代码测试与整理
This commit is contained in:
+1
-27
@@ -1,9 +1,5 @@
|
||||
import config
|
||||
import xtquant.xtconstant as xtconstant
|
||||
from xtquant import xtdata, xttrader
|
||||
from xtquant.xttype import StockAccount, XtOrder, XtPosition
|
||||
|
||||
import datetime
|
||||
|
||||
def is_trading_time():
|
||||
"""
|
||||
判断当前时间是否在周一至周五的9:30~11:30或13:00~15:00时间段内
|
||||
@@ -37,25 +33,3 @@ def is_trading_time():
|
||||
|
||||
return False
|
||||
|
||||
|
||||
def getStockPosition(stock_code: str, xt_trader: xttrader.XtQuantTrader, account: StockAccount):
|
||||
volume = 0
|
||||
positions = xt_trader.query_stock_positions(account)
|
||||
if positions:
|
||||
for temp in positions:
|
||||
pos:XtPosition = temp
|
||||
if pos.stock_code == stock_code:
|
||||
volume = pos.volume
|
||||
break
|
||||
|
||||
return volume
|
||||
|
||||
def minPosition(gridIndex:int):
|
||||
return config.grid_volume * gridIndex
|
||||
|
||||
def queryPendingOrder(stock_code:str, tag: str, xt_trader: xttrader.XtQuantTrader, account: StockAccount) -> list[XtOrder]:
|
||||
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