History
Table of contents
History
The history class handles completed trade deals and trade orders in the trading history of an account.
Attributes
| Name |
Type |
Description |
Default |
deals |
list[TradeDeal] |
Iterable of trade deals |
[] |
orders |
list[TradeOrder] |
Iterable of trade orders |
[] |
total_deals |
int |
Total number of deals |
0 |
total_orders |
int |
Total number orders |
0 |
group |
str |
Filter for selecting history by symbols. |
"" |
mt5 |
MetaTrader |
MetaTrader instance |
None |
config |
Config |
Config instance |
None |
__init__
Parameters:
| Name |
Type |
Description |
Default |
date_from |
datetime|float |
Date the deals are requested from. Set by the 'datetime' object or as a number of seconds elapsed since 1970.01.01. Defaults to twenty-four hours from the current time in 'utc' |
0 |
date_to |
datetime|float |
Date up to which the deals are requested. Set by the 'datetime' object or as a number of seconds elapsed since 1970.01.01. Defaults to the current time in "utc" |
0 |
group |
str |
Filter for selecting history by symbols. |
"" |
initialize
Get deals and orders within the timeframe specified in the constructor.
get_deals
Get deals from trading history using the parameters set in the constructor.
Returns
| Name |
Type |
Description |
deals |
tuple[TradeDeal, ...] |
A list of trade deals |
get_deals_by_ticket
Get deals by ticket number. This filters deals by ticket based on the deals already fetched in initialize.
Parameters
| Name |
Type |
Description |
ticket |
int |
Ticket number to get |
Returns:
| Name |
Type |
Description |
deals |
tuple[TradeDeal, ...] |
A tuple of trade deals |
get_deals_by_position
Get deals by position
Parameters
| Name |
Type |
Description |
position |
int |
Position number to get |
Returns
| Name |
Type |
Description |
deals |
tuple[TradeDeal, ...] |
A tuple of trade deals |
get_orders
Get orders from trading history using the parameters set in the constructor.
get_orders_by_position
Get orders by position.
Parameters
| Name |
Type |
Description |
position |
int |
Position number to get |
Returns
| Name |
Type |
Description |
orders |
tuple[TradeOrder, ...] |
A tuple of trade orders |
get_orders_by_ticket
Get orders by ticket number. This filters orders by ticket based on the orders already fetched in initialize.
Parameters
| Name |
Type |
Description |
ticket |
int |
ticket number to get |
Returns
| Name |
Type |
Description |
orders |
tuple[TradeOrder, ...] |
A tuple of trade orders |