visualise_position#
API documentation for tradeexecutor.visual.position.visualise_position Python function.
- visualise_position(position, df, height=800, width=1200, autosize=False, extended=False)[source]#
Visualise position as a Plotly figure with subplots.
Price chart with trade markers on top subplot
Position value in middle subplot
PnL charts on bottom subplot
Example:
from tradeexecutor.visual.position import visualise_position, calculate_position_timeline # Visualise the last position in the table above position_id = vault_df.index[-2] position = state.portfolio.get_position_by_id(position_id) position_df = calculate_position_timeline( strategy_universe, position, end_at=state.backtest_data.end_at, ) fig = visualise_position( position, position_df, extended=True, height=1600, width=1200, autosize=False, ) fig.update_layout( margin=dict(b=100), # add bottom margin legend=dict( orientation="h", yanchor="top", y=-0.05, xanchor="center", x=0.5 ) ) fig.show(renderer="notebook")
- Parameters:
extended – Plots a tons of stuff.
position (TradingPosition) –
df (DataFrame) –
- Return type:
Figure