Add python syntax check (#8651)
API Tests / build (push) Has been cancelled
Benchmarks / build (push) Has been cancelled
Build & Test Lean / build (push) Has been cancelled
Regression Tests / build (push) Has been cancelled
Report Generator Tests / build (push) Has been cancelled
Research Regression Tests / build (push) Has been cancelled
Syntax Tests / build (push) Has been cancelled
Python Virtual Environments / build (push) Has been cancelled

* Add python syntax check

* Fix some python regression algorithms

* Fixing more bugs
This commit is contained in:
Martin-Molinero
2025-03-28 10:36:26 -03:00
committed by GitHub
parent 581e87809b
commit 513ced31d7
155 changed files with 667 additions and 587 deletions
@@ -53,7 +53,7 @@ class TrailingStopOrderRegressionAlgorithm(QCAlgorithm):
stop_price_to_market_price_distance = stop_price - low
if stop_price_to_market_price_distance > self.buy_trailing_amount:
raise Exception(f"StopPrice {stop_price} should be within {self.buy_trailing_amount} of the previous low price {low} at all times.")
raise AssertionError(f"StopPrice {stop_price} should be within {self.buy_trailing_amount} of the previous low price {low} at all times.")
if self._sell_order_ticket is None:
if self.portfolio.invested:
@@ -67,7 +67,7 @@ class TrailingStopOrderRegressionAlgorithm(QCAlgorithm):
else self._previous_slice.bars[self._symbol].high
stop_price_to_market_price_distance = high - stop_price
if stop_price_to_market_price_distance > self.sell_trailing_amount:
raise Exception(f"StopPrice {stop_price} should be within {self.sell_trailing_amount} of the previous high price {high} at all times.")
raise AssertionError(f"StopPrice {stop_price} should be within {self.sell_trailing_amount} of the previous high price {high} at all times.")
self._previous_slice = slice
@@ -76,10 +76,10 @@ class TrailingStopOrderRegressionAlgorithm(QCAlgorithm):
if orderEvent.direction == OrderDirection.BUY:
stop_price = self._buy_order_ticket.get(OrderField.STOP_PRICE)
if orderEvent.fill_price < stop_price:
raise Exception(f"Buy trailing stop order should have filled with price greater than or equal to the stop price {stop_price}. "
raise AssertionError(f"Buy trailing stop order should have filled with price greater than or equal to the stop price {stop_price}. "
f"Fill price: {orderEvent.fill_price}")
else:
stop_price = self._sell_order_ticket.get(OrderField.STOP_PRICE)
if orderEvent.fill_price > stop_price:
raise Exception(f"Sell trailing stop order should have filled with price less than or equal to the stop price {stop_price}. "
raise AssertionError(f"Sell trailing stop order should have filled with price less than or equal to the stop price {stop_price}. "
f"Fill price: {orderEvent.fill_price}")