|
@@ -76,7 +76,7 @@ def ma_judge(data, stock_list, results):
|
|
|
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)
|
|
|
+ # print(i, current_price, open_price, MA5, MA10, MA20, MA5_1)
|
|
|
if (current_price > open_price) & (current_price > MA5) & (MA5 > MA5_1) & (current_price < MA5 * 1.03) & (
|
|
|
MA20 < MA10):
|
|
|
if his_vol(i, -1) > his_vol(i, -2):
|
|
@@ -156,7 +156,7 @@ def buy_trader(data):
|
|
|
industry_list.append(key2['industry_name'])
|
|
|
industry_list = pd.value_counts(industry_list)
|
|
|
# 最热集中的n个板块
|
|
|
- max_industry_list = list(industry_list[0:3].index)
|
|
|
+ max_industry_list = list(industry_list[0:2].index)
|
|
|
results_industry = []
|
|
|
for key, value in num_industry.items():
|
|
|
for key2 in value.values():
|
|
@@ -181,10 +181,13 @@ def buy_trader(data):
|
|
|
print(new_keep_stock)
|
|
|
|
|
|
for stock in data:
|
|
|
+ asset = xt_trader.query_stock_asset(acc)
|
|
|
+ cash = asset.cash
|
|
|
+ print(cash)
|
|
|
if stock in new_keep_stock:
|
|
|
current_price = data[stock]['lastPrice']
|
|
|
- if acc.cash > 2000:
|
|
|
- volume = int((acc.cash / 2 / current_price) // 100 * 100)
|
|
|
+ if cash > 2000:
|
|
|
+ volume = int((cash / 2 / current_price) // 100 * 100)
|
|
|
print('volume:', volume)
|
|
|
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')
|
|
@@ -293,6 +296,7 @@ if __name__ == '__main__':
|
|
|
subscribe_result = xt_trader.subscribe(acc)
|
|
|
print('对交易回调进行订阅,订阅后可以收到交易主推,返回0表示订阅成功', subscribe_result)
|
|
|
|
|
|
+
|
|
|
stocks = xtdata.get_stock_list_in_sector('沪深A股')
|
|
|
xtdata.subscribe_whole_quote(stocks, callback=trader)
|
|
|
xtdata.run()
|