I'm a newbie so forgive the mess, I am just stitching examples together to lean and no matter what I change trades always happen on ‘2024-08-23’ . Ive changed the SetStartDate & SetStartDate, no change. thought maybe there was no data for the ticker since im testing with the free account, so i tried tsla and spy, didnt work. what am I doing wrong?
example:
677
|
12:20:27
:
2024-08-23 09:31:00: 0: Time: 08/23/2024 13:31:00 OrderID: 1 EventID: 2 Symbol: SPY Status: Filled Quantity: 20 FillQuantity: 20 FillPrice: $557.4705 OrderFee: 1 USD
678
|
12:20:27
:
2024-08-23 09:32:00: 0: Time: 08/23/2024 13:32:00 OrderID: 2 EventID: 2 Symbol: SPY Status: Filled Quantity: -20 FillQuantity: -20 FillPrice: $557.2313 OrderFee: 1 USD
679
|
12:20:27
:
2024-08-23 09:33:00: 0: Time: 08/23/2024 13:33:00 OrderID: 3 EventID: 2 Symbol: SPY Status: Filled Quantity: 20 FillQuantity: 20 FillPrice: $557.2612 OrderFee: 1 USD
680
from AlgorithmImports import *
import numpy as np
from collections import deque
class HKUSTIntradayMomentum(QCAlgorithm):
def initialize(self):
self.set_name("Intra-MOMO backtest")
self.SetStartDate(2024, 11, 18)
self.SetEndDate(2024, 11, 18)
#start = self.SetStartDate(2024, 11, 18)
#end = self.SetEndDate(2024, 11, 18)
self.set_cash(25000)
self.set_brokerage_model(BrokerageName.INTERACTIVE_BROKERS_BROKERAGE, AccountType.MARGIN)
self._symbol = self.add_equity("SPY", Resolution.MINUTE).symbol
self.symbol = "SPY"
self.bar = RollingWindow[TradeBar](10)
self.debug(f"symbol is: {self._symbol}")
#self.debug(f"start date is: {start}")
#self.debug(f"end date is: {end}")
self._macd = self.macd(self._symbol, 3, 9, 5, MovingAverageType.Exponential)
self.register_indicator(self._symbol, self._macd, Resolution.MINUTE)
def on_data(self, data):
open_orders = self.transactions.get_open_orders()
holdings = self.portfolio[self.symbol]
quantity = holdings.quantity
bar_slice = data.bars.get(self.symbol)
self.bar.Add(bar_slice)
if self._macd.is_ready:
# The current value of self._macd is represented by self._macd.current.value
self.plot("MovingAverageConvergenceDivergence", "macd", self._macd.current.value)
# Plot all attributes of self._macd
self.plot("MovingAverageConvergenceDivergence", "fast", self._macd.fast.current.value)
self.plot("MovingAverageConvergenceDivergence", "slow", self._macd.slow.current.value)
self.plot("MovingAverageConvergenceDivergence", "signal", self._macd.signal.current.value)
self.plot("MovingAverageConvergenceDivergence", "histogram", self._macd.histogram.current.value)
if len(open_orders) != 0: return
bar_pattern = ((self.bar[0].open > self.bar[0].close) or (self.bar[1].open > self.bar[1].close) or (self.bar[2].open > self.bar[2].close))
if (self.time.day > 10 and quantity <= 0) and (self._macd.current.value >= self._macd.signal.current.value):
self.market_order(self.symbol, 20, True)
elif (self.time.day > 20 and quantity > 0) or ((self._macd.current.value <= self._macd.signal.current.value) and (quantity > 0)):
self.market_order(self.symbol, -20, True)
def on_order_event(self, order_event: OrderEvent) -> None:
order = self.transactions.get_order_by_id(order_event.order_id)
if order_event.status == OrderStatus.FILLED:
self.debug(f"{self.time}: {order.type}: {order_event}")
Mia Alissi
Sources: Extended Market Trading Regression Algorithm, Momentum And State Of Market Filters, Momentum Effect In Commodities Futures, Seasonality Effect Based On Same Calendar Month Returns, Basic Template Index Daily Algorithm
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.
Jason
bad bot, no change, still trades show place on:
Jason
googling for answers i see another person had a similar issue, they upgraded to researcher and it didnt appear to work for them.
Hello - Beginner to QuantConnect by Santosh Kalakonda - QuantConnect.com
I didnt see a resolution to the persons question, is this project maintained and working, or what am i doing wrong.
Jared Broad
Hi Jason,
The out of sample period is fixed to 3 months for free accounts. You can disable this with the researcher subscription. We'll try and make this more obvious for future users.
Best
Jared
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.
Jason
Hi Jared thanks for the reply, I upgraded to researcher and still facing the same issue.
self.set_start_date(2024, 11, 11)
self.set_end_date(2024, 11, 11)
both set_start and end_ are set to 2024,11,11 but dates im seeing trades are still 2024-8-23, i must be doing something wrong, but changing those has no effect.
Jason
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!