This commit is contained in:
2025-10-27 17:38:49 +08:00
commit f37c1158ee
6 changed files with 261 additions and 0 deletions
+18
View File
@@ -0,0 +1,18 @@
from xtquant import xtdata, xttrader
from xtquant.xttype import StockAccount
def getInstrumentName(stock_code):
# print(f"getInstrumentName: 获取标的名称 {stock_code}")
detail = xtdata.get_instrument_detail(stock_code, False)
return detail['InstrumentName']
def getStockPosition(stock_code: str, xt_trader: xttrader.XtQuantTrader, account: StockAccount):
volume = 0
positions = xt_trader.query_stock_positions(account)
if positions:
for pos in positions:
if pos.stock_code == stock_code:
volume = pos.m_nVolume
break
return volume