Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inaccurate equity margin requirement for limit order #6846

Closed
4 tasks done
LouisSzeto opened this issue Jan 10, 2023 · 3 comments
Closed
4 tasks done

Inaccurate equity margin requirement for limit order #6846

LouisSzeto opened this issue Jan 10, 2023 · 3 comments

Comments

@LouisSzeto
Copy link
Collaborator

Expected Behavior

Based on the description of IB, the margin requirement of equities should be based on the stock value to be purchased, not the current value of the stock.
i.e. min{current / limit price} * quantity * margin factor should be required for limit order when checking submitted order

Actual Behavior

current value of stocks * quantity * margin factor is required for limit order

Reproducing the Problem

https://www.quantconnect.com/forum/discussion/14666/limitorder-requires-margin-based-on-current-close-price-not-on-limit-price/p1
backtest: https://www.quantconnect.com/terminal/processCache?request=embedded_backtest_4531fc381d219373d9293f0a38e43feb.html
The expected behavior was tested on IB.

System Information

NA

Checklist

  • I have completely filled out this template
  • I have confirmed that this issue exists on the current master branch
  • I have confirmed that this is not a duplicate issue by searching issues
  • I have provided detailed steps to reproduce the issue
@LouisSzeto LouisSzeto changed the title Inaccurate equity margin requirement Inaccurate equity margin requirement for limit order Jan 10, 2023
@dhilgarth
Copy link

I'm no longer sure this is actually a bug. I tested it in a live account on Interactive Brokers and the margin requirement was always more or less the same, no matter the limit price I entered:

Limit 150:
image

Limit 15:
image

@Martin-Molinero
Copy link
Member

Hey!

I'm no longer sure this is actually a bug. I tested it in a live account on Interactive Brokers and the margin requirement was always more or less the same, no matter the limit price I entered:

Yes we found the same behavior, we were actually using entry price for margin calculation back in 2019 and we fixed it to use current asset value, take a look at the refactor which has a detailed explanation and examples #3768.
Will close the issue for now 👌

@dhilgarth
Copy link

Great. I will do some more tests in the coming weeks regarding the exact margin amount between QC and IB. If I find any discrepancies, I will report them.

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

No branches or pull requests

3 participants