Skip to content

Commit 96f5428

Browse files
author
Idan Yael
committed
added test for IB source
1 parent 749a056 commit 96f5428

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

tests/integration/test_ib_source.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from datetime import datetime, timedelta
2+
from unittest import TestCase
3+
4+
from entities.timespan import TimeSpan
5+
from pipeline.sources.ib_history import IBHistorySource
6+
from providers.ib.interactive_brokers_connector import InteractiveBrokersConnector
7+
8+
9+
class TestIBSource(TestCase):
10+
def setUp(self) -> None:
11+
super().setUp()
12+
self.ib_connector = InteractiveBrokersConnector()
13+
14+
def tearDown(self) -> None:
15+
super().tearDown()
16+
self.ib_connector.kill()
17+
18+
def test(self):
19+
symbol = 'AAPL'
20+
from_time = datetime.now() - timedelta(days=30)
21+
source = IBHistorySource(self.ib_connector, [symbol], TimeSpan.Day, from_time)
22+
23+
candles = list(source.read())
24+
self.assertTrue(len(candles) > 10)
25+
26+
for candle in candles:
27+
self.assertEqual(symbol, candle.symbol)
28+
self.assertEqual(TimeSpan.Day, candle.time_span)
29+
self.assertTrue(candle.timestamp < datetime.now())

0 commit comments

Comments
 (0)