From c194b47c8e47fdc66f16c444da764a9a59ed981e Mon Sep 17 00:00:00 2001 From: edtechre Date: Thu, 14 Dec 2023 21:07:47 -0800 Subject: [PATCH] Convert testdata files to pickle Needed for upgrade to Pandas 2 since JobLib deserialization breaks in Pandas 2 for Pandas 1 dataframes. --- tests/fixtures.py | 5 ++--- tests/test_data.py | 19 ++++++++---------- tests/test_eval.py | 9 ++++----- tests/test_strategy.py | 5 ++--- .../testdata/{daily_1.joblib => daily_1.pkl} | Bin 135227 -> 134607 bytes .../{portfolio_df.joblib => portfolio_df.pkl} | Bin 81982 -> 81655 bytes .../{trades_df.joblib => trades_df.pkl} | Bin 31423 -> 30817 bytes .../{yfinance.joblib => yfinance.pkl} | Bin 103482 -> 102723 bytes ...ance_single.joblib => yfinance_single.pkl} | Bin 29708 -> 29373 bytes 9 files changed, 16 insertions(+), 22 deletions(-) rename tests/testdata/{daily_1.joblib => daily_1.pkl} (97%) rename tests/testdata/{portfolio_df.joblib => portfolio_df.pkl} (97%) rename tests/testdata/{trades_df.joblib => trades_df.pkl} (85%) rename tests/testdata/{yfinance.joblib => yfinance.pkl} (90%) rename tests/testdata/{yfinance_single.joblib => yfinance_single.pkl} (93%) diff --git a/tests/fixtures.py b/tests/fixtures.py index 6077be6..359cd03 100644 --- a/tests/fixtures.py +++ b/tests/fixtures.py @@ -6,7 +6,6 @@ (see LICENSE for details). """ -import joblib import numpy as np import os import pandas as pd @@ -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") ) diff --git a/tests/test_data.py b/tests/test_data.py index f0c02b8..bb38514 100644 --- a/tests/test_data.py +++ b/tests/test_data.py @@ -7,7 +7,6 @@ """ import akshare -import joblib import os import pandas as pd import pytest @@ -48,8 +47,8 @@ @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] @@ -57,8 +56,8 @@ def alpaca_df(): @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] @@ -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") ) diff --git a/tests/test_eval.py b/tests/test_eval.py index b76a74f..ee7f8aa 100644 --- a/tests/test_eval.py +++ b/tests/test_eval.py @@ -6,7 +6,6 @@ (see LICENSE for details). """ -import joblib import math import numpy as np import os @@ -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") ) diff --git a/tests/test_strategy.py b/tests/test_strategy.py index fa40ec7..ed6df16 100644 --- a/tests/test_strategy.py +++ b/tests/test_strategy.py @@ -6,7 +6,6 @@ (see LICENSE for details). """ -import joblib import numpy as np import os import pandas as pd @@ -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") ) diff --git a/tests/testdata/daily_1.joblib b/tests/testdata/daily_1.pkl similarity index 97% rename from tests/testdata/daily_1.joblib rename to tests/testdata/daily_1.pkl index a09b346d98585eba6d37940930995a96edfffa55..d4b833346e5a9c38812dd79e267613a3ca0a7532 100644 GIT binary patch delta 4656 zcmeI0F>ljA6vuOkohB*>gbE{yP}F)rr7S2?E2XAV1zZ}Urb`DDoaB-VO6?ASi(1;V(0*T0S3s0YWJ5bmQ9vhPP5xEY}@DqJ6Ezv#WFix+o^QH1G>QG%kE~U>h`yFxvVtw-4S&bSpl*oytZc?^mL!tO8vqd%ODe8|+d*hEIvzr~sQU)oiO( zc4{?Za|!Kmw2C4ko{#n8v5wxZCO^NNJcxid($foAo#-&M!FS#Un$-?9|7eVs{O<#l zK;XX`p!8L&?g8Bt2{o&)kU^e?voVgCtJbiI%RT9Ywc8KMDASBmRd z0il1n4fwD6Pqf*GcQOf4L0^`(J0uR&jF&sFZM} zsLn(~{n=T_n1$#6k4~Nc>;EQ_Jc)3=K{I~u3tD&EOucJX$rBDT1{@41RikSF{evJR zI8M02qW3c}JeX327%k`X`FlTkOfERfcb&imu?GRBSZ!kR8*S7nuvpW23{0&wtqy+| z?^#WbQ-Cccjq0P)>C;ZXRkoTS>SKy&@PxdxFHnf><1xB;0-|U3_zP}57`4D2( z1H}>lCng0}hE_E}&I)lgujC4uTvmK8Lt+mkoyUZ(^M!{xpUXj=?2^lG$Qp^+AtNt{ zGH)0JMeI&h;vEz<+l+zu93&i=`_;KgA2nT~em1y6P;_?>+_+`4yew-kGm66J$hJM^ z?dkewcsaYGDo`~uLcxRv;rjDJPx<)x`~!^7bQMjXH+Dhd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62hsN%MpU6&Pu^nlM^}v67sSy@2s*wR%6AjQA$sqA;Pg*CAh0 zM4qD~pTK1NJq&?K8!#0IHuAPi2MWpv2k~GVQ}qe50t`i^GQiJV$AW2PjC+COVLsB& zv7ttXGcoTb#y-qq3UgYyyB_@(x89ecaCde!99=~eQ`5$ONlz-h>(hdtpAXY(e2H33 zR%0buBn!Qd)568eXF9^i|4&Q)i61}RiEOeHAIdX=a%rM#CxxVTSd(dFrFVE!*gOG< CleY>0 diff --git a/tests/testdata/trades_df.joblib b/tests/testdata/trades_df.pkl similarity index 85% rename from tests/testdata/trades_df.joblib rename to tests/testdata/trades_df.pkl index 66cf992577889a80a7ce0952f572f66456361f6b..6a571b98c00e800a07b9e5bce3bd64a1695f3e0f 100644 GIT binary patch delta 2158 zcmZWq&rcIU6z-NSMySRZF$5Ar3?ZDbUWg*`_n|-uJ!ln>UyDVo}L_$#<)5uN(NiYM>$|uE`5tt?c{dfsUNazFM&=>b=@j^N!_Y*WOtND*A3M zjvn4GPG&O4g=}%sR)MNSgQ>+^@~YQsbp{L7w(lmJMGx9w6s>V*rpQ2`J)*oWul+XjAngyW^Xw5z7h|K;AH7eVw{L{ z5&Dh`tHsH?N~|UKWTsehY$xy7#6PXNDQ2lRF*nrNm)cx-_(IJ~yV>@3l&H&GSG4^= ziJkaYKeN{b;vIc5XGEL5>t4^MbbIu!H5~Kpe*B*$JtaHJ!XXl zN}m|y^0Sg@BV)~c#4zT{VGIf}D@+~-h5&JM#OQ{2X+d)af{Za|Eu&}@>LTvnB=9_x zfgrjiglBoHD_?j}1C(q}}>5*lL$cp)Vi1TakD7#xb&fb%9I z2CT7@CUgl+=i_szVJgJUn2g9srfvBuEJaL?*(i;{I*mi0FS9GcVbHt=43HrvvvEBV zVH570P?G_h7(jrMLef9mq`P1fDq=cfwqhw-)A_VYS_=v=Mis|N{|NX|SQZ88h)qcz zR|AWm6>D0L>zNNN-s86_o<5*?Bs?O~OkX6*|0M6~IVhH*->-_HFLRH)n%md&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Niy#oT)ai9X@S3KBoKYBFwY#U|oRmm#wRW9;g>!IO#0Vp>%QD z#WpR~BOc+`ju~2*4Q=#}IXSmFi^O0zIi!?Z-(WmHi0JZf->3}mI7z_ zE+`|YK;;#doL99vGYJ^^aBB98b9698H#>6yAo9g?vy)Xi1h7f~>pU!QBX=`SI2L&l z_-qbf_4dV)O;o%YOr*`=a@Gxg>ixKz-GD12usm1+OaK$Xl2QHy?2Rt&rIp@sBQ#Rv z_g8A2BtjR^Z=GimDxupQX&Lzg5X;n7V-m<%=jJjxcDyHaXk@R({+j&)@ACJrLy?Xr jQRXZMSDe_m;$g~Ee-+x>-B>uI1#qbe*<$C(9n^RM_uX}J diff --git a/tests/testdata/yfinance_single.joblib b/tests/testdata/yfinance_single.pkl similarity index 93% rename from tests/testdata/yfinance_single.joblib rename to tests/testdata/yfinance_single.pkl index c09bbbc25473e5e2d73d0ca3b33a3bc1b7e9b4db..df82960692e7ae70eb9c0605ce9f700477b9fd6b 100644 GIT binary patch delta 554 zcmZvZL2DE-6vsF1&K9XUw&Y>&>ErDuRn z72Pn2dC`qiBX!D>0<0gFX&#H+M20-c#4b3n%V{~xM_rL=*~M1sSb$v&2Ra+_axjn@ zMV+H*(5UNpk4%FluwH!&_sEQL39d(0ed=xeBJaSGJ{Z^rr?#%1r*ntcszr6Sb2Ra1 z9zVAxeh<{Lor~9C{Jv6j=)7tNLGa`^R=v=M0ZvJ6sV-H9>I(H}i;_x@zV7?WTkNLw z9;cCfgOK~svCW7X2KK^&e8&RI}WYR~jg~EpE1-N0m5e{5L!-hdUa|=qVF5cGj1d7|d$!lb=zRMHQ zwQPqg&o14A|pz@ZQXH@ z&kthb)6ub7?Y=7&EB&!DrFVch=_iAy1CY@Z?qs|mL@tp@a#ay>JTgV5$qc!cliONpG#+zOk4{4_ynt zhRL$oMGHlU|ASm<^FOfZxAoZ;sU60~UfImWDeQ4#3bthu$$EfI&kds>HY1spiYoa; zK$!_jsm;o!Zh96rLm9hSAhRA#0FDL|wFWugR)4MNlejCY!As zSI)JTS-)0>hLr_&4%A=+O*RO6VPjek z>^}Ck*?CQZXo-3uW*4+7#EaJEbdis1S2BiAJsLZhUBnTaFdE(G8GBgib#!myNiuL3 zML4n@{Fk=me!7Rk5pZt#)H#vNrK`s5{8`1p=~K!7S1%RjzA=u5>fKfWU4pwW=^FuN VTn+cZ|J6jyXuuy)Y^E;*{Wm0mI