Beispiel #1
0
class MarketDataTester(unittest.TestCase):

    def setUp(self):
        self.ticker = "YAHOO/INDEX_GSPC"
        self.ref = MarketData(self.ticker)

    def action(self):
        self.data = self.ref.get_data(self.start, self.end, self.frequency)

    def test_frequency_should_return_correct_value(self):
        assert Frequency.Month.value == "monthly"

    def test_quandl_should_return_some_data(self):
        self.start = "2013-01-01"
        self.end = "2013-12-31"
        self.frequency = Frequency.Day.value
        self.action()
        assert len(self.data.index) > 0

    def test_quandl_should_return_correct_monthly_data(self):
        self.start = "2013-01-01"
        self.end = "2013-12-31"
        self.frequency = Frequency.Month.value
        self.action()
        assert len(self.data.index) == 12
Beispiel #2
0
 def test_strategy_with_real_data(self):
     start = "2013-01-01"
     end = "2013-12-31"
     frequency = Frequency.Day.value
     ref = MarketData("YAHOO/INDEX_GSPC")
     market_data = ref.get_data(start, end, frequency)
     self.data = pandas.DataFrame(np.repeat(1, len(market_data.index)))
     self.data["Close"] = market_data["Close"].tolist()
     result = self.strategy.get_result(self.data)
Beispiel #3
0
 def setUp(self):
     pass
     start = "2013-01-01"
     end = "2013-12-31"
     frequency = Frequency.Day.value
     ref = MarketData("YAHOO/INDEX_GSPC")
     self.market_data = ref.get_data(start, end, frequency)
     self.data = pandas.DataFrame(np.repeat(1, len(self.market_data.index)))
     self.data['Close'] = self.market_data['Close'].tolist()
Beispiel #4
0
 def setUp(self):
     start = "2010-12-01"
     end = "2010-12-31"
     frequency = Frequency.Day.value
     ref = MarketData("YAHOO/INDEX_GSPC")
     self.market_data = ref.get_data(start, end, frequency)
     self.data = pandas.DataFrame(np.repeat(1, len(self.market_data.index)))
     self.data['Close'] = self.market_data['Close'].tolist()
     self.strategyList = ["MA", "MT", "SP", "BB"]
     start = time.time()
     for strategyName in self.strategyList:
         strategy = StrategyFactory.get_strategy(strategyName)
         strategy.get_result(self.data)
     print time.time() - start