量化交易”有着两层含义: 即为根据一系列交易条件,智能化辅助决策体系,将丰富的从业经验与交易条件相结合,在交易过程管理好风险控制。
【一】是从狭义上来讲,是指量化交易的内容,将交易条件转变成为程序,自动下单;
【二】是从广义上来讲,是指系统交易方法,就是一个整合的交易系统。
#from CTP.MdApi import*
from AlgoPlus.CTP.FutureAccount import get_simnow_account,FutureAccount
from AlgoPlus.CTP.FutureAccount import SIMNOW_SERVER,MD_LOCATION,TD_LOCATION
from multiprocessing import Process,Queue
from CTP.MdApi import run_bar_engine,run_tick_engine
from CTP.TradeApi import run_trade_engine
#账户配置
future_account=FutureAccount(
#server_dict={'TDServer':"180.168.146.187:10130",'MDServer':'180.168.146.187:10131'},#TEST
server_dict={'TDServer':"218.202.237.33:10102",'MDServer':'218.202.237.33:10112'},#移动
#TDServer为交易服务器,MDServer为行情服务器。服务器地址格式为"ip:port。"
reserve_server_dict={},
investor_id="**",
password="**"
app_id='simnow_client_test',
auth_code='0000000000000000'
instrument_id_list=instrument_id_list,#订阅合约列表
md_page_dir=MD_LOCATION,#MdApi流文件存储地址,默认MD_LOCATION
td_page_dir=TD_LOCATION#TraderApi流文件存储地址,默认TD_LOCATION
)
#///深度行情通知
def OnRtnDepthMarketData(self,pDepthMarketData):
last_update_time=self.bar_dict[pDepthMarketData['InstrumentID']]["UpdateTime"]
is_new_1minute=(pDepthMarketData'UpdateTime'!=last_update_time[:-2])and pDepthMarketData['UpdateTime']!=b'21:00:00'#1分钟K线条件
#is_new_5minute=is_new_1minute and int(pDepthMarketData'UpdateTime')%5==0#5分钟K线条件
#is_new_10minute=is_new_1minute and pDepthMarketData'UpdateTime'==b"0"#10分钟K线条件
#is_new_10minute=is_new_1minute and int(pDepthMarketData'UpdateTime')%15==0#15分钟K线条件
#is_new_30minute=is_new_1minute and int(pDepthMarketData'UpdateTime')%30==0#30分钟K线条件
#is_new_hour=is_new_1minute and int(pDepth