Skip to content

Commit

Permalink
fixed github issue #109 on typo of logging invocation
Browse files Browse the repository at this point in the history
  • Loading branch information
enzbus committed Sep 6, 2023
1 parent 3ca3406 commit 2c6ccbc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cvxportfolio/simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ def _simulate(self, t, t_next, h, policy, mask=None, **kwargs):
current_volumes = current_and_past_volumes.iloc[-1]
non_tradable_stocks = current_volumes[current_volumes <= 0].index
if len(non_tradable_stocks):
logger.info(
logging.info(
f"At time {t} the simulator canceled trades on assets {non_tradable_stocks}"
" because their market volumes for the period are zero.")
u[non_tradable_stocks] = 0.
Expand Down
16 changes: 16 additions & 0 deletions cvxportfolio/tests/test_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,22 @@ def test_hyperparameters_optimize(self):
base_location=self.datadir)

simulator.optimize_hyperparameters(policy, start_time='2023-01-01')

def test_cancel_trades(self):

sim = cvx.StockMarketSimulator(
['AAPL', 'ZM'],
trading_frequency='monthly',
base_location=self.datadir)

sim.market_data.volumes['ZM'] = 0.

objective = cvx.ReturnsForecast() - 5 * cvx.FullCovariance()
policy = cvx.SinglePeriodOptimization(
objective, [cvx.LongOnly(), cvx.LeverageLimit(1)])

sim.backtest(policy, start_time='2023-01-01')



if __name__ == '__main__':
Expand Down

0 comments on commit 2c6ccbc

Please sign in to comment.