mirror of
https://github.com/andrewkdinh/fund-indicators.git
synced 2024-11-22 00:24:19 -08:00
Tried making listGoogle.py
Tried using Google Sheets API for stock data but didn't realize they did not allow that.
This commit is contained in:
parent
8f7ea905d0
commit
353d3a7d9f
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,3 +1,5 @@
|
|||||||
__pycache__/StockData.cpython-37.pyc
|
__pycache__/StockData.cpython-37.pyc
|
||||||
__pycache__/
|
__pycache__/
|
||||||
*.pyc
|
*.pyc
|
||||||
|
quickstart.py
|
||||||
|
creds.json
|
||||||
|
@ -14,12 +14,14 @@ Barchart: No
|
|||||||
# Alpha Vantage API Key: O42ICUV58EIZZQMU
|
# Alpha Vantage API Key: O42ICUV58EIZZQMU
|
||||||
# Barchart API Key: a17fab99a1c21cd6f847e2f82b592838 # Possible other one? f40b136c6dc4451f9136bb53b9e70ffa
|
# Barchart API Key: a17fab99a1c21cd6f847e2f82b592838 # Possible other one? f40b136c6dc4451f9136bb53b9e70ffa
|
||||||
# Tiingo API Key: 2e72b53f2ab4f5f4724c5c1e4d5d4ac0af3f7ca8
|
# Tiingo API Key: 2e72b53f2ab4f5f4724c5c1e4d5d4ac0af3f7ca8
|
||||||
|
# Tradier API Key: n26IFFpkOFRVsB5SNTVNXicE5MPD
|
||||||
# If you're going to take these API keys and abuse it, you should really reconsider your life priorities
|
# If you're going to take these API keys and abuse it, you should really reconsider your life priorities
|
||||||
|
|
||||||
apiAV = 'O42ICUV58EIZZQMU'
|
apiAV = 'O42ICUV58EIZZQMU'
|
||||||
#apiBarchart = 'a17fab99a1c21cd6f847e2f82b592838' # 150 getHistory queries per day
|
#apiBarchart = 'a17fab99a1c21cd6f847e2f82b592838' # 150 getHistory queries per day
|
||||||
apiBarchart = 'f40b136c6dc4451f9136bb53b9e70ffa'
|
apiBarchart = 'f40b136c6dc4451f9136bb53b9e70ffa'
|
||||||
apiTiingo = '2e72b53f2ab4f5f4724c5c1e4d5d4ac0af3f7ca8'
|
apiTiingo = '2e72b53f2ab4f5f4724c5c1e4d5d4ac0af3f7ca8'
|
||||||
|
apiTradier = 'n26IFFpkOFRVsB5SNTVNXicE5MPD'
|
||||||
'''
|
'''
|
||||||
Monthly Bandwidth = 5 GB
|
Monthly Bandwidth = 5 GB
|
||||||
Hourly Requests = 500
|
Hourly Requests = 500
|
||||||
@ -451,9 +453,9 @@ class Stock:
|
|||||||
return
|
return
|
||||||
|
|
||||||
listOfFirstLastDates = []
|
listOfFirstLastDates = []
|
||||||
|
self.allLists = []
|
||||||
|
|
||||||
# IEX
|
# IEX
|
||||||
|
|
||||||
print("\nIEX")
|
print("\nIEX")
|
||||||
listIEX = Stock.getIEX(self)
|
listIEX = Stock.getIEX(self)
|
||||||
#print(listIEX)
|
#print(listIEX)
|
||||||
@ -481,9 +483,9 @@ class Stock:
|
|||||||
|
|
||||||
#print(self.allLists)
|
#print(self.allLists)
|
||||||
#print(listOfFirstLastDates)
|
#print(listOfFirstLastDates)
|
||||||
|
if (len(self.allLists) > 0):
|
||||||
print("\n")
|
print("\n")
|
||||||
print(len(self.allLists), "available sources for", self.name)
|
print(len(self.allLists), "available sources for", self.name)
|
||||||
if (len(self.allLists) > 0):
|
|
||||||
self.absFirstLastDates = Stock.getFirstLastDate(self, listOfFirstLastDates)
|
self.absFirstLastDates = Stock.getFirstLastDate(self, listOfFirstLastDates)
|
||||||
print("\nThe absolute first date with close values is:", self.absFirstLastDates[0])
|
print("\nThe absolute first date with close values is:", self.absFirstLastDates[0])
|
||||||
print("The absolute last date with close values is:", self.absFirstLastDates[1])
|
print("The absolute last date with close values is:", self.absFirstLastDates[1])
|
||||||
@ -501,7 +503,7 @@ class Stock:
|
|||||||
print("No sources have data for", self.name)
|
print("No sources have data for", self.name)
|
||||||
|
|
||||||
def main(): # For testing purposes
|
def main(): # For testing purposes
|
||||||
stockName = 'IWV'
|
stockName = 'spy'
|
||||||
stock1 = Stock(stockName)
|
stock1 = Stock(stockName)
|
||||||
print("Finding available dates and close values for", stock1.name)
|
print("Finding available dates and close values for", stock1.name)
|
||||||
Stock.main(stock1)
|
Stock.main(stock1)
|
||||||
|
54
listGoogle.py
Normal file
54
listGoogle.py
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
# https://support.google.com/docs/answer/3093281?hl=en
|
||||||
|
# Historical data cannot be downloaded or accessed via the Sheets API or Apps Script. If you attempt to do so, you will see a #N/A error in place of the values in the corresponding cells of your spreadsheet.
|
||||||
|
|
||||||
|
import gspread, time, webbrowser, msvcrt
|
||||||
|
from oauth2client.service_account import ServiceAccountCredentials
|
||||||
|
|
||||||
|
def main():
|
||||||
|
scope = ['https://spreadsheets.google.com/feeds',
|
||||||
|
'https://www.googleapis.com/auth/drive']
|
||||||
|
|
||||||
|
credentials = ServiceAccountCredentials.from_json_keyfile_name('creds.json', scope)
|
||||||
|
|
||||||
|
gc = gspread.authorize(credentials)
|
||||||
|
'''
|
||||||
|
# Just by ID:
|
||||||
|
#sheet = gc.open_by_key('1YS8qBQCXKNfSgQgXeUdSGOd6lM2wm-inV0_1YE36vQM')
|
||||||
|
sheet = gc.open_by_url('https://docs.google.com/spreadsheets/d/1YS8qBQCXKNfSgQgXeUdSGOd6lM2wm-inV0_1YE36vQM')
|
||||||
|
worksheet = sheet.get_worksheet(0)
|
||||||
|
worksheet.update_acell('B1', 'bingo!')
|
||||||
|
#worksheet.update_cell(1, 2, 'Bingo!')
|
||||||
|
val = worksheet.acell('B1').value
|
||||||
|
#val = worksheet.cell(1, 2).value
|
||||||
|
print(val)
|
||||||
|
'''
|
||||||
|
url = 'https://docs.google.com/spreadsheets/d/1YS8qBQCXKNfSgQgXeUdSGOd6lM2wm-inV0_1YE36vQM'
|
||||||
|
surl = 'https://www.andrewkdinh.com/u/listGoogle'
|
||||||
|
print("Opening", url)
|
||||||
|
#webbrowser.open(surl)
|
||||||
|
sheet = gc.open_by_url(url)
|
||||||
|
worksheet = sheet.get_worksheet(0)
|
||||||
|
print('Writing Google Finance function to A1')
|
||||||
|
worksheet.update_cell(1, 1, '=GOOGLEFINANCE("GOOG", "price", DATE(2014,1,1), DATE(2014,12,31), "DAILY")')
|
||||||
|
print('\nOpening link to the Google Sheet. Please download the file as comma-separated values (.csv) and move it to the directory of this Python file',
|
||||||
|
'\nFile > Download as > Comma-separated values(.csv,currentsheet)')
|
||||||
|
print("If the link did not open, please go to", surl)
|
||||||
|
print("Press any key to continue")
|
||||||
|
#time.sleep(45)
|
||||||
|
'''
|
||||||
|
for i in range(60, 0, -1):
|
||||||
|
print(i, end='\r')
|
||||||
|
time.sleep(1)
|
||||||
|
'''
|
||||||
|
waiting = True
|
||||||
|
while waiting == True:
|
||||||
|
if msvcrt.kbhit():
|
||||||
|
waiting = False
|
||||||
|
|
||||||
|
print("e")
|
||||||
|
|
||||||
|
#val = worksheet.acell('A1').value
|
||||||
|
#print(val)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
6
main.py
6
main.py
@ -25,12 +25,16 @@ for i in range(0, numberOfStocks, 1):
|
|||||||
listOfStocks.append(i)
|
listOfStocks.append(i)
|
||||||
listOfStocks[i] = Stock()
|
listOfStocks[i] = Stock()
|
||||||
listOfStocks[i].setName(stockName)
|
listOfStocks[i].setName(stockName)
|
||||||
print(listOfStocks[i].name)
|
#print(listOfStocks[i].name)
|
||||||
|
|
||||||
for i in range(0, numberOfStocks, 1):
|
for i in range(0, numberOfStocks, 1):
|
||||||
print("\n")
|
print("\n")
|
||||||
print(listOfStocks[i].name)
|
print(listOfStocks[i].name)
|
||||||
Stock.main(listOfStocks[i])
|
Stock.main(listOfStocks[i])
|
||||||
|
|
||||||
|
#print(listOfStocks[0].name, listOfStocks[0].absFirstLastDates, listOfStocks[0].finalDatesAndClose)
|
||||||
|
print("\nWhich indicator would you like to look at? \n1. Expense Ratio")
|
||||||
|
indicator = str(input)
|
||||||
'''
|
'''
|
||||||
stockName = 'IWV'
|
stockName = 'IWV'
|
||||||
stock1 = Stock(stockName)
|
stock1 = Stock(stockName)
|
||||||
|
Loading…
Reference in New Issue
Block a user