UNPKG

@showr/core

Version:
37 lines (36 loc) 1.71 kB
import { Quote, Dataset, Indicator, BacktestConfiguration, BacktestReport } from './'; import { TradePositionType } from './position'; export declare class StrategyValue { position: TradePositionType | undefined; constructor(position: TradePositionType | undefined); } /** * Defines a strategy that can be back-tested. */ export declare class Strategy<P = unknown, T = number> { protected _name: string; protected _define: (quote: Quote<T>) => StrategyValue | undefined; protected _indicators: Indicator<P, T>[]; /** * Creates a strategy with definition and indicators. * @param name - Name of the strategy. * @param define - Strategy definition function that accepts a `Quote` and returns a `PositionType`. * @param indicators - Array of `Indicator` that can be used to determine the position in this strategy. */ constructor(name: string, define: (quote: Quote<T>) => StrategyValue | undefined, indicators: Indicator<P, T>[]); get name(): string; get indicators(): Indicator<P, T>[]; /** * Applies the strategy over a given quote and returns the strategy values. * @param quote - `Quote` on which strategy should be applied. * @returns `StrategyPoint`. */ apply(quote: Quote<T>): StrategyValue | undefined; /** * Backtests the strategy over a given Dataset and configuration, and returns the report. * @param dataset - `Dataset` on which strategy should be applied over each quote. * @param configuration - `BacktestConfiguration` that configures the backtest. * @returns `BacktestReport`. */ backtest(dataset: Dataset<T>, configuration: BacktestConfiguration): BacktestReport; }