-
Notifications
You must be signed in to change notification settings - Fork 0
/
graph2.py
34 lines (22 loc) · 828 Bytes
/
graph2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import requests
#import plotly.express as px
from mdate import getdate
def graph_data():
response=requests.get("https://markets.businessinsider.com/Ajax/Chart_GetChartData?instrumentType=Bond&tkData=1,32823537,1330,88&from=19700201&to=20231211")
data=response.json()
#print(data)
close_data=[]
date_data=[]
for i in range(0,len(data)):
close_data.append(data[i]["Close"])
date_data.append(data[i]["Date"].split(" ")[0])
final_data={"close":close_data,"date":date_data}
return final_data
'''fig = px.line(x=date_data, y=close_data, title='Graph')
#fig.add_scatter(x=bidx,y=bidy)
fig.update_xaxes(
title_text='Date',
tickformat='%b %d, %Y',
dtick=3 * 24 * 60 * 60 * 1000, # Set the tick interval to one month
)
fig.show()'''