Update main.py
Browse files
main.py
CHANGED
@@ -37,46 +37,46 @@ async def get_data(ticker: str):
|
|
37 |
async def get_stocks_data(ticker: str, intervals: int, days: int):
|
38 |
try:
|
39 |
response = fetcher.fetch_stock_data(ticker, 15, 10).to_dict(orient="records")
|
40 |
-
return response
|
41 |
-
except:
|
42 |
return {"data" : response}
|
|
|
|
|
43 |
|
44 |
@app.get('/chain')
|
45 |
async def get_stocks_data(ticker: str):
|
46 |
try:
|
47 |
response = fetcher.fetch_option_chain(ticker).to_dict(orient="records")
|
48 |
-
return response
|
49 |
-
except:
|
50 |
return {"data" : response}
|
|
|
|
|
51 |
|
52 |
@app.get('/search')
|
53 |
async def get_stocks_data(ticker: str):
|
54 |
try:
|
55 |
response = fetcher.search_entity(ticker)
|
56 |
-
return response
|
57 |
-
except:
|
58 |
return {"data" : response}
|
|
|
|
|
59 |
|
60 |
@app.get('/news')
|
61 |
async def get_stocks_data(ticker: str, page: int, size: int):
|
62 |
try:
|
63 |
response = fetcher.fetch_stock_news(ticker, page=page, size=size).to_dict(orient="records")
|
64 |
-
return response
|
65 |
-
except:
|
66 |
return {"data" : response}
|
|
|
|
|
67 |
|
68 |
@app.get('/all')
|
69 |
async def get_stocks_data():
|
70 |
try:
|
71 |
response = fetcher.fetch_all_stock().to_dict(orient="records")
|
72 |
-
return response
|
73 |
-
except:
|
74 |
return {"data" : response}
|
|
|
|
|
75 |
|
76 |
@app.get('/signal')
|
77 |
async def get_stocks_data(index: str):
|
78 |
try:
|
79 |
response = fetcher.realtime_signal(index).tail(1).to_dict(orient="records")[0]
|
80 |
-
return response
|
81 |
except:
|
82 |
-
return {"
|
|
|
37 |
async def get_stocks_data(ticker: str, intervals: int, days: int):
|
38 |
try:
|
39 |
response = fetcher.fetch_stock_data(ticker, 15, 10).to_dict(orient="records")
|
|
|
|
|
40 |
return {"data" : response}
|
41 |
+
except:
|
42 |
+
return {"Timeout" : "Error"}
|
43 |
|
44 |
@app.get('/chain')
|
45 |
async def get_stocks_data(ticker: str):
|
46 |
try:
|
47 |
response = fetcher.fetch_option_chain(ticker).to_dict(orient="records")
|
|
|
|
|
48 |
return {"data" : response}
|
49 |
+
except:
|
50 |
+
return {"Timeout" : "Error"}
|
51 |
|
52 |
@app.get('/search')
|
53 |
async def get_stocks_data(ticker: str):
|
54 |
try:
|
55 |
response = fetcher.search_entity(ticker)
|
|
|
|
|
56 |
return {"data" : response}
|
57 |
+
except:
|
58 |
+
return {"Timeout" : "Error"}
|
59 |
|
60 |
@app.get('/news')
|
61 |
async def get_stocks_data(ticker: str, page: int, size: int):
|
62 |
try:
|
63 |
response = fetcher.fetch_stock_news(ticker, page=page, size=size).to_dict(orient="records")
|
|
|
|
|
64 |
return {"data" : response}
|
65 |
+
except:
|
66 |
+
return {"Timeout" : "Error"}
|
67 |
|
68 |
@app.get('/all')
|
69 |
async def get_stocks_data():
|
70 |
try:
|
71 |
response = fetcher.fetch_all_stock().to_dict(orient="records")
|
|
|
|
|
72 |
return {"data" : response}
|
73 |
+
except:
|
74 |
+
return {"Timeout" : "Error"}
|
75 |
|
76 |
@app.get('/signal')
|
77 |
async def get_stocks_data(index: str):
|
78 |
try:
|
79 |
response = fetcher.realtime_signal(index).tail(1).to_dict(orient="records")[0]
|
80 |
+
return {"data" : response}
|
81 |
except:
|
82 |
+
return {"Timeout" : "Error"}
|