vnpy交易學習接口(2)

#來源於github下載vnpy版本  20180413git

十一、多投資標的狀況下,該如何修改?github

 

 

十、stop和limit報單有什麼區別呢?app

 在交易時用得最多的是二類定單,第一類是市價單(Market Order),就是用市場如今的報價成交,這類定單很是簡單易懂,不須要多做解釋,但第二類的定單相對比較複雜一點,它包括二種定單,一種是限價單,一種是止損單。
       限價單和止損單都屬於掛單,也就是用市場之後可能會出現的價格成交,若是設定的價格不出現則不成交,一旦設定的價格出現,掛單就自動轉成市價單而成交。

spa

九、哪裏能夠看到成交明細?code

 

八、blog

這裏是否是寫的有問題?是否是應該小於等於?ip

 

七、最後一根bar的時候是如何中止的?it

解答:最後一根bar出來,若是產生交易信號,會存到限價單或者中止單字典中,沒有下一個bar出來,就不會交易。io

 

六、ctaBacktesting.py中的self.workingStopOrderDict和self.workingLimitOrderDict是如何來的?table

 解答:是在回測引擎ctaBacktesting.py 的 sendorder() / sendStopOrder()方法倒數第二行代碼添加進去的,即這個bar產生信號,把order信號保存進self.limitOrderDict或者self.stopOrderDict字典中。

self.limitOrderDict[orderID]=order
 或者
self.workingStopOrderDict[stopOrderID]=so

 

五、運行strategyMultiSignal.py時出錯:

Traceback (most recent call last):
  File "E:/vnpy0419/examples/CtaBacktesting/runBacktesting.py", line 42, in <module>
    engine.initStrategy(RsiSignal, d)
  File "E:\vnpy0419\vnpy\trader\app\ctaStrategy\ctaBacktesting.py", line 285, in initStrategy
    self.strategy = strategyClass(self, setting)
TypeError: __init__() takes 1 positional argument but 3 were given

解決: 暫時放棄

 

四、運行時出錯:

  File "E:\vnpy0419\vnpy\trader\app\ctaStrategy\ctaBacktesting.py", line 304, in crossLimitOrder
    for orderID, order in self.workingLimitOrderDict.items():
RuntimeError: OrderedDict mutated during iteration

修改成:

        workingLimitOrderDictCopy=self.workingLimitOrderDict.copy()
        for orderID, order in workingLimitOrderDictCopy.items():

 

三、運行strategyAtrRsi策略是出錯

  File "E:\vnpy0419\vnpy\trader\app\ctaStrategy\ctaBacktesting.py", line 566, in cancelAll
    for stopOrderID in self.workingStopOrderDict.keys():
RuntimeError: dictionary changed size during iteration

修改:

原來:for stopOrderID in self.workingStopOrderDict.keys():
修改成: for stopOrderID in list(self.workingStopOrderDict.keys()):      

 

二、運行runBacktesting.py出錯

  File "E:\vnpy0419\vnpy\trader\app\ctaStrategy\ctaBacktesting.py", line 839, in <lambda>
    tradeTimeIndex = map(lambda i: tradeTimeIndex[i], xindex)
TypeError: 'map' object is not subscriptable

修改成:tradeTimeIndex=list(map(lambda i : tradeTimeIndex[i], xindex))

 

一、運行runBacktesting.py出錯。

  File "E:\vnpy0419\vnpy\trader\app\ctaStrategy\ctaBacktesting.py", line 374, in crossStopOrder
    for stopOrderID, so in self.workingStopOrderDict.items():
RuntimeError: dictionary changed size during iteration

解決: 修改成

        # 遍歷中止單字典中的全部中止單
        workingStopOrderDictCopy=self.workingStopOrderDict.copy()
        for stopOrderID, so in workingStopOrderDictCopy.items():
相關文章
相關標籤/搜索