Skip to content

Use order price for crypto future initial margin checks#9411

Open
aiSynergy37 wants to merge 2 commits intoQuantConnect:masterfrom
aiSynergy37:bug-7726-cryptofuture-order-margin
Open

Use order price for crypto future initial margin checks#9411
aiSynergy37 wants to merge 2 commits intoQuantConnect:masterfrom
aiSynergy37:bug-7726-cryptofuture-order-margin

Conversation

@aiSynergy37
Copy link
Copy Markdown
Contributor

Summary

  • use order-derived price when computing crypto future order initial margin
  • keep existing security-price-based GetInitialMarginRequirement(InitialMarginParameters) behavior for non-order paths
  • add regression tests covering BTCUSDT and BTCUSD limit orders

Why

Fixes incorrect buying power checks for crypto future limit orders where margin should be based on the executable order price context.

Closes #7726

Testing

  • Local environment is blocked by Windows Application Control when loading QuantConnect.Tests.dll (0x800711C7).
  • Requested command to run on unrestricted runner:
    • dotnet test Tests/QuantConnect.Tests.csproj --filter "FullyQualifiedName~CryptoFutureMarginModelTests.InitialMarginRequiredForOrderUsesLimitOrderPrice"

@aiSynergy37
Copy link
Copy Markdown
Contributor Author

Validation update:

To bypass the local Windows App Control restriction (0x800711C7), I ran the exact command on GitHub-hosted runners:

dotnet test Tests/QuantConnect.Tests.csproj --filter "FullyQualifiedName~CryptoFutureMarginModelTests.InitialMarginRequiredForOrderUsesLimitOrderPrice"

Runs:

Both runs aborted before producing a test assertion result with the same host crash:

  • The active test run was aborted. Reason: Test host process crashed : Unhandled exception. System.InvalidOperationException: GIL must always be released, and it must be released from the same thread that acquired it.
  • Test Run Aborted.
  • Process completed with exit code 1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CryptoFutureMarginModel - GetInitialMarginRequirement doesn't consider order type

2 participants