TradeAnalysis#

tradeexecutor.analysis.trade_analyser.TradeAnalysis class.

class TradeAnalysis[source]#

Bases: object

Analysis of trades in a portfolio.

__init__(portfolio, asset_histories=<factory>)#
Parameters
Return type

None

Methods

__init__(portfolio[, asset_histories])

calculate_summary_statistics()

Calculate some statistics how our trades went.

create_timeline()

Create a timeline feed how we traded over a course of time.

get_all_positions()

Return open and closed positions over all traded assets.

get_first_opened_at()

get_last_closed_at()

get_open_positions()

Return open and closed positions over all traded assets.

Attributes

portfolio

asset_histories

How a particular asset traded.

asset_histories: Dict[object, AssetTradeHistory]#

How a particular asset traded. Asset id -> Asset history mapping

get_all_positions()[source]#

Return open and closed positions over all traded assets.

Return type

Iterable[Tuple[PrimaryKey, TradePosition]]

get_open_positions()[source]#

Return open and closed positions over all traded assets.

Return type

Iterable[Tuple[PrimaryKey, TradePosition]]

calculate_summary_statistics()[source]#

Calculate some statistics how our trades went.

Return type

TradeSummary

create_timeline()[source]#

Create a timeline feed how we traded over a course of time.

Note: We assume each position has only one enter and exit event, not position increases over the lifetime.

Returns

DataFrame with timestamp and timeline_event columns

Return type

DataFrame

__init__(portfolio, asset_histories=<factory>)#
Parameters
Return type

None