Add indicator and strategy interfaces
Introduce the typed interfaces that form the foundation of the strategy framework: Indicator<T> for market analysis and Strategy with Signal types for trading decisions. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
6
src/indicator.ts
Normal file
6
src/indicator.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import { Alpaca } from "./alpaca";
|
||||
|
||||
export interface Indicator<T> {
|
||||
name: string;
|
||||
evaluate(alpaca: Alpaca): Promise<T>;
|
||||
}
|
||||
15
src/strategy.ts
Normal file
15
src/strategy.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { Alpaca } from "./alpaca";
|
||||
|
||||
export type SignalDirection = 'buy' | 'sell';
|
||||
|
||||
export interface Signal {
|
||||
symbol: string;
|
||||
direction: SignalDirection;
|
||||
allocation: number; // fraction of this strategy's capital to use (0-1)
|
||||
}
|
||||
|
||||
export interface Strategy {
|
||||
name: string;
|
||||
capitalAllocation: number; // fraction of total account capital (0-1)
|
||||
execute(alpaca: Alpaca): Promise<Signal[]>;
|
||||
}
|
||||
Reference in New Issue
Block a user