Skip to content

Commit

Permalink
added test for IB source
Browse files Browse the repository at this point in the history
  • Loading branch information
Idan Yael committed Oct 1, 2021
1 parent 749a056 commit 96f5428
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tests/integration/test_ib_source.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from datetime import datetime, timedelta
from unittest import TestCase

from entities.timespan import TimeSpan
from pipeline.sources.ib_history import IBHistorySource
from providers.ib.interactive_brokers_connector import InteractiveBrokersConnector


class TestIBSource(TestCase):
def setUp(self) -> None:
super().setUp()
self.ib_connector = InteractiveBrokersConnector()

def tearDown(self) -> None:
super().tearDown()
self.ib_connector.kill()

def test(self):
symbol = 'AAPL'
from_time = datetime.now() - timedelta(days=30)
source = IBHistorySource(self.ib_connector, [symbol], TimeSpan.Day, from_time)

candles = list(source.read())
self.assertTrue(len(candles) > 10)

for candle in candles:
self.assertEqual(symbol, candle.symbol)
self.assertEqual(TimeSpan.Day, candle.time_span)
self.assertTrue(candle.timestamp < datetime.now())

0 comments on commit 96f5428

Please sign in to comment.