Spaces:
Running
Running
Robert Castagna
commited on
Commit
•
ead331a
1
Parent(s):
e53404c
removing scraped_data.py
Browse files- pages/1_Fundamentals.py +32 -1
- pages/2_Sentiment_Data_Input.py +3 -0
pages/1_Fundamentals.py
CHANGED
@@ -1,9 +1,40 @@
|
|
1 |
-
|
|
|
|
|
2 |
import datetime
|
3 |
import pandas as pd
|
4 |
import streamlit as st
|
5 |
import yfinance as yf
|
6 |
from datetime import timedelta
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
|
9 |
def get_industry(ticker):
|
|
|
1 |
+
import json
|
2 |
+
import os
|
3 |
+
import requests
|
4 |
import datetime
|
5 |
import pandas as pd
|
6 |
import streamlit as st
|
7 |
import yfinance as yf
|
8 |
from datetime import timedelta
|
9 |
+
from dotenv import load_dotenv
|
10 |
+
|
11 |
+
load_dotenv()
|
12 |
+
|
13 |
+
def get_finnhub_data(example: str) -> json:
|
14 |
+
"""
|
15 |
+
Pass in the "example" string from the API documentation. It changes for every endpoint.
|
16 |
+
|
17 |
+
:param1 example: '/company-news?symbol=AAPL&from=2023-08-15&to=2023-08-20'
|
18 |
+
"""
|
19 |
+
base_url = 'https://finnhub.io/api/v1//'
|
20 |
+
|
21 |
+
token = f"&token={os.environ['finnhub_token']}"
|
22 |
+
|
23 |
+
request = requests.get(f"{base_url}{example}{token}")
|
24 |
+
return request.json()
|
25 |
+
|
26 |
+
|
27 |
+
def get_alpha_vantage_data(example: str) -> json:
|
28 |
+
"""
|
29 |
+
Pass in the "function" string from the API documentation. It changes for every endpoint.
|
30 |
+
|
31 |
+
:param1 example: ''
|
32 |
+
"""
|
33 |
+
base_url = 'https://www.alphavantage.co/query?'
|
34 |
+
token = f"&apikey={os.environ['alpha_api_key']}"
|
35 |
+
|
36 |
+
request = requests.get(f"{base_url}{example}{token}")
|
37 |
+
return request.json()
|
38 |
|
39 |
|
40 |
def get_industry(ticker):
|
pages/2_Sentiment_Data_Input.py
CHANGED
@@ -10,6 +10,9 @@ import os
|
|
10 |
import streamlit as st
|
11 |
from requests.exceptions import HTTPError, RequestException
|
12 |
|
|
|
|
|
|
|
13 |
# API DOC: https://finnhub.io/docs/api/introduction
|
14 |
|
15 |
def get_finnhub_data(example: str) -> json:
|
|
|
10 |
import streamlit as st
|
11 |
from requests.exceptions import HTTPError, RequestException
|
12 |
|
13 |
+
from dotenv import load_dotenv
|
14 |
+
load_dotenv()
|
15 |
+
|
16 |
# API DOC: https://finnhub.io/docs/api/introduction
|
17 |
|
18 |
def get_finnhub_data(example: str) -> json:
|