- Remove unrequired `GetBuyingPower`
- Making `BuyingPowerModel.GetMaintenanceMarginRequirement` protected
instead of public
- Adding `GetMaximumOrderQuantityForDeltaBuyingPower` to replace
public `GetMaintenanceMarginRequirement` and improve API experience for
consumers like the `DefaultMarginCallModel`
- Adding new unit tests
The logic for margin calls was previously split between SecurityPortfolioManager.ScanForMarginCall and IMarginCallModel methods, now it is entirely contained within margin call model implementations.
One of the margin call model tests was also testing against the Null model, it has been updated to use the DefaultMarginCallModel.
This PR reverts and replaces PR #674 because it caused issue #678.
The margin call model has been refactored and now contains both methods for margin call order handling (generation and execution).
Disabling margin calls is now much simpler:
Portfolio.MarginCallModel = MarginCallModel.Null;
List of changes:
- Added a new IMarginCallModel interface
- Renamed MarginCallModel to DefaultMarginCallModel
- Refactored margin call models by moving the GenerateMarginCallOrder method from ISecurityMarginModel to IMarginCallModel
- Disabled margin calls by default for live trading in BrokerageSetupHandler initialization