From 345ff933ecb2b65e9c5660cb6e1b9899484ae558 Mon Sep 17 00:00:00 2001 From: Jon Date: Fri, 30 Jan 2026 14:05:41 -0700 Subject: [PATCH] Add indicator and strategy interfaces Introduce the typed interfaces that form the foundation of the strategy framework: Indicator for market analysis and Strategy with Signal types for trading decisions. Co-Authored-By: Claude Opus 4.5 --- src/indicator.ts | 6 ++++++ src/strategy.ts | 15 +++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 src/indicator.ts create mode 100644 src/strategy.ts diff --git a/src/indicator.ts b/src/indicator.ts new file mode 100644 index 0000000..a778121 --- /dev/null +++ b/src/indicator.ts @@ -0,0 +1,6 @@ +import { Alpaca } from "./alpaca"; + +export interface Indicator { + name: string; + evaluate(alpaca: Alpaca): Promise; +} diff --git a/src/strategy.ts b/src/strategy.ts new file mode 100644 index 0000000..c8ea4af --- /dev/null +++ b/src/strategy.ts @@ -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; +}