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
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:
@@ -58,13 +58,13 @@ class BasicTemplateCryptoFutureHourlyAlgorithm(QCAlgorithm):
|
||||
self.interest_per_symbol[interest_rate.key] += 1
|
||||
self.cached_interest_rate = self.securities[interest_rate.key].cache.get_data[MarginInterestRate]()
|
||||
if self.cached_interest_rate != interest_rate.value:
|
||||
raise Exception(f"Unexpected cached margin interest rate for {interest_rate.key}!")
|
||||
raise AssertionError(f"Unexpected cached margin interest rate for {interest_rate.key}!")
|
||||
|
||||
if self.fast > self.slow:
|
||||
if self.portfolio.invested == False and self.transactions.orders_count == 0:
|
||||
self.ticket = self.buy(self.ada_usdt.symbol, 100000)
|
||||
if self.ticket.status != OrderStatus.INVALID:
|
||||
raise Exception(f"Unexpected valid order {self.ticket}, should fail due to margin not sufficient")
|
||||
raise AssertionError(f"Unexpected valid order {self.ticket}, should fail due to margin not sufficient")
|
||||
|
||||
self.buy(self.ada_usdt.symbol, 1000)
|
||||
|
||||
@@ -76,22 +76,22 @@ class BasicTemplateCryptoFutureHourlyAlgorithm(QCAlgorithm):
|
||||
self.holdings_value_usdt = self.ada_usdt.price * self.ada_usdt.symbol_properties.contract_multiplier * 1000
|
||||
|
||||
if abs(self.ada_usdt_holdings.total_sale_volume - self.holdings_value_usdt) > 1:
|
||||
raise Exception(f"Unexpected TotalSaleVolume {self.ada_usdt_holdings.total_sale_volume}")
|
||||
raise AssertionError(f"Unexpected TotalSaleVolume {self.ada_usdt_holdings.total_sale_volume}")
|
||||
|
||||
if abs(self.ada_usdt_holdings.absolute_holdings_cost - self.holdings_value_usdt) > 1:
|
||||
raise Exception(f"Unexpected holdings cost {self.ada_usdt_holdings.holdings_cost}")
|
||||
raise AssertionError(f"Unexpected holdings cost {self.ada_usdt_holdings.holdings_cost}")
|
||||
|
||||
if (abs(self.ada_usdt_holdings.absolute_holdings_cost * 0.05 - self.margin_used) > 1) or (BuyingPowerModelExtensions.get_maintenance_margin(self.ada_usdt.buying_power_model, self.ada_usdt) != self.margin_used):
|
||||
raise Exception(f"Unexpected margin used {self.margin_used}")
|
||||
raise AssertionError(f"Unexpected margin used {self.margin_used}")
|
||||
|
||||
# position just opened should be just spread here
|
||||
self.profit = self.portfolio.total_unrealized_profit
|
||||
|
||||
if (5 - abs(self.profit)) < 0:
|
||||
raise Exception(f"Unexpected TotalUnrealizedProfit {self.portfolio.total_unrealized_profit}")
|
||||
raise AssertionError(f"Unexpected TotalUnrealizedProfit {self.portfolio.total_unrealized_profit}")
|
||||
|
||||
if (self.portfolio.total_profit != 0):
|
||||
raise Exception(f"Unexpected TotalProfit {self.portfolio.total_profit}")
|
||||
raise AssertionError(f"Unexpected TotalProfit {self.portfolio.total_profit}")
|
||||
|
||||
else:
|
||||
# let's revert our position and double
|
||||
@@ -104,23 +104,23 @@ class BasicTemplateCryptoFutureHourlyAlgorithm(QCAlgorithm):
|
||||
self.holdings_value_usdt = self.ada_usdt.price * self.ada_usdt.symbol_properties.contract_multiplier * 2000
|
||||
|
||||
if abs(self.ada_usdt_holdings.absolute_holdings_cost - self.holdings_value_usdt) > 1:
|
||||
raise Exception(f"Unexpected holdings cost {self.ada_usdt_holdings.holdings_cost}")
|
||||
raise AssertionError(f"Unexpected holdings cost {self.ada_usdt_holdings.holdings_cost}")
|
||||
|
||||
# position just opened should be just spread here
|
||||
self.profit = self.portfolio.total_unrealized_profit
|
||||
if (5 - abs(self.profit)) < 0:
|
||||
raise Exception(f"Unexpected TotalUnrealizedProfit {self.portfolio.total_unrealized_profit}")
|
||||
raise AssertionError(f"Unexpected TotalUnrealizedProfit {self.portfolio.total_unrealized_profit}")
|
||||
|
||||
# we barely did any difference on the previous trade
|
||||
if (5 - abs(self.portfolio.total_profit)) < 0:
|
||||
raise Exception(f"Unexpected TotalProfit {self.portfolio.total_profit}")
|
||||
raise AssertionError(f"Unexpected TotalProfit {self.portfolio.total_profit}")
|
||||
|
||||
if self.time.hour >= 22 and self.transactions.orders_count == 3:
|
||||
self.liquidate()
|
||||
|
||||
def on_end_of_algorithm(self):
|
||||
if self.interest_per_symbol[self.ada_usdt.symbol] != 1:
|
||||
raise Exception(f"Unexpected interest rate count {self.interest_per_symbol[self.ada_usdt.symbol]}")
|
||||
raise AssertionError(f"Unexpected interest rate count {self.interest_per_symbol[self.ada_usdt.symbol]}")
|
||||
|
||||
def on_order_event(self, order_event):
|
||||
self.debug("{0} {1}".format(self.time, order_event))
|
||||
|
||||
Reference in New Issue
Block a user