☰
Login
Signup
Home
›
Python client
Howdy, Stranger!
It looks like you're new here. If you want to get involved, click one of these buttons!
Sign In
Register
Categories
Recent Discussions
Activity
Categories
13.6K
All Categories
0
Incidents
143
Node JS client
38
Go client
784
.Net API client
375
Kite Publisher
537
.Net / VBA / Excel (3rd party)
452
Algorithms and Strategies
985
Java client
1.1K
API clients
402
PHP client
3.9K
Python client
344
Mobile and Desktop apps
1.3K
Market data (WebSockets)
3.3K
General
In this Discussion
December 2021
nayana
December 2021
SRIJAN
plotting ohlc in candlestick chart
nayana
December 2021
in
Python client
hi, this is my code where im reading data from database and converting tick data into ohlc
and i am plotting that data in an chart.In chart im not getting timestamp in x axis its throwing me error can anyone help me in this..
thanks in advance
db=mysql.connector.connect(host='localhost',user='root',password='',database='algotrading')
data=pd.read_sql('select *from algotrading.ticks',con=db)
data=data.set_index(['timestamp'])
ticks=data.loc[:,['last_price']]
data=ticks['last_price'].resample('1min').ohlc().dropna()
print(data)
# print(data['timestamp'])
#with
open('alogdata.csv','w',newline='')as csvfile:
# writer=csv.writer(csvfile)
# writer.writerow(v)
fig = go.Figure(data=[go.Candlestick(x=df['timestamp'],
open=df['open'],
high=df['high'],
low=df['low'],
close=df['close'])])
fig.show()
Tagged:
python
python chart candlestick
SRIJAN
December 2021
What's the error you are getting??
nayana
December 2021
fig = go.Figure(data=[go.Candlestick(x=data['timestamp'],
KeyError: 'timestamp'
im getting this error
SRIJAN
December 2021
edited December 2021
The 'timestamp' key is not present in your dataframe. Use the correct key.
Sign In
or
Register
to comment.
KeyError: 'timestamp'
im getting this error