init
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user