ezyquant.backtesting.context.Context#
- class ezyquant.backtesting.context.Context(ts: Timestamp, symbol: str = '', signal: Any = nan, close_price: float = nan, volume: float = nan, cost_price: float = nan, cash: float = nan, total_cost_value: float = nan, total_market_value: float = nan, port_value: float = nan)#
Context class for backtest.
Context.buy_pct_port
(pct_port)Calculate buy volume from the percentage of the portfolio.
Context.buy_pct_position
(pct_position)Calculate buy volume from the percentage of the current position.
Context.buy_value
(value)Calculate buy volume from the given value.
Context.sell_pct_port
(pct_port)Calculate sell volume from the percentage of the portfolio.
Context.sell_pct_position
(pct_position)Calculate sell volume from the percentage of the current position.
Context.sell_value
(value)Calculate sell volume from the given value.
Context.target_pct_port
(pct_port)Calculate buy/sell volume to make the current position reach the target percentage of the portfolio.
Context.target_value
(value)Calculate buy/sell volume to make the current position reach the target value.
Available cash.
Close price.
Cost price.
Total portfolio value.
Signal.
Selected symbol.
Sum of all stock market value in portfolio.
Sum of all stock cost value in portfolio.
Current Volume.
Current timestamp.