Пример #1
0
 def __init__(self, feed, brk, instrument, vwapWindowSize, buyThreshold,
              sellThreshold):
     super(VWAPMomentum, self).__init__(feed, brk)
     self.__instrument = instrument
     self.__vwap = vwap.VWAP(feed[instrument], vwapWindowSize)
     self.__buyThreshold = buyThreshold
     self.__sellThreshold = sellThreshold
Пример #2
0
 def testPeriod1_ClosingPrice(self):
     barFeed = self.__getFeed()
     bars = barFeed[VWAPTestCase.Instrument]
     vwap_ = vwap.VWAP(bars, 1)
     barFeed.loadAll()
     for i in xrange(len(bars)):
         self.assertEqual(round(bars[i].getClose(), 5), round(vwap_[i], 5))
Пример #3
0
 def testPeriod2_TypicalPrice(self):
     barFeed = self.__getFeed()
     bars = barFeed[VWAPTestCase.Instrument]
     vwap_ = vwap.VWAP(bars, 2, True)
     barFeed.loadAll()
     self.assertEqual(vwap_[0], None)
     for i in xrange(1, len(vwap_)):
         self.assertNotEqual(vwap_[i], None)
Пример #4
0
    def testBounded(self):
        barFeed = self.__getFeed()
        bars = barFeed[VWAPTestCase.Instrument]
        vwap_ = vwap.VWAP(bars, 50, True, 2)
        barFeed.loadAll()

        outputValues = [14.605005665747331, 14.605416923506045]
        for i in xrange(2):
            self.assertEqual(round(vwap_[i], 4), round(outputValues[i], 4))
Пример #5
0
 def testPeriod50_ClosingPrice(self):
     barFeed = self.__getFeed()
     bars = barFeed[VWAPTestCase.Instrument]
     vwap_ = vwap.VWAP(bars, 50)
     barFeed.loadAll()
     for i in xrange(49):
         self.assertEqual(vwap_[i], None)
     for i in xrange(49, len(vwap_)):
         self.assertNotEqual(vwap_[i], None)
Пример #6
0
 def __init__(self, feed, instrument, vwapWindowSize, threshold):
     super(VWAPMomentum, self).__init__(feed)
     self.__instrument = instrument
     self.__vwap = vwap.VWAP(feed[instrument], vwapWindowSize)
     self.__threshold = threshold