Hi
I'm trying to create this backtest from Quantopian codes. Please help
def initialize(context):# Set for either buy at open / sell at close vs buy at close / sell at open# True is intraday / False is overnightbuy_open_sell_close = Falseif buy_open_sell_close:# Schedule orders. Market close orders need a minute to fill.schedule_function(my_buys, date_rules.every_day(), time_rules.market_open(minutes=2))schedule_function(my_sells, date_rules.every_day(), time_rules.market_close(minutes=2)) else: schedule_function(my_sells, date_rules.every_day(), time_rules.market_open(minutes=10))schedule_function(my_buys, date_rules.every_day(), time_rules.market_close(minutes=10))
def my_buys(context, data):order_target_percent(symbol('qqq'),1) def my_sells(context, data):order_target(symbol('qqq'),0)
Vladimir
Brandon levan .
Here is "Buy Open Sell Close".
Enjoy.
Hi Vladimir
Thanks so much. Also can you help add "flat fee" = $1 per trade instead of default fees
Thanks
Spacetime
the below link should help
https://www.quantconnect.com/docs/algorithm-reference/reality-modelling#Reality-Modelling-Fee-Models
In Initialize, you can use:
self.Securities["QQQ"].FeeModel = ConstantFeeModel(1.0)
Thanks spacetime and Vladimir
I would like to try same script with futures contract "NQ". Can you help? If posible I would like to pay for the works. Thanks
Vladimir
Here is "Buy Open Sell Close" with a Spacetime recommendation.
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!