-
-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added tests, replaced blosc with pyarrow
- Loading branch information
Showing
6 changed files
with
96 additions
and
14 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
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 |
---|---|---|
@@ -1,21 +1,24 @@ | ||
import pytest | ||
import pandas | ||
import pandas as pd | ||
|
||
from findatapy.timeseries import Filter | ||
|
||
def test_filtering_by_dates(): | ||
|
||
filter = Filter() | ||
|
||
# filter S&P500 between specific working days | ||
start_date = '01 Oct 2008' | ||
finish_date = '29 Oct 2008' | ||
|
||
# read CSV from disk, and make sure to parse dates | ||
df = pandas.read_csv("S&P500.csv", parse_dates=['Date'], index_col=['Date']) | ||
df = pd.read_csv("S&P500.csv", parse_dates=['Date'], index_col=['Date']) | ||
df = filter.filter_time_series_by_date(start_date=start_date, finish_date=finish_date, data_frame=df) | ||
|
||
assert df.index[0] == pandas.to_datetime(start_date) | ||
assert df.index[-1]== pandas.to_datetime(finish_date) | ||
assert df.index[0] == pd.to_datetime(start_date) | ||
assert df.index[-1]== pd.to_datetime(finish_date) | ||
|
||
if __name__ == '__main__': | ||
pytest.main() | ||
pytest.main() | ||
|
||
# test_filtering_by_dates() |
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,33 @@ | ||
import pytest | ||
import pandas as pd | ||
|
||
from findatapy.util.dataconstants import DataConstants | ||
|
||
data_constants = DataConstants() | ||
|
||
redis_server = data_constants.db_cache_server | ||
redis_port = data_constants.db_cache_port | ||
|
||
def test_redis_caching(): | ||
# Note: you need to install Redis in order for this to work! | ||
|
||
# read CSV from disk, and make sure to parse dates | ||
df = pd.read_csv("S&P500.csv", parse_dates=['Date'], index_col=['Date']) | ||
df.index = pd.to_datetime(df.index) | ||
|
||
from findatapy.market.ioengine import IOEngine | ||
|
||
io = IOEngine() | ||
|
||
# Write DataFrame to Redis (using pyarrow format) | ||
io.write_time_series_cache_to_disk('test_key', df, engine='redis', db_server=redis_server, db_port=redis_port) | ||
|
||
# Read back DataFrame from Redis (using pyarrow format) | ||
df_out = io.read_time_series_cache_from_disk('test_key', engine='redis', db_server=redis_server, db_port=redis_port) | ||
|
||
pd.testing.assert_frame_equal(df, df_out) | ||
|
||
if __name__ == '__main__': | ||
pytest.main() | ||
|
||
# test_redis_caching() |
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,22 @@ | ||
import pytest | ||
import pandas as pd | ||
|
||
from findatapy.market import Market, MarketDataGenerator, MarketDataRequest | ||
from findatapy.util.dataconstants import DataConstants | ||
|
||
market = Market(market_data_generator=MarketDataGenerator()) | ||
|
||
data_constants = DataConstants() | ||
quandl_api_key = data_constants.quandl_api_key | ||
|
||
def test_quandl_download(): | ||
md_request = MarketDataRequest(start_date='month', category='fx', data_source='quandl', tickers=['AUDJPY'], | ||
quandl_api_key=quandl_api_key) | ||
|
||
df = market.fetch_market(md_request) | ||
|
||
assert df is not None | ||
|
||
if __name__ == '__main__': | ||
pytest.main() | ||
|