-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinitializeStockInfoFile.py
More file actions
31 lines (22 loc) · 924 Bytes
/
initializeStockInfoFile.py
File metadata and controls
31 lines (22 loc) · 924 Bytes
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
############### Initilize the stock info CSV #########################
from alpha_vantage.fundamentaldata import FundamentalData
import pandas as pd
import csv
import requests
import time
API_key = "********"
# Get list of tickers from csv
list_of_tickers = pd.read_csv(r'/home/ubuntu/list_of_tickers.csv')
list_of_tickers = list(list_of_tickers.symbol)
# Get company overview data for column names
overview = FundamentalData(key=API_key, output_format='pandas')
tempdata = overview.get_company_overview('AAPL')[0]
list_of_columns = tempdata.columns
# Empty dataframe
overview_data_all = pd.DataFrame(columns=list_of_columns)
# 1st entry
tempdata = overview.get_company_overview(list_of_tickers[0])
overview_data_all = pd.concat([overview_data_all,tempdata[0]], ignore_index = True)
# Write to file
overview_data_all.to_csv(r'/home/ubuntu/overview_data_all.csv')
print('ALL DONE !!!!')