模拟没问题的,但实盘不行。在文华、国贸金服等软件中,连委托单都看不见。
import pandas as pd
from tqsdk import TqApi, TqAuth, TqAccount, TqKq, TqSim
import os
attempts = 0
success = False
while attempts < 30 and not success:
try:
api = TqApi(account=TqAccount(),auth=TqAuth())
success = True
except:
attempts += 1
df_期货得分 = pd.read_csv('选股.csv')
new_symbol = list(df_期货得分['future'])[0]
new_direction = list(df_期货得分['direction'])[0]
q = api.get_quote(new_symbol)
字典 = {'BUY':q.upper_limit,'SELL':q.lower_limit}
price = 字典[new_direction]
api.insert_order(new_symbol,new_direction,'OPEN',1,price)
api.wait_update()
os._exit(0)