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. |
"" |
ticket |
int |
Filter for selecting history by ticket number |
0 |
position |
int |
Filter for selecting history deals by position |
0 |
initialized |
bool |
check if initial request has been sent to the terminal to get history. |
False |
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. |
"" |
ticket |
int |
Filter for selecting history by ticket number |
0 |
position |
int |
Filter for selecting history deals by position |
0 |
init
Get history deals and orders
Parameters
| Name |
Type |
Description |
Default |
deals |
bool |
If true get history deals during initial request to terminal |
True |
orders |
bool |
If true get history orders during initial request to terminal |
True |
Returns
| Name |
Type |
Description |
Default |
bool |
bool |
True if all requests were successful else False |
False |
get_deals
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' |
None |
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" |
None |
group |
str |
Filter for selecting history by symbols. |
"" |
retries |
int |
Number of retries if the request fails. |
3 |
Returns:
| Name |
Type |
Description |
Default |
deals |
tuple[TradeDeal] |
A list of trade deals |
[] |
get_deals_ticket
Get deals by ticket number
Parameters:
| Name |
Type |
Description |
Default |
ticket |
int |
Ticket number to get |
0 |
Returns:
| Name |
Type |
Description |
Default |
deals |
tuple[TradeDeal] |
A list of trade deals |
[] |
get_deals_position
Get deals by position
Parameters:
| Name |
Type |
Description |
Default |
position |
int |
Position number to get |
0 |
Returns:
| Name |
Type |
Description |
Default |
deals |
tuple[TradeDeal] |
A list of trade deals |
[] |
deals_total
Get total number of deals within the specified period in the constructor.
Returns
| Name |
Type |
Description |
Default |
total_deals |
int |
Total number of deals |
0 |
get_orders
Get orders from trading history using the parameters set in the constructor.
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' |
None |
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" |
None |
group |
str |
Filter for selecting history by symbols. |
"" |
Returns
| Name |
Type |
Description |
Default |
orders |
tuple[TradeOrder] |
A list of trade orders |
[] |
get_orders_position
Get orders by position.
Parameters
| Name |
Type |
Description |
Default |
position |
int |
Position number to get |
0 |
Returns
| Name |
Type |
Description |
Default |
orders |
tuple[TradeOrder] |
A list of trade orders |
[] |
get_order_ticket
Get a single order by ticket number.
Parameters
| Name |
Type |
Description |
Default |
ticket |
int |
Ticket number to get |
0 |
Returns
| Name |
Type |
Description |
Default |
order |
TradeOrder |
A single trade order |
None |
orders_total
Get total number of orders within the specified period in the constructor.
Returns
| Name |
Type |
Description |
Default |
total_orders |
int |
Total number orders |
0 |