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

Add IB Tiered Fee Model #8446

Open
wants to merge 17 commits into
base: master
Choose a base branch
from

Conversation

LouisSzeto
Copy link
Collaborator

Description

  • Add IB Tiered Fee Structure Model
  • Refactor the current IB fee model implementation
  • Add Crypto support

Related Issue

Motivation and Context

Missing feature

Requires Documentation Change

Add to Writing Algorithms / Reality Modeling / Transaction Fee / Supported Models

How Has This Been Tested?

  • Unit tests
  • Regression tests

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • Refactor (non-breaking change which improves implementation)
  • Performance (non-breaking change which improves performance. Please add associated performance test and results)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Non-functional change (xml comments/documentation/etc)

Checklist:

  • My code follows the code style of this project.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • My branch follows the naming convention bug-<issue#>-<description> or feature-<issue#>-<description>

Copy link
Collaborator

@jhonabreul jhonabreul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Leaving a few comments.

_monthlyTradeVolume = _monthlyTradeVolume.ToDictionary(kvp => kvp.Key, _ => 0m);
}
// Reprocess the rate schedule based on the current traded volume in various assets.
ReprocessRateSchedule(_monthlyTradeVolume[SecurityType.Equity], _monthlyTradeVolume[SecurityType.Future], _monthlyTradeVolume[SecurityType.Forex],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be done on month rollover only as well?

Copy link
Collaborator Author

@LouisSzeto LouisSzeto Dec 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nah, the fee will change by sufficient volume/dollar volume traded within that month. It should be sensitive to per order level.

Common/Orders/Fees/InteractiveBrokersTieredFeeModel.cs Outdated Show resolved Hide resolved
Common/Orders/Fees/InteractiveBrokersTieredFeeModel.cs Outdated Show resolved Hide resolved
Common/Orders/Fees/InteractiveBrokersTieredFeeModel.cs Outdated Show resolved Hide resolved
Comment on lines +53 to +55
MarketOnOpenOrder(_spy, 30000);
MarketOnOpenOrder(_aig, 30000);
MarketOnOpenOrder(_bac, 30000);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these orders filled on the next day or right away? If the latest, might as well use MarketOrder? Same for the MarketOnClose ones

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They should be filled right away at 9:30am, same for market on close at 4pm

Copy link
Collaborator

@jhonabreul jhonabreul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good! Just a couple more comments

// Add exchange fees + IBKR regulatory fee (0.02)
return new CashAmount(ibFeePerContract + exchangeFeePerContract + 0.02m, Currencies.EUR);
return new CashAmount(ibFeePerContract + exchangeFeePerContract + 0.02m, Currencies.USD);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to run at least a few of these tests for the Python model as well? Just to make sure they are always kept the same when changed

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CC: @LouisSzeto 👁️

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.

3 participants