|
@@ -217,18 +217,18 @@ def buy_trader(data, positions):
|
|
|
cash = asset.cash
|
|
|
positions_dict = {positions[x].stock_code: positions[x].volume for x in range(0, len(positions)) if
|
|
|
positions[x].volume > 0}
|
|
|
- if stock in new_keep_stock:
|
|
|
- current_price = data[stock]['lastPrice']
|
|
|
- current_high = data[stock]['high']
|
|
|
- if cash > 5000 and len(positions_dict) < max_pos and current_price > 9 \
|
|
|
- and current_price > (current_high*0.98):
|
|
|
- volume = int((cash / 5 / current_price) // 100 * 100)
|
|
|
- print('买入信号!!!!!!', stock, volume, current_price)
|
|
|
- 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}')
|
|
|
+ print(f'判断{stock}:cash={cash},持仓数量为{len(positions_dict)}')
|
|
|
+ current_price = data[stock]['lastPrice']
|
|
|
+ current_high = data[stock]['high']
|
|
|
+ if cash > 5000 and len(positions_dict) < max_pos and current_price > 9 \
|
|
|
+ and current_price > (current_high*0.98):
|
|
|
+ volume = int((cash / 5 / current_price) // 100 * 100)
|
|
|
+ print('买入信号!!!!!!', stock, volume, current_price)
|
|
|
+ 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())
|
|
|
|
|
@@ -347,7 +347,7 @@ if __name__ == '__main__':
|
|
|
print('对交易回调进行订阅,订阅后可以收到交易主推,返回0表示订阅成功', subscribe_result)
|
|
|
|
|
|
scheduler = BlockingScheduler()
|
|
|
- scheduler.add_job(func=bridge, trigger='cron', day_of_week='0-4', hour='9', minute='40',
|
|
|
+ scheduler.add_job(func=bridge, trigger='cron', day_of_week='0-4', hour='10', minute='55',
|
|
|
timezone="Asia/Shanghai")
|
|
|
try:
|
|
|
scheduler.start()
|