OK, 差不多了
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import sfgrid_constants
|
||||
import xtquant.xtconstant as xtconstant
|
||||
from xtquant import xtdata, xttrader
|
||||
from xtquant.xttype import StockAccount, XtOrder
|
||||
|
||||
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
|
||||
|
||||
def minPosition(gridIndex:int):
|
||||
return sfgrid_constants.grid_volume * gridIndex
|
||||
|
||||
def queryPendingOrder(stock_code:str, tag: str, xt_trader: xttrader.XtQuantTrader, account: StockAccount):
|
||||
if stock_code == None or tag == None:
|
||||
return []
|
||||
orders = xt_trader.query_stock_orders(account)
|
||||
result = [order for order in orders if order.order_status == xtconstant.ORDER_REPORTED and order.stock_code == stock_code and order.strategy_name == tag]
|
||||
return result
|
||||
Reference in New Issue
Block a user