通达信自动交易股票下单程序,外挂软件不可信,网上有很多通达信自动交易插件和同花顺外挂软件可以实现自动交易,提交订单等功能,但是这些通过外部插件来操作股票账户的工具,都是使用技术手段,如窗口控件操作、DLL绑定甚至内存注入等方式来操作你的股票账户
它们的使用往往伴随着巨大的风险,例如,窗口控件操作类插件可能在执行时出错,导致输入不正确的股票代码或金额,造成资金损失,还存在账户被盗取、非法操控访问以及券商封禁账户等潜在风险,像内存注入类的操作可能触及严重的法律问题,涉及刑事责任,各位务必谨慎,不仅要关注其合法性和合规性,还要充分了解并采取适当的措施来降低潜在的风险。
其实现在券商有现成的接口,像我在用的国金证券就有现成的接口,个人账户入金1万就可以开,几乎无门槛,而且量化接口支持股票、基金、可转债、期权、期货等
自带了很多策略可以参考,包含多因子、日内回转、机器学习、双均线等不同类型的策略
很多操作只需要一行代码:
- #获取实时行情
- get_full_tick(['股票代码1','股票代码2'])
- #下载历史数据,支持tick级分笔数据,最早可以获取到中国股市开市以来的所有数据
- download_history_data('股票代码','k线类型','开始时间','结束时间')
开户渠道选的好,费用也是大大降低,配合比较好的交易策略,通过自动化程序化交易,即能避免人工操作时的情绪波动和操作失误,还能够实现高效的交易,在市场中获得竞争优势,尽量拉平与大户的差距。
比如费率方面的优势,大部分做量化交易的肯定交易频率会很高,找不到好的客户经理,拿着市面上常见的万2.5费率,如果像我的交易比较频繁,主要集中在可转债和场内ETF上,一天几个来回交易费用得差大几百几千的
费率低意味着交易机会多,拿可转债来说,我的是万0.4免5,以113050南银转债来说,做网格交易一天可以有几百次机会,挂买一成交后立即挂卖一出手,简直是捡钱一样,现在靠程序交易的人还少,我写的策略也极简单,就是买进成交后,加一点点利润价立即卖出
而如果按照市面上常见的万3或万2不免5,算上交易成本,加上是人工操作,就干脆不要想这种这交易方式,根本没机会出手,直接就被套住了
有了自动交易这把利器,再加python强大的支持库,能发挥的想像空间实在太大了,闲置资金利用,高频网格(我最常用的),机器学习,人工智能,策略选股等等,目前还是早期,程序交易一片蓝海,机会很多,等程序员大军加入进来,就很难靠简单的程序实现盈利了
机会是有,但到时候用程序交易的人多了,开户的门槛提高,策略的门槛提高,任何一个想法都得靠复杂的程序才能实现,都是程序和程序的碰撞,你想要盈利,就得比别人有更高级更好更复杂的代码来实现,
对股票量化交易,股票自动交易感兴趣的朋友可以留言或私信与我交流,需要的话开户渠道我也会无偿提供
以下是一段机器学习回测示例参考:
- #coding:gbk
- #!/usr/bin/python
- """
- 回测模型示例(非实盘交易策略)
- #单股机器学习模型,在主图下直接运行即可
- #模型中以过去15个交易日数据生成特征变量以预测5个交易日后的涨跌,
- #特征变量我们选取了平均收盘价,平均成交量,平均最高价,平均最低价,总收益,收盘价的标准差
- #训练结束后,回测过程中在每个星期一预测本周五的涨跌,以此为据开仓
- """
- import pandas as pd
- import numpy as np
- import time
- from datetime import *
- from sklearn import svm
- import traceback
- def init(ContextInfo):
- ContextInfo.stock = ContextInfo.stockcode + '.' + ContextInfo.market
- ContextInfo.set_universe([ContextInfo.stock])
- ContextInfo.holding = 0
- ContextInfo.days = 0
- ContextInfo.money = ContextInfo.capital
- ContextInfo.accountid = "testS"
-
- def handlebar(ContextInfo):
- buy_condition = False
- sell_condition = False
- d = ContextInfo.barpos
- if ContextInfo.days == 0:
- #用20160101到20170101一年间的数据生成训练集
- df = ContextInfo.get_market_data(['open','high','low','close','volume'],stock_code=[ContextInfo.stock],start_time='20160101',end_time='20170101',dividend_type='front')
- df = df.sort_index()
- days = df.index.values
- days_close = df['close'].values
- print('start training SVM')
- x_all = []
- y_all = []
- for i in range(14, len(days) - 5):
- start_day = days[i - 14]
- end_day = days[i]
- data = ContextInfo.get_market_data(['open','high','low','close','volume'],stock_code=[ContextInfo.stock],end_time=end_day,count=15,skip_paused=False,dividend_type='front')
- data = data.sort_index()
- open = data['open'].values
- close = data['close'].values
- max = data['high'].values
- min = data['low'].values
- volume = data['volume'].values
- close_mean = close[-1] / np.mean(close)
- volume_mean = volume[-1] / np.mean(volume)
- max_mean = max[-1] / np.mean(max)
- min_mean = min[-1] / np.mean(min)
- vol = volume[-1]
- return_now = close[-1] / close[0]
- std = np.std(np.array(close), axis = 0)
- #features用于存放因子
- features = [close_mean, volume_mean, max_mean, min_mean, vol, return_now, std] #计算出的6个因子作为特征
- x_all.append(features)
-
- for i in range(len(days_close) - 19):
- if days_close[i+19] > days_close[i+14]:
- label = 1
- else:
- label = 0
- y_all.append(label)
- x_train = x_all[:-1]
- y_train = y_all[:-1]
-
- ContextInfo.clf = svm.SVC(C=1.0, kernel='rbf', degree=3, gamma='auto', coef0=0.0, shrinking=True, probability=False,tol=0.001, cache_size=200, verbose=False, max_iter=-1, decision_function_shape='ovr', random_state=None)
- try:
- ContextInfo.clf.fit(x_train, y_train)
- except:
- e = traceback.format_exc()
- print(('value error, bar:', e))
- print('training finish!')
-
- timetag = ContextInfo.get_bar_timetag(d)
- timetag_start = ContextInfo.get_bar_timetag(d-15)
- timetag_end = ContextInfo.get_bar_timetag(d-1) #过去15个交易日的起止时间
-
- today = timetag_to_datetime(timetag, '%Y%m%d')
- start_date = timetag_to_datetime(timetag_start, '%Y%m%d')
- end_date = timetag_to_datetime(timetag_end, '%Y%m%d')
- weekday = datetime.strptime(today, '%Y%m%d').isoweekday()
- open_today = ContextInfo.get_market_data(['open'],stock_code=[ContextInfo.stock],skip_paused=False,dividend_type='front')
- close_today = ContextInfo.get_market_data(['close'],stock_code=[ContextInfo.stock],skip_paused=False,dividend_type='front')
- #print ContextInfo.holding
- #print weekday
- if ContextInfo.holding == 0 and weekday == 1: #每个星期一判断是否开仓
- data = ContextInfo.get_market_data(['open','high','low','close','volume'],stock_code=[ContextInfo.stock],end_time=end_date,count=15,skip_paused=False, dividend_type='front')
- data = data.sort_index()
- close = data['close'].values
- max = data['high'].values
- min = data['low'].values
- volume = data['volume'].values
- close_mean = close[-1] / np.mean(close)
- volume_mean = volume[-1] / np.mean(volume)
- max_mean = max[-1] / np.mean(max)
- min_mean = min[-1] / np.mean(min)
- vol = volume[-1]
- return_now = close[-1] / close[0]
- std = np.std(np.array(close), axis = 0)
-
- features = [close_mean, volume_mean, max_mean, min_mean, vol, return_now, std]
- features = np.array(features).reshape(1, -1)
- try:
- prediction = ContextInfo.clf.predict(features)[0]
- if prediction == 1:
- ContextInfo.holding = int(ContextInfo.money*0.95/(open_today))/100
- order_shares(ContextInfo.stock,ContextInfo.holding*100,'fix',open_today,ContextInfo,ContextInfo.accountid)
- ContextInfo.buyprice = open_today
- buy_condition = True
- print(today)
- print('open long position to 0.95')
- except :
- print(('predict error occur,bar:', d))
- elif ContextInfo.holding > 0 and close_today/ContextInfo.buyprice >= 1.1: #每个交易日判断止盈止损
- order_shares(ContextInfo.stock,-ContextInfo.holding*100,'fix',close_today,ContextInfo,ContextInfo.accountid)
- ContextInfo.holding = 0
- sell_condition = True
- print(today)
- print('reach profit stop limit, close position')
- elif ContextInfo.holding > 0 and close_today/ContextInfo.buyprice < 0.98 and weekday == 5:
- order_shares(ContextInfo.stock,-ContextInfo.holding*100,'fix',close_today,ContextInfo,ContextInfo.accountid)
- ContextInfo.holding = 0
- sell_condition = True
- print(today)
- print('reach lose stop limit, close position')
- ContextInfo.days += 1
-
- ContextInfo.paint('do_buy', int(buy_condition), -1, 0)
- ContextInfo.paint('do_sell', int(sell_condition), -1, 0)
-
-
对股票量化交易,股票自动交易感兴趣的朋友可以留言或私信与我交流,需要的话开户渠道我也会无偿提供
------