Browse Source

避免上上影线:current_price > (current_high*0.98)

Daniel 2 years ago
parent
commit
6f8b96117a
1 changed files with 4 additions and 2 deletions
  1. 4 2
      QMT/real_time.py

+ 4 - 2
QMT/real_time.py

@@ -203,8 +203,10 @@ def buy_trader(data, positions):
                               positions[x].volume > 0}
             if stock in new_keep_stock:
                 current_price = data[stock]['lastPrice']
-                if cash > 5000 and len(positions_dict) < max_pos and current_price > 9:
-                    volume = int((cash / 2 / current_price) // 100 * 100)
+                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')