Browse Source

丰富提示信息

daniel-ali 2 years ago
parent
commit
d958b71d7e
1 changed files with 5 additions and 2 deletions
  1. 5 2
      QMT/real_time.py

+ 5 - 2
QMT/real_time.py

@@ -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())