Repository navigation
Use the executable spread side for IB option market order fees #10178
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
base: master
Are you sure you want to change the base?
Changes from all commits
d3a6101
bc15bd8
b6c23cc
aeca3f8
ddc2e11
5d9356a
f563da6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,6 +31,11 @@ public class TastytradeFeeModel : FeeModel | |
| /// </summary> | ||
| private const decimal _optionFeeOpen = 1m; | ||
|
|
||
| /// <summary> | ||
| /// The fee associated with an option exercise or assignment (per transaction). | ||
| /// </summary> | ||
| private const decimal _optionExerciseFee = 5m; | ||
|
|
||
| /// <summary> | ||
| /// The fee associated with futures transactions (per contract). | ||
| /// </summary> | ||
|
|
@@ -51,6 +56,12 @@ public class TastytradeFeeModel : FeeModel | |
| /// </returns> | ||
| public override OrderFee GetOrderFee(OrderFeeParameters parameters) | ||
| { | ||
| // an option exercise or assignment is charged a flat fee, whatever its size | ||
| if (parameters.Order.Type == OrderType.OptionExercise) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In a backtest, this runs once for each fill of the exercise order ( |
||
| { | ||
| return new OrderFee(new CashAmount(_optionExerciseFee, Currencies.USD)); | ||
| } | ||
|
|
||
| var feeRate = default(decimal); | ||
| switch (parameters.Security.Type) | ||
| { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P2] Preserve sale-side fee estimation in the assignment simulator.
DefaultOptionAssignmentModel.cs:99,112–119values the counterparty selling an option at the bid, but passes a positive-quantityMarketOrderto this fee model. Changing that synthetic buy to the ask tier raises the estimated sale fee and can newly trigger early assignment. Reproduced with a standard 100-share American call three days before expiry: strike $0.50, short 10 at average $0.10, underlying close $0.54 and bid/ask $0.5009/$0.54, option bid/ask $0.09/$0.11. With identical inputs, base returns arbitrage P/L $0 and assignment quantity 0; this head returns $1.50 and assigns all 10. Correcting only the simulator's hypothetical order to a sale restores quantity 0. The caller's sign error predates this PR, but this incorrect assignment decision is new. Please align that fee estimate with the sale it models and add an assignment regression, or obtain a maintainer decision on accepting the limitation before changing this caller's behavior.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 24624d8:
EstimateArbitragePnLnow estimates the close's fee with a sale (holding.Quantity), matching the bid it values the close at, instead of a buy. AddedEstimatesTheFeeOfClosingTheCounterPartyPositionAsASalewith your reproduction (strike 0.50, short 10 at 0.10, underlying 0.5009/0.54, option 0.09/0.11, 3 days out): it passes on master (base and exercise P/L are both -$15, no assignment), fails with only the fee change (assigns 10), and passes with both. Full unit suite (39769 passed) and all 1112 regression cases pass.