forked from jesse-ai/jesse
-
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.
fix research.store_candles() + write unit test
- Loading branch information
Showing
3 changed files
with
56 additions
and
18 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
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
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,26 @@ | ||
import pytest | ||
from jesse import research | ||
|
||
|
||
def test_store_candles(): | ||
""" | ||
for now, don't actually store it in the db. But test validations, etc | ||
""" | ||
# validate that candles type must be np.ndarray | ||
with pytest.raises(TypeError): | ||
research.store_candles({}, 'Test Exchange', 'BTC-USDT') | ||
with pytest.raises(TypeError): | ||
research.store_candles([], 'Test Exchange', 'BTC-USDT') | ||
|
||
# add validation for timeframe to make sure it's `1m` | ||
with pytest.raises(ValueError): | ||
close_prices = [10, 11] | ||
np_candles = research.candles_from_close_prices(close_prices) | ||
# change the timeframe to 5 minutes | ||
np_candles[1][0] += 300_000 | ||
research.store_candles(np_candles, 'Test Exchange', 'BTC-USDT') | ||
|
||
# just make sure it doesn't raise an error | ||
close_prices = [10, 11, 12, 12, 11, 13, 14, 12, 11, 15] | ||
np_candles = research.candles_from_close_prices(close_prices) | ||
research.store_candles(np_candles, 'Test Exchange', 'BTC-USDT') |