无限易量化策略模板 极简 策略开发

无限易极简策略模板,仅输出行情最新价。

# encoding: UTF-8

"""
作者:Leo
微信:470770753
"""

from __future__ import division
from ctaBase import *
from ctaTemplate import *

########################################################################
class strategyDEMO(CtaTemplate):
    """
    极简策略模板
    仅输出行情最新价
    """
    varList=[]
    paramList=[]
    paramMap={}
    varMap={}
    # ----------------------------------------------------------------------
    def __init__(self, ctaEngine=None, setting={}):
        super(strategyDEMO, self).__init__(ctaEngine, setting)
        pass

    # ----------------------------------------------------------------------
    def onTick(self, tick):
        """收到行情TICK推送"""
        super(strategyDEMO, self).onTick(tick)
        self.output(tick.lastPrice)

    #----------------------------------------------------------------------
    def onTrade(self, trade):
        '''交易日志'''
        super(strategyDEMO, self).onTrade(trade, log=True)
        pass
        

    #----------------------------------------------------------------------
    def onOrderCancel(self, order):
        """收到委托变化推送"""
        pass

    #----------------------------------------------------------------------
    def onOrderTrade(self, order):
        """收到委托变化推送"""
        pass

    #----------------------------------------------------------------------
    def onStart(self):
        """启动策略"""
        super(strategyDEMO, self).onStart()

用法:将代码拷贝到文件名为“strategyDEMO.py”的文件中,然后直接将该文件“strategyDEMO.py”放到无限易策略目录下即可使用。

你可能感兴趣的:(python)