forked from idanya/algo-trader
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Idan Yael
committed
Oct 1, 2021
1 parent
749a056
commit 96f5428
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) |