Explorar el Código

Merge remote-tracking branch 'origin/master'

Daniel hace 2 años
padre
commit
44551a3a52
Se han modificado 2 ficheros con 5 adiciones y 4 borrados
  1. 2 0
      QMT/download_data_whole.py
  2. 3 4
      QMT/real_time.py

+ 2 - 0
QMT/download_data_whole.py

@@ -64,6 +64,8 @@ def download_data(stock_list):
     pool.close()
     pool.join()
 
+    print(f'今日数据下载完毕 {dt.now()}')
+
 
 
 if __name__ == '__main__':

+ 3 - 4
QMT/real_time.py

@@ -73,7 +73,7 @@ def ma_judge(data, stock_list, results):
     print('这个ma_judge的PID为:', os.getpid())
     for stock in data:
         i = stock.replace('XSHG', 'SH').replace('XSHE', 'SZ')
-        current_price, open_price = data[i]['lastPrice'], data[i]['open_front']
+        current_price, open_price = data[i]['lastPrice'], data[i]['open']
         MA5, MA10, MA20 = ma(i, 5, data), ma(i, 10, data), ma(i, 20, data)
         MA5_1 = ma_1(i, 5)
         # print(i, current_price, open_price, MA5, MA10, MA20, MA5_1)
@@ -93,11 +93,11 @@ def sell_trader(data, positions_dict):
 
     for stock, volume in positions_dict.items():
         if stock in data:
-            print('持仓', stock, volume)
             current_price = data[stock]['lastPrice']
             open_price = data[stock]['open']
             MA5 = ma(stock, 5, data)
             MA5_1 = ma_1(stock, 5)
+            print(f'{stock},持仓量为{volume}当前价:{current_price},MA5:{MA5},昨日MA5:{MA5_1},开始判断:')
             if current_price < MA5 or MA5 < MA5_1 or current_price > MA5 * 1.07:
                 print('卖出信号!!!!!!', stock, current_price)
                 order_id = xt_trader.order_stock(acc, stock, xtconstant.STOCK_SELL, volume,
@@ -187,8 +187,7 @@ def buy_trader(data, positions):
             if cash > 2000 and len(positions) < 12:
                 if stock in new_keep_stock:
                     current_price = data[stock]['lastPrice']
-                    volume = int((cash / 3 / current_price) // 100 * 100)
-                    print('volume:', volume)
+                    volume = int((cash / 2 / 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)