Skip to content

Commit

Permalink
fixed bug that blocked old pandas (<=1.4.0)
Browse files Browse the repository at this point in the history
  • Loading branch information
enzbus committed Sep 2, 2023
1 parent 8fa6038 commit 7a58422
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,12 @@ jobs:

# rationale: we test against an environment which had
# current packages as of ~ Q4 2022 for python 3.10
# and ~ Q4 2021 for python 3.9 (with the exception of pandas,
# for which we use a mid-2022 package).
# and ~ Q4 2021 for python 3.9
# we only install the base packages here (pip below figures out the others)

- name: If running on python 3.9 install some old dependencies
if: ${{ matrix.python-version == '3.9'}}
run: python -m pip install numpy==1.21.5 scipy==1.7.3 cvxpy==1.1.17 pandas==1.5.0 osqp==0.6.2.post0 ecos==2.0.11 scs==2.1.4
run: python -m pip install numpy==1.21.5 scipy==1.7.3 cvxpy==1.1.17 pandas==1.4.0 osqp==0.6.2.post0 ecos==2.0.11 scs==2.1.4

- name: If running on python 3.10 install some old dependencies
if: ${{ matrix.python-version == '3.10'}}
Expand Down
5 changes: 2 additions & 3 deletions cvxportfolio/simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,14 +179,13 @@ def _downsample(self, interval):
# print(new_returns_index)
self.returns = np.exp(np.log(
1+self.returns).resample(interval, closed='left', label='left'
).sum(numeric_only=False, min_count=1))-1
).sum(min_count=1))-1
self.returns.index = new_returns_index
if self.volumes is not None:
new_volumes_index = pd.Series(self.volumes.index, self.volumes.index
).resample(interval, closed='left', label='left').first().values
self.volumes = self.volumes.resample(
interval, closed='left', label='left').sum(
numeric_only=False, min_count=1)
interval, closed='left', label='left').sum(min_count=1)
self.volumes.index = new_volumes_index
if self.prices is not None:
new_prices_index = pd.Series(self.prices.index, self.prices.index
Expand Down

0 comments on commit 7a58422

Please sign in to comment.