Thank you in advance for your help. I am racking my brain, but cannot solve for plotting more bars than 2 in Jupyter. This is code from a Documentation Example, but it doesn't produce a year of daily candlesticks. Does anyone know why not?
from datetime import date
start_date = datetime(2020, 1, 4)
end_date = datetime(2023,1,1)
#symb = qb.AddEquity("REGN", Resolution.Daily).Symbol
symb = qb.AddEquity("SPY", Resolution.Daily).Symbol
history = qb.History(symb, start_date, end_date, Resolution.Daily)
import plotly.express as px
import plotly.graph_objects as go
#print(history.Count())
# Plot security price candlesticks
candlestick = go.Candlestick(x=history.index,
open=history['open'],
high=history['high'],
low=history['low'],
close=history['close'],
name='Price')
layout = go.Layout(title=go.layout.Title(text=f'{symb.Value} Trades'),
xaxis_title='Date',
yaxis_title='Price',
xaxis_rangeslider_visible=True,
height=600)
fig = go.Figure(data=[candlestick], layout=layout)
# Plot buys
#fig.add_trace(go.Scatter(
# x=order_data.buy_fill_times,
# y=order_data.buy_fill_prices,
# marker=go.scatter.Marker(color='aqua', symbol='triangle-up', size=10),
# mode='markers',
# name='Buys',
#))
# Plot sells
#fig.add_trace(go.Scatter(
# x=order_data.sell_fill_times,
# y=order_data.sell_fill_prices,
# marker=go.scatter.Marker(color='indigo', symbol='triangle-down', size=10),
# mode='markers',
# name='Sells',
#))
fig.show()
Craig McWilliams
I managed to fix the code:
Craig McWilliams
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!