Back

How to set Fee model in QC Framework Algorithm?

Hello,

    When trying to set a FeeTransactionModel in a QCFrameworkAlgorithm, I get this error. 

Runtime Error: NameError : name 'ConstantFeeTransactionModel' is not defined
at OnSecuritiesChanged in main.py:line 44
NameError : name 'ConstantFeeTransactionModel' is not defined

 

I am unable to attach a backtest... I guess I cannot attach backtests with runtime errors?  Here's the code:

from Alphas.ConstantAlphaModel import ConstantAlphaModel

from Portfolio.EqualWeightingPortfolioConstructionModel import EqualWeightingPortfolioConstructionModel

from Risk.NullRiskManagementModel import NullRiskManagementModel


class BasicTemplateFrameworkAlgorithm(QCAlgorithmFramework):

def Initialize(self):

# Set requested data resolution
self.UniverseSettings.Resolution = Resolution.Minute

self.SetStartDate(2018, 11, 26) #Set Start Date
self.SetEndDate(2018, 11, 27) #Set End Date
self.SetCash(100000) #Set Strategy Cash

self.SetUniverseSelection(ScheduledUniverseSelectionModel(
self.DateRules.Every(DayOfWeek.Monday, DayOfWeek.Tuesday, DayOfWeek.Wednesday, DayOfWeek.Thursday, DayOfWeek.Friday),
self.TimeRules.At(4, 0),
self.SelectSymbols))

self.SetAlpha(ConstantAlphaModel(InsightType.Price, InsightDirection.Up, TimeSpan.FromMinutes(20), 0.025, None))
self.SetPortfolioConstruction(EqualWeightingPortfolioConstructionModel())
self.SetExecution(NullExecutionModel())
self.SetRiskManagement(NullRiskManagementModel())


def SelectSymbols(self, dateTime):
symbols = []
symbols.append(Symbol.Create('SPY', SecurityType.Equity, Market.USA))
return symbols


def OnOrderEvent(self, orderEvent):
if orderEvent.Status == OrderStatus.Filled:
# self.Debug("Purchased Stock: {0}".format(orderEvent.Symbol))
pass

def OnSecuritiesChanged(self, changes):
for instrument in changes.AddedSecurities:
self.Securities[instrument].FeeModel = ConstantFeeTransactionModel(0)
#self.Securities[instrument].SlippageModel = ConstantSlippageModel(0)
#self.Securities[instrument].SetDataNormalizationMode(DataNormalizationMode.Raw)

Update Backtest







I don't think that class exists anymore. You should probably use ConstantFeeModel instead (

https://github.com/QuantConnect/Lean/blob/master/Common/Orders/Fees/ConstantFeeModel.cs

).

1

Solved the problem!  Thanks Douglas

0

Hi KILLC, the code you provided is not formatted.
Please share an algorithm (use the attach backtest button below) that shows the issue you are experiencing.
This procedure helps us, the community, to answer your questions quickly and effectively.
 

0

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.


Update Backtest





0

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.


Loading...

This discussion is closed