Skip to content

Commit ba4f590

Browse files
committed
Modified PriceParser in rebalance to not differ between 2.7.x and 3.x.x.
1 parent 32bdb92 commit ba4f590

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

examples/test_examples.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def test_monthly_liquidate_rebalance_backtest(self):
7878
self.config, self.testing, tickers, filename
7979
)
8080
self.assertAlmostEqual(
81-
float(results['sharpe']), 0.27105589487274
81+
float(results['sharpe']), 0.2710491397280638
8282
)
8383

8484

qstrader/position_sizer/rebalance.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,9 @@ def size_order(self, portfolio, initial_order):
4343
# Determine total portfolio value, work out dollar weight
4444
# and finally determine integer quantity of shares to purchase
4545
price = portfolio.price_handler.tickers[ticker]["adj_close"]
46-
price /= PriceParser.PRICE_MULTIPLIER
47-
equity = portfolio.equity / PriceParser.PRICE_MULTIPLIER
46+
price = PriceParser.display(price)
47+
equity = PriceParser.display(portfolio.equity)
4848
dollar_weight = weight * equity
4949
weighted_quantity = int(floor(dollar_weight / price))
50-
# Update quantity
5150
initial_order.quantity = weighted_quantity
5251
return initial_order

0 commit comments

Comments
 (0)