Pivotrades requires only a callback function and will handle historical price data, performance monitoring, and state management, giving you the freedom to focus more on strategy and less on infrastructure.
Feel free to visit the documentation
Download from NPM
> npm i pivotrade
Here is an example implementation of a classic Simple Moving Average (SMA) crossover strategy trading on the S&P ETF. A strategy that involves:
Buying N shares of a security when it's 20 day moving average crosses above its 50 day moving average. Set a stop loss at 10% below it's long entry price.
Selling N shares of a security when its 20 day average falls below the 50 day average.
// node example/sma_cross.jsconst Session = Session;const Algorithm = Algorithm;const SMA = AlgorithmSMA;const session =name: "SMA Crossover"symbol: "SPY"capital: 100000start_date: "2006-01-01"end_date: "2010-01-01"indicators:SMA50: 50SMA20: 20;session;