Fix crypto future margin model to reflect margin used (#9235)
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
API Tests / build (push) Has been cancelled
Syntax Tests / build (push) Has been cancelled
Python Virtual Environments / 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
API Tests / build (push) Has been cancelled
Syntax Tests / build (push) Has been cancelled
Python Virtual Environments / build (push) Has been cancelled
* Fix crypto future margin model to reflect margin used * Minor tests fixes * Cleanup * Cleanup
This commit is contained in:
@@ -82,7 +82,7 @@ class BasicTemplateCryptoFutureAlgorithm(QCAlgorithm):
|
||||
raise AssertionError(f"Unexpected holdings cost {self.btc_usd_holdings.holdings_cost}")
|
||||
|
||||
# margin used is based on the maintenance rate
|
||||
if (abs(self.btc_usd_holdings.absolute_holdings_cost * 0.05 - self.margin_used) > 1) or (BuyingPowerModelExtensions.get_maintenance_margin(self.btc_usd.buying_power_model, self.btc_usd) != self.margin_used):
|
||||
if BuyingPowerModelExtensions.get_maintenance_margin(self.btc_usd.buying_power_model, self.btc_usd) != self.margin_used:
|
||||
raise AssertionError(f"Unexpected margin used {self.margin_used}")
|
||||
|
||||
self.buy(self.ada_usdt.symbol, 1000)
|
||||
@@ -99,7 +99,7 @@ class BasicTemplateCryptoFutureAlgorithm(QCAlgorithm):
|
||||
if abs(self.ada_usdt_holdings.absolute_holdings_cost - self.holdings_value_usdt) > 1:
|
||||
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):
|
||||
if BuyingPowerModelExtensions.get_maintenance_margin(self.ada_usdt.buying_power_model, self.ada_usdt) != self.margin_used:
|
||||
raise AssertionError(f"Unexpected margin used {self.margin_used}")
|
||||
|
||||
# position just opened should be just spread here
|
||||
|
||||
Reference in New Issue
Block a user