Feat: Add orderbook context to strategy base

This commit is contained in:
2026-03-16 12:29:47 -07:00
parent 00e613e27a
commit 83df308c37

View File

@@ -2,21 +2,26 @@
* Base strategy class. All strategies extend this.
*
* Strategies receive market state updates and emit trade signals.
* Signals are { side: 'yes'|'no', price: number, size: number, reason: string }
* Signals are { side: 'yes'|'no', price: number, maxPrice: number, size: number, reason: string }
*
* `price` = ideal/target price in cents
* `maxPrice` = maximum acceptable fill price (slippage tolerance)
*/
export class BaseStrategy {
constructor(name, config = {}) {
this.name = name;
this.config = config;
this.enabled = true;
this.mode = 'paper'; // 'paper' | 'live'
this.mode = 'paper';
}
/**
* Called on every market state update.
* @param {object} marketState - includes yesPct, noPct, orderbook, ticker, closeTime, etc.
* @param {string} caller - 'paper' | 'live' — so strategies can track per-caller state
* Return a signal object or null.
*/
evaluate(marketState) {
evaluate(marketState, caller = 'paper') {
throw new Error(`${this.name}: evaluate() not implemented`);
}