Skip to content

Commit

Permalink
Convert testdata files to pickle
Browse files Browse the repository at this point in the history
Needed for upgrade to Pandas 2 since JobLib deserialization breaks in Pandas 2 for Pandas 1 dataframes.
  • Loading branch information
edtechre committed Dec 15, 2023
1 parent eb68641 commit c194b47
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 22 deletions.
5 changes: 2 additions & 3 deletions tests/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
(see LICENSE for details).
"""

import joblib
import numpy as np
import os
import pandas as pd
Expand Down Expand Up @@ -51,8 +50,8 @@ def predict(self, _):

@pytest.fixture()
def data_source_df():
return joblib.load(
os.path.join(os.path.dirname(__file__), "testdata/daily_1.joblib")
return pd.read_pickle(
os.path.join(os.path.dirname(__file__), "testdata/daily_1.pkl")
)


Expand Down
19 changes: 8 additions & 11 deletions tests/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"""

import akshare
import joblib
import os
import pandas as pd
import pytest
Expand Down Expand Up @@ -48,17 +47,17 @@

@pytest.fixture()
def alpaca_df():
df = joblib.load(
os.path.join(os.path.dirname(__file__), "testdata/daily_1.joblib")
df = pd.read_pickle(
os.path.join(os.path.dirname(__file__), "testdata/daily_1.pkl")
)
df["date"] = df["date"].dt.tz_localize("US/Eastern")
return df.assign(vwap=1)[ALPACA_COLS]


@pytest.fixture()
def alpaca_crypto_df():
df = joblib.load(
os.path.join(os.path.dirname(__file__), "testdata/daily_1.joblib")
df = pd.read_pickle(
os.path.join(os.path.dirname(__file__), "testdata/daily_1.pkl")
)
df["date"] = df["date"].dt.tz_localize("US/Eastern")
return df.assign(vwap=1, trade_count=1)[ALPACA_CRYPTO_COLS]
Expand All @@ -76,17 +75,15 @@ def crypto_bars_df(alpaca_crypto_df):

@pytest.fixture()
def yfinance_df():
return joblib.load(
os.path.join(os.path.dirname(__file__), "testdata/yfinance.joblib")
return pd.read_pickle(
os.path.join(os.path.dirname(__file__), "testdata/yfinance.pkl")
)


@pytest.fixture()
def yfinance_single_df():
return joblib.load(
os.path.join(
os.path.dirname(__file__), "testdata/yfinance_single.joblib"
)
return pd.read_pickle(
os.path.join(os.path.dirname(__file__), "testdata/yfinance_single.pkl")
)


Expand Down
9 changes: 4 additions & 5 deletions tests/test_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
(see LICENSE for details).
"""

import joblib
import math
import numpy as np
import os
Expand Down Expand Up @@ -68,15 +67,15 @@ def calc_bootstrap(request):

@pytest.fixture()
def portfolio_df():
return joblib.load(
os.path.join(os.path.dirname(__file__), "testdata/portfolio_df.joblib")
return pd.read_pickle(
os.path.join(os.path.dirname(__file__), "testdata/portfolio_df.pkl")
)


@pytest.fixture()
def trades_df():
return joblib.load(
os.path.join(os.path.dirname(__file__), "testdata/trades_df.joblib")
return pd.read_pickle(
os.path.join(os.path.dirname(__file__), "testdata/trades_df.pkl")
)


Expand Down
5 changes: 2 additions & 3 deletions tests/test_strategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
(see LICENSE for details).
"""

import joblib
import numpy as np
import os
import pandas as pd
Expand Down Expand Up @@ -1129,8 +1128,8 @@ class FakeDataSource(DataSource):
def _fetch_data(
self, symbols, start_date, end_date, timeframe, adjustment
):
return joblib.load(
os.path.join(os.path.dirname(__file__), "testdata/daily_1.joblib")
return pd.read_pickle(
os.path.join(os.path.dirname(__file__), "testdata/daily_1.pkl")
)


Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit c194b47

Please sign in to comment.