history_deals_total
history_deals_total
获取交易历史中指定时间间隔内的交易数量。
history_deals_total(
date_from, // 请求交易的开始日期
date_to // 请求交易的结束日期
)参数
- date_from
[in] 请求交易的开始日期。通过’datetime’对象或根据1970.01.01以来过去的秒数设置。所需的未命名参数。
- date_to
[in] 请求交易的结束日期。通过’datetime’对象或根据1970.01.01以来过去的秒数设置。所需的未命名参数。
返回值
整数值。
注意
该函数类似于HistoryDealsTotal。
例如:
from datetime import datetime
import MetaTrader5 as mt5
# 显示有关MetaTrader 5程序包的数据
print("MetaTrader5 package author: ",mt5.__author__)
print("MetaTrader5 package version: ",mt5.__version__)
# 建立与MetaTrader 5程序端的连接
if not mt5.initialize():
print("initialize() failed, error code =",mt5.last_error())
quit()
# 获取历史中的交易数量
from_date=datetime(2020,1,1)
to_date=datetime.now()
deals=mt5.history_deals_total(from_date, to_date)
if deals>0:
print("Total deals=",deals)
其他:
print("Deals not found in history")
# 断开与MetaTrader 5程序端的连接
mt5.shutdown()