Skip to content

Fix double fee haircut in risk_to_qty - #620

Open
Steve0x2a wants to merge 1 commit into
jesse-ai:masterfrom
Steve0x2a:fix/risk-to-qty-double-fee
Open

Steve0x2a wants to merge 1 commit into
jesse-ai:masterfrom
Steve0x2a:fix/risk-to-qty-double-fee

Conversation

@Steve0x2a

Copy link
Copy Markdown

Fixes #614

Credit to @flyerswk for reporting this and pinpointing the double application.

risk_to_qty reduced size by (1 - fee_rate * 3) and then called size_to_qty(..., fee_rate=fee_rate), which applies the same haircut again.

On the reporter inputs that produced a double-haircut qty of 97.0225 instead of a single haircut of 98.5:

risk_to_qty(10000, 10, 100, 90, fee_rate=0.005)

This drops the pre-adjust in risk_to_qty and lets size_to_qty apply the fee once. size_to_qty itself is unchanged, so other callers keep the same behavior.

risk_to_qty(10000, 10, 100, 90, fee_rate=0.005) now returns 98.5.

risk_to_qty was reducing size by (1 - fee_rate * 3) and then passing
fee_rate into size_to_qty, which applies the same haircut again.
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.

utils.risk_to_qty() function calculates fee_rate twice

1 participant