Spaces:
Running
Running
Robert Castagna
commited on
Commit
•
bed2d7a
1
Parent(s):
e4cdeb1
add gitignore
Browse files- .gitignore +2 -0
- fin_data_api.py +23 -9
- requirements.txt +1 -0
.gitignore
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
secrets.json
|
2 |
+
fin_data.db
|
fin_data_api.py
CHANGED
@@ -3,6 +3,7 @@ from transformers import pipeline
|
|
3 |
import json
|
4 |
import requests
|
5 |
import datetime
|
|
|
6 |
|
7 |
with open('secrets.json') as f:
|
8 |
content = json.load(f)
|
@@ -32,21 +33,34 @@ def sentiment_analysis(headline:str) -> str:
|
|
32 |
return nlp(headline)
|
33 |
|
34 |
|
35 |
-
|
36 |
-
res_news = get_finnhub_data('/company-news?symbol=AAPL&from=2023-08-15&to=2023-08-20')
|
37 |
#print(res_news[0].keys())
|
38 |
-
for item in res_news:
|
39 |
-
dt_object = datetime.datetime.fromtimestamp(item['datetime']).strftime("%Y-%m-%d")
|
40 |
#print(item['headline'], item['source'], dt_object)
|
41 |
|
42 |
|
43 |
-
|
44 |
-
res_basic_fins = get_finnhub_data('/stock/metric?symbol=AAPL&metric=all')
|
45 |
#print(res_basic_fins['metric'].keys())
|
46 |
#print(res_basic_fins['series']['annual'].keys())
|
47 |
#print(res_basic_fins['series']['quarterly'].keys())
|
48 |
|
49 |
|
50 |
-
|
51 |
-
res_sentiment = get_finnhub_data('/stock/insider-sentiment?symbol=AAPL')
|
52 |
-
#print(res_sentiment['data'][0].keys())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
import json
|
4 |
import requests
|
5 |
import datetime
|
6 |
+
import sqlite3
|
7 |
|
8 |
with open('secrets.json') as f:
|
9 |
content = json.load(f)
|
|
|
33 |
return nlp(headline)
|
34 |
|
35 |
|
36 |
+
## get news articles for a company
|
37 |
+
#res_news = get_finnhub_data('/company-news?symbol=AAPL&from=2023-08-15&to=2023-08-20')
|
38 |
#print(res_news[0].keys())
|
39 |
+
#for item in res_news:
|
40 |
+
#dt_object = datetime.datetime.fromtimestamp(item['datetime']).strftime("%Y-%m-%d")
|
41 |
#print(item['headline'], item['source'], dt_object)
|
42 |
|
43 |
|
44 |
+
## get basic financials
|
45 |
+
#res_basic_fins = get_finnhub_data('/stock/metric?symbol=AAPL&metric=all')
|
46 |
#print(res_basic_fins['metric'].keys())
|
47 |
#print(res_basic_fins['series']['annual'].keys())
|
48 |
#print(res_basic_fins['series']['quarterly'].keys())
|
49 |
|
50 |
|
51 |
+
## get insider sentiment
|
52 |
+
#res_sentiment = get_finnhub_data('/stock/insider-sentiment?symbol=AAPL')
|
53 |
+
#print(res_sentiment['data'][0].keys())
|
54 |
+
|
55 |
+
|
56 |
+
# put data in database after figuring out what data we want to store
|
57 |
+
conn = sqlite3.connect('fin_data.db')
|
58 |
+
c = conn.cursor()
|
59 |
+
c.execute("""
|
60 |
+
select * from test
|
61 |
+
""")
|
62 |
+
|
63 |
+
print(c.fetchall())
|
64 |
+
|
65 |
+
conn.commit()
|
66 |
+
conn.close()
|
requirements.txt
CHANGED
@@ -16,3 +16,4 @@ pathos
|
|
16 |
transformers
|
17 |
requests
|
18 |
datetime
|
|
|
|
16 |
transformers
|
17 |
requests
|
18 |
datetime
|
19 |
+
pysqlite3 == 0.5.2
|