Skip to content

Commit

Permalink
fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
LouisSzeto committed Dec 9, 2024
1 parent d26361c commit d6b94be
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions Algorithm.Python/InteractiveBrokersTieredFeeModelAlgorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ class InteractiveBrokersTieredFeeModelAlgorithm(QCAlgorithm):

def initialize(self):
''' Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.'''
self.set_start_date(2013, 10, 7) #Set Start Date
self.set_end_date(2013, 10, 10) #Set End Date
self.set_cash(1000000000) #Set Strategy Cash
self.set_start_date(2013, 10, 7) #Set Start Date
self.set_end_date(2013, 10, 10) #Set End Date
self.set_cash(1000000000) #Set Strategy Cash

# Set the fee model to be shared by all securities to accurately track the volume/value traded to select the correct tiered fee structure.
self.set_security_initializer(lambda security: security.set_fee_model(self.fee_model))
Expand Down
12 changes: 6 additions & 6 deletions Common/Orders/Fees/InteractiveBrokersTieredFeeModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
### <summary>
### Provides the implementation of "IFeeModel" for Interactive Brokers Tiered Fee Structure
### </summary>
class InteractiveBrokersTieredFeeModel:
class InteractiveBrokersTieredFeeModel(FeeModel):
equity_minimum_order_fee = 0.35
equity_commission_rate = None
future_commission_tier = None
Expand Down Expand Up @@ -207,14 +207,14 @@ def get_order_fee(self, parameters: OrderFeeParameters) -> OrderFee:
self.monthly_trade_volume[SecurityType.OPTION] += quantity * order_price

elif security.Type == SecurityType.FUTURE or security.Type == SecurityType.FUTURE_OPTION:
fee_result, fee_currency = self.calculate_future_fop_fee(security, order, quantity, market, self.future_fee)
fee_result, fee_currency = self.calculate_future_fop_fee(security, quantity, market, self.future_fee)

# Update the monthly value traded
self.monthly_trade_volume[SecurityType.FUTURE] += quantity

elif security.Type == SecurityType.EQUITY:
trade_value = abs(order.get_value(security))
fee_result, fee_currency, trade_fee = self.calculate_equity_fee(security, order, quantity, trade_value, market, self.equity_commission_rate, self.equity_minimum_order_fee)
fee_result, fee_currency = self.calculate_equity_fee(quantity, trade_value, market, self.equity_commission_rate, self.equity_minimum_order_fee)

# Tiered fee model has the below extra cost.
# FINRA Trading Activity Fee only applies to sale of security.
Expand All @@ -226,9 +226,9 @@ def get_order_fee(self, parameters: OrderFeeParameters) -> OrderFee:
# Clearing Fee: NSCC, DTC Fees.
clearing = min(0.0002 * quantity, 0.005 * trade_value)
# Exchange related handling fees.
exchange = self.get_equity_exchange_fee(order, security.primary_exchange, trade_value, trade_fee)
exchange = self.get_equity_exchange_fee(order, security.primary_exchange, trade_value, fee_result)
# FINRA Pass Through Fees.
pass_through = min(8.3, trade_fee * 0.00056)
pass_through = min(8.3, fee_result * 0.00056)

fee_result += regulatory + exchange + clearing + pass_through

Expand Down Expand Up @@ -551,4 +551,4 @@ def __init__(self, currency: str, fee_per_share: float, minimum_fee: float, maxi
self.currency = currency
self.fee_per_share = fee_per_share
self.minimum_fee = minimum_fee
self.maximum_fee_rate = maximum_fee_rate
self.maximum_fee_rate = maximum_fee_rate

0 comments on commit d6b94be

Please sign in to comment.