|
@@ -180,12 +180,13 @@ def buy_trader(data, positions):
|
|
|
|
|
|
keep_stocks = results_industry.split(",")
|
|
|
new_keep_stock = [stock.replace('XSHG', 'SH').replace('XSHE', 'SZ') for stock in keep_stocks]
|
|
|
- print(f'new_keep_stock is:{new_keep_stock}')
|
|
|
+ print(f'new_keep_stock is:{len(new_keep_stock)},{new_keep_stock}')
|
|
|
|
|
|
+ max_pos = 12
|
|
|
for stock in new_keep_stock:
|
|
|
asset = xt_trader.query_stock_asset(acc)
|
|
|
cash = asset.cash
|
|
|
- if cash > 2000 and len(positions) < 12:
|
|
|
+ if cash > 2000 and len(positions) < max_pos:
|
|
|
if stock in new_keep_stock:
|
|
|
current_price = data[stock]['lastPrice']
|
|
|
volume = int((cash / 2 / current_price) // 100 * 100)
|
|
@@ -193,6 +194,8 @@ def buy_trader(data, positions):
|
|
|
order_id = xt_trader.order_stock(acc, stock, xtconstant.STOCK_BUY, volume, xtconstant.LATEST_PRICE,
|
|
|
current_price, 'strategy1', 'order_test')
|
|
|
print(order_id)
|
|
|
+ else:
|
|
|
+ print(f'Cash只有:{cash} 或者 现有持仓{len(positions)} 超过了{max_pos}')
|
|
|
engine_hlfx_pool.dispose()
|
|
|
print('一轮结束了,现在时间是:', dt.now())
|
|
|
|