trade_analyser#

API documentation for tradeexecutor.analysis.trade_analyser Python module in Trading Strategy.

Module description#

Analyze the trade performance of algorithm.

Calculate success/fail rate of trades and plot success distribution.

Example analysis include:

  • Table: Summary of all trades

  • Graph: Trade won/lost distribution

  • Timeline: Analysis of each individual trades made

Note

A lot of this code has been lifted off from trading-strategy package where it had to deal with different trading frameworks. It could be simplified greatly now.

Classes#

TimelineRowStylingMode

An enumeration.

TimelineStyler

Style the expanded trades timeline table.

TradeAnalysis

Analysis of trades in a portfolio.

TradeSummary

Some generic statistics over all the trades

Functions#

avg(lst)

avg_timedelta(lst)

build_trade_analysis(portfolio)

Build a trade analysis from list of positions.

calculate_annualised_return(profit_pct, duration)

Calculate annualised return %.

expand_timeline(exchanges, pair_universe, ...)

Expand trade history timeline to human readable table.

expand_timeline_raw(timeline[, timestamp_format])

A simplified version of expand_timeline that does not care about pair info, exchanges, or opening capital, and also provides raw figures.