18 lines
619 B
Python
18 lines
619 B
Python
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 |