def get_avaliable(accountid, datatype):
result = 0
resultlist = get_trade_detail_data(accountid, datatype, "ACCOUNT")
for obj in resultlist:
# print("账户ID:", obj.m_strAccountID, "总资产:", obj.m_dBalance, "可用金额:", obj.m_dAvailable)
print(f'总资产: {obj.m_dBalance:.2f}, 净资产: {obj.m_dAssureAsset:.2f}, 总市值: {obj.m_dInstrumentValue:.2f}',
f'总负债: {obj.m_dTotalDebit:.2f}, 可用金额: {obj.m_dAvailable:.2f}, 盈亏: {obj.m_dPositionProfit:.2f}')
result = obj.m_dAvailable # 可用金额,指账户中可用于交易和提取的资金金额
return result
def get_holdings(accountid, datatype):
holdinglist = {}
resultlist = get_trade_detail_data(accountid, datatype, "POSITION")
for obj in resultlist:
# print("股票代码:", obj.m_strInstrumentID, "市场类型:", obj.m_strExchangeID, "可用余额:", obj.m_nCanUseVolume)
print(f'股票代码: {obj.m_strInstrumentID}, 市场类型: {obj.m_strExchangeID}, 证券名称: {obj.m_strInstrumentName}, 持仓量: {obj.m_nVolume}, 可用数量: {obj.m_nCanUseVolume}',f'成本价: {obj.m_dOpenPrice:.2f}, 市值: {obj.m_dInstrumentValue:.2f}, 持仓成本: {obj.m_dPositionCost:.2f}, 盈亏: {obj.m_dPositionProfit:.2f}')
holdinglist[obj.m_strInstrumentID + "." + obj.m_strExchangeID] = obj.m_nCanUseVolume # 可用余额
return holdinglist

为什么这几个值很异常? |