My custom Fee Model:
class FutuTransactionFeeModel(FeeModel):
def GetOrderFee(self, parameters: OrderFeeParameters) -> OrderFee:
order = parameters.Order
price = order.price
count = order.quantity
security = parameters.security
return OrderFee(CashAmount(0.5, security.Currency.Symbol))
set my custon fee model:
self.equities[stock_name].set_fee_model(FutuTransactionFeeModel())
but when this called in ondata method ,error comes:
holding_stock = self.portfolio[stock_symbol]
stock_unrealized_profit = holding_stock.unrealized_profit
Runtime Error: FutuTransactionFeeModel.GetOrderFee() takes 2 positional arguments but 3 were given
at update_holding_stock_delta
stock_unrealized_profit = holding_stock.unrealized_profit
I don't konw why this error comes and what can i do ,anyone can help me ?
Mia Alissi
Make sure that
self
andstock_name
are defined in your algorithm where you set the fee model. This will resolve the runtime error you were facing.Sources: Key Concepts - QuantConnect.com, Custom Models P E P8 Algorithm, Supported Models - QuantConnect.com, Custom Models Algorithm, Immediate Execution Model Works With Binance Fee Model
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
Sean Sean Sean
yes , I am sure stock name is define ,and i change my code to this, the error remains:
Louis Szeto
Hi Sean
The error results from the get_order_fee method, which cannot be wrapped by the Python Wrapper. Usually, it is because the method cannot be compiled by Pythonnet, which indicates some methods/properties used inside the method do not exist. In your case, `security.currency` and `order.price` are not valid properties.
Best
Louis
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
Sean Sean Sean
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!