calculate_position_timeline#
API documentation for tradeexecutor.visual.position.calculate_position_timeline Python function.
- calculate_position_timeline(strategy_universe, position, end_at=None, pnl_method=<function calculate_pnl>)[source]#
Calculatea visualisation dato for a single position.
Price
Position size
PnL
TODO: Missing vault perf and managemetn fees.
Example data:
quantity delta executed_price fee cumulative_cost avg_price mark_price value realised_delta realised_pnl unrealised_pnl pnl timestamp 2025-03-22 00:00:00 51.894608 51.894608 1.002456 0.0 52.022051 0.000000 1.002456 52.022051 0.0 0.000000 0.00000 0.000000 2025-03-22 01:00:00 51.894608 0.000000 1.002456 0.0 52.022051 0.000000 1.002456 52.022051 0.0 0.000000 0.00000 0.000000 2025-03-22 02:00:00 51.894608 0.000000 1.002456 0.0 52.022051 0.000000 1.002456 52.022051 0.0 0.000000 0.00000 0.000000 2025-03-22 03:00:00 51.894608 0.000000 1.002456 0.0 52.022051 0.000000 1.002456 52.022051 0.0 0.000000 0.00000 0.000000
- Parameters:
end_at (datetime.datetime | None) – End at timestamp for positions that are still open/were open at the end of the backtest.
pnl_method (Callable) –
Method we use to calculate profit and losses over time.
Only relevant for open positions, as closed positions have no ambiguity of their PnL values.
strategy_universe (TradingStrategyUniverse) –
position (TradingPosition) –
- Returns:
DataFrame with columns as above,
- Return type:
DataFrame