expand_timeline#

API documentation for tradeexecutor.analysis.trade_analyser.expand_timeline Python function.

expand_timeline(exchanges, pair_universe, timeline, vmin=- 0.3, vmax=0.2, timestamp_format='%Y-%m-%d', hidden_columns=['Id', 'PnL % raw'], row_styling_mode=TimelineRowStylingMode.simple)[source]#

Expand trade history timeline to human readable table.

This will the outputting much easier in Python Notebooks.

Currently does not incrementing/decreasing positions gradually.

Instaqd of applying styles or returning a styled dataframe, we return a callable that applies the styles. This is because of Pandas issue https://github.com/pandas-dev/pandas/issues/40675 - hidden indexes, columns, etc. are not exported.

Parameters:
  • exchanges (Set[Exchange]) – Needed for exchange metadata

  • pair_universe (PandasPairUniverse) – Needed for trading pair metadata

  • vmax – Trade success % to have the extreme green color.

  • vmin – The % of lost capital on the trade to have the extreme red color.

  • timestamp_format – How to format Opened at column, as passed to strftime()

  • hidden_columns – Hide columns in the output table

  • timeline (DataFrame) –

Returns:

DataFrame with human=readable position win/loss information, having DF indexed by timestamps and a styler function

Return type:

Tuple[DataFrame, TimelineStyler]