第一次调用QAStrategy的例子,出现异常,请求帮助
发布于 4 个月前 作者 sillyemperor 271 次浏览 来自 问答

代码如下

from QAStrategy import QAStrategyCTABase
import QUANTAXIS as QA
import pprint
class CCI(QAStrategyCTABase):
    def on_bar(self, bar):
        res = self.cci()
        if res.CCI[-1] < -100:
             print('LONG')
            if self.positions and self.positions.volume_long == 0:
                self.send_order('BUY', 'OPEN', price=bar['close'], volume=1)
            if self.positions and self.positions.volume_short > 0:
                self.send_order('SELL', 'CLOSE', price=bar['close'], volume=1)
        elif res.CCI[-1] > 100:
             print('SHORT')
            if self.positions and self.positions.volume_short == 0:
                self.send_order('SELL', 'OPEN', price=bar['close'], volume=1)
            if self.positions and self.positions.volume_long > 0:
                self.send_order('BUY', 'CLOSE', price=bar['close'], volume=1)
				
    def cci(self,):
        return QA.QA_indicator_CCI(self.market_data, 61)

    def risk_check(self):
        pass

strategy =CCI(code='000001', frequence='1min',strategy_id='a3916de0-bd28-4b9c-bea1-94d91f1744ac', start='2020-01-01', end='2020-02-01')
strategy.debug()
strategy.run_backtest()

异常信息如下:

图片.png

上一次遇到这个问题,我发现是没有下载分组数据导致。下载完成之后再次运行,又出现了这个错误,还请大家帮忙看看。谢谢!

2 回复

换个id 你这个strategyid之前跑过期货

QAACCOUNT: THIS ACCOUNT DOESNOT HAVE ANY TRADE,这个例子不完整吧,我也遇到了

回到顶部