使用history_deals_get读取历史记录,部分最新的数据无法被读取?

 
groupStr = "*ARS*"
deals=mt5.history_deals_get(from_date, to_date, group=groupStr)
if deals==None:
    print("No deals with group=\"{}\", error code={}".format(groupStr,mt5.last_error()))
elif len(deals)> 0:
    print("history_deals_get({}, {}, group=\"{}\")={}".format(from_date,to_date,groupStr,len(deals))) 
    print(deals)
else:
    print("deals is not None ,and count !> 0",deals)
print("")

在上面的代码中,如果USDARS是刚刚完成的交易(30分钟内都有这个问题,多久没有这个问题还没试出来),代码就会走到else部分。

deals is not None ,and count !> 0 ()

尝试使用position_id的搜索就没有这个问题。

deals=mt5.history_deals_get(position=position_id)
if deals==None:
    print("No deals with position={}, error code={}".format(position_id,mt5.last_error()))
elif len(deals)> 0:
    print("history_deals_get({}, {}, position={})={}".format(from_date,to_date,position_id,len(deals)))
    print("deals by position",deals)

我想问下,有没有什么办法,查询到历史交易的position_id?

 
history_deals_get这个是自定义函数;

意思就是这个函数是自己写的,应该检测这个函数有没有问题

光你这几句代码看不出毛病