QMT · 内置 Python成交回报实时主推函数
account_callback
当资金账号状态有变化时,这个函数被客户端调用
提示
仅在实盘运行模式下生效。
需要先在init里调用ContextInfo.set_account后生效。
用法
account_callback(ContextInfo, accountInfo)
释义
当资金账号状态有变化时,这个函数被客户端调用
参数
ContextInfo:特定对象
accountInfo:账号对象在新窗口打开或信用账号对象在新窗口打开
返回值
无
示例
示例
#coding:gbk
def show_data(data):
tdata = {}
for ar in dir(data):
if ar[:2] != 'm_':continue
try:
tdata[ar] = data.__getattribute__(ar)
except:
tdata[ar] = '<CanNotConvert>'
return tdata
def init(ContextInfo):
# 设置对应的资金账号
# 示例需要在策略交易界面运行
ContextInfo.set_account(account)
def after_init(ContextInfo):
# 在策略交易界面运行时,account的值会被赋值为策略配置中的账号,编辑器界面运行时,需要手动赋值
# 编译器界面里执行的下单函数不会产生实际委托
passorder(23, 1101, account, "000001.SZ", 5, 0, 100, "示例", 2, "投资备注",ContextInfo)
pass
def account_callback(ContextInfo, accountInfo):
print(show_data(accountInfo))
返回值
{'m_Enable': True, 'm_dAssetBalance': 9975010.001775814, 'm_dAssureAsset': 9975010.001775814, 'm_dAvailable': 9555238.805375814, 'm_dBalance': 9975010.001775814, 'm_dBuyWaitMoney': 0.0, 'm_dCashIn': 0.0, 'm_dCloseProfit': 0.0, 'm_dCommission': 14.284000000000006, 'm_dCredit': 0.0, 'm_dCurrMargin': 0.0, 'm_dDeposit': 0.0, 'm_dEntrustAsset': 0.0, 'm_dFetchBalance': 9556221.001775814, 'm_dFrozenCash': 982.1964, 'm_dFrozenCommission': 0.0, 'm_dFrozenMargin': 9555238.805375814, 'm_dFrozenRoyalty': 0.0, 'm_dFundValue': 0.0, 'm_dGoldFrozen': 0.0, 'm_dGoldValue': 0.0, 'm_dInitBalance': 0.0, 'm_dInitCloseMoney': -4249.283999999998, 'm_dInstrumentValue': 418789.0, 'm_dInstrumentValueRMB': 0.0, 'm_dIntradayBalance': 0.0, 'm_dIntradayFreedBalance': 0.0, 'm_dLoanValue': 0.0, 'm_dLongValue': 0.0, 'm_dMargin': 0.0, 'm_dMaxMarginRate': 0.0, 'm_dMortgage': 0.0, 'm_dNav': 0.0, 'm_dNetValue': 0.0, 'm_dOccupiedBalance': 0.0, 'm_dPositionProfit': -3441.6657800000025, 'm_dPreBalance': 9556221.001775814, 'm_dPreCredit': 0.0, 'm_dPreMortgage': 0.0, 'm_dPurchasingPower': 0.0, 'm_dRawMargin': 0.0, 'm_dRealRiskDegree': 0.0, 'm_dRealUsedMargin': 0.0, 'm_dReceiveInterestTotal': 0.0, 'm_dRepurchaseValue': 0.0, 'm_dRisk': 0.0, 'm_dRoyalty': 0.0, 'm_dSellWaitMoney': 0.0, 'm_dShortValue': 0.0, 'm_dStockValue': 418789.0, 'm_dSubscribeFee': 0.0, 'm_dTotalDebit': 0.0, 'm_dWithdraw': 0.0, 'm_nBrokerType': 2, 'm_nDirection': 48, 'm_strAccountID': '2000567', 'm_strAccountKey': '2____11194____114911____49____2000567____', 'm_strAccountRemark': '', 'm_strBrokerName': '', 'm_strMoneyType': '', 'm_strOpenDate': '', 'm_strStatus': '准备登录', 'm_strTradingDate': '20240220'}
{'m_Enable': True, 'm_dAssetBalance': 9975010.001775814, 'm_dAssureAsset': 9975010.001775814, 'm_dAvailable': 9556221.001775814, 'm_dBalance': 9975010.001775814, 'm_dBuyWaitMoney': 0.0, 'm_dCashIn': 0.0, 'm_dCloseProfit': 0.0, 'm_dCommission': 14.284000000000006, 'm_dCredit': 0.0, 'm_dCurrMargin': 0.0, 'm_dDeposit': 0.0, 'm_dEntrustAsset': 0.0, 'm_dFetchBalance': 9556221.001775814, 'm_dFrozenCash': 0.0, 'm_dFrozenCommission': 0.0, 'm_dFrozenMargin': 9556221.001775814, 'm_dFrozenRoyalty': 0.0, 'm_dFundValue': 0.0, 'm_dGoldFrozen': 0.0, 'm_dGoldValue': 0.0, 'm_dInitBalance': 0.0, 'm_dInitCloseMoney': -4249.283999999998, 'm_dInstrumentValue': 418789.0, 'm_dInstrumentValueRMB': 0.0, 'm_dIntradayBalance': 0.0, 'm_dIntradayFreedBalance': 0.0, 'm_dLoanValue': 0.0, 'm_dLongValue': 0.0, 'm_dMargin': 0.0, 'm_dMaxMarginRate': 0.0, 'm_dMortgage': 0.0, 'm_dNav': 0.0, 'm_dNetValue': 0.0, 'm_dOccupiedBalance': 0.0, 'm_dPositionProfit': -3441.6657800000025, 'm_dPreBalance': 9556221.001775814, 'm_dPreCredit': 0.0, 'm_dPreMortgage': 0.0, 'm_dPurchasingPower': 0.0, 'm_dRawMargin': 0.0, 'm_dRealRiskDegree': 0.0, 'm_dRealUsedMargin': 0.0, 'm_dReceiveInterestTotal': 0.0, 'm_dRepurchaseValue': 0.0, 'm_dRisk': 0.0, 'm_dRoyalty': 0.0, 'm_dSellWaitMoney': 0.0, 'm_dShortValue': 0.0, 'm_dStockValue': 418789.0, 'm_dSubscribeFee': 0.0, 'm_dTotalDebit': 0.0, 'm_dWithdraw': 0.0, 'm_nBrokerType': 2, 'm_nDirection': 48, 'm_strAccountID': '2000567', 'm_strAccountKey': '2____11194____114911____49____2000567____', 'm_strAccountRemark': '', 'm_strBrokerName': '', 'm_strMoneyType': '', 'm_strOpenDate': '', 'm_strStatus': '准备登录', 'm_strTradingDate': '20240220'}
{'m_Enable': True, 'm_dAssetBalance': 9975010.001775814, 'm_dAssureAsset': 9975010.001775814, 'm_dAvailable': 9555238.805375814, 'm_dBalance': 9975010.001775814, 'm_dBuyWaitMoney': 0.0, 'm_dCashIn': 0.0, 'm_dCloseProfit': 0.0, 'm_dCommission': 14.480400000000007, 'm_dCredit': 0.0, 'm_dCurrMargin': 0.0, 'm_dDeposit': 0.0, 'm_dEntrustAsset': 0.0, 'm_dFetchBalance': 9556221.001775814, 'm_dFrozenCash': 0.0, 'm_dFrozenCommission': 0.0, 'm_dFrozenMargin': 9555238.805375814, 'm_dFrozenRoyalty': 0.0, 'm_dFundValue': 0.0, 'm_dGoldFrozen': 0.0, 'm_dGoldValue': 0.0, 'm_dInitBalance': 0.0, 'm_dInitCloseMoney': -4249.283999999998, 'm_dInstrumentValue': 419771.0, 'm_dInstrumentValueRMB': 0.0, 'm_dIntradayBalance': 0.0, 'm_dIntradayFreedBalance': 0.0, 'm_dLoanValue': 0.0, 'm_dLongValue': 0.0, 'm_dMargin': 0.0, 'm_dMaxMarginRate': 0.0, 'm_dMortgage': 0.0, 'm_dNav': 0.0, 'm_dNetValue': 0.0, 'm_dOccupiedBalance': 0.0, 'm_dPositionProfit': -3441.6657800000025, 'm_dPreBalance': 9556221.001775814, 'm_dPreCredit': 0.0, 'm_dPreMortgage': 0.0, 'm_dPurchasingPower': 0.0, 'm_dRawMargin': 0.0, 'm_dRealRiskDegree': 0.0, 'm_dRealUsedMargin': 0.0, 'm_dReceiveInterestTotal': 0.0, 'm_dRepurchaseValue': 0.0, 'm_dRisk': 0.0, 'm_dRoyalty': 0.0, 'm_dSellWaitMoney': 0.0, 'm_dShortValue': 0.0, 'm_dStockValue': 419771.0, 'm_dSubscribeFee': 0.0, 'm_dTotalDebit': 0.0, 'm_dWithdraw': 0.0, 'm_nBrokerType': 2, 'm_nDirection': 48, 'm_strAccountID': '2000567', 'm_strAccountKey': '2____11194____114911____49____2000567____', 'm_strAccountRemark': '', 'm_strBrokerName': '', 'm_strMoneyType': '', 'm_strOpenDate': '', 'm_strStatus': '准备登录', 'm_strTradingDate': '20240220'}
官方来源
QMT 官方文档:资金账号状态变化主推。网页核对日期:2026-10-11。