trading.optimizer.analysis.context
trading.optimizer.analysis.context
AnalysisContext
Bases: NamedTuple
The analysis data necessary to compute the metrics for a backtest.
Attributes:
| Name | Type | Description |
|---|---|---|
equity_curve |
tuple[EquityPoint, ...]
|
The equity (value of units + cash) in USD for every portfolio event. |
returns |
tuple[ReturnPoint, ...]
|
The total returns (in percent) for every equity point. |
drawdowns |
tuple[DrawdownPoint, ...]
|
The peak (USD) & drawdown (in percent) for every equity point. |
trades |
tuple[TradePoint, ...]
|
The trades made during the execution of the backtester. |
DrawdownPoint
Bases: NamedTuple
A single drawdown point in time.
Attributes:
| Name | Type | Description |
|---|---|---|
timestamp |
time_unix_ms
|
The time for the drawdown point (unix ms). |
peak |
time_unix_ms
|
The highest equity up to and including this point. |
drawdown_percent |
percent
|
The current percentage decline of the equity from its peak value to its lowest point. |
EquityPoint
Bases: NamedTuple
A single equity point in an equity curve.
Attributes:
| Name | Type | Description |
|---|---|---|
timestamp |
time_unix_ms
|
The time for the equity point (unix ms). |
equity |
USD
|
The price for the equity point at its timestamp. |
ReturnPoint
Bases: NamedTuple
A single return point in time.
Attributes:
| Name | Type | Description |
|---|---|---|
timestamp |
time_unix_ms
|
The time for the return point (unix ms). |
return_percent |
percent
|
The percent increase / decrease from the previous point. |
TradePoint
Bases: NamedTuple
A single completed trade (long-only).
Attributes:
| Name | Type | Description |
|---|---|---|
entry_time |
time_unix_ms
|
When the position was opened (unix ms). |
exit_time |
time_unix_ms
|
When the position was closed (unix ms). |
entry_price |
USD
|
Price at entry. |
exit_price |
USD
|
Price at exit. |
quantity |
units
|
Units held. |