Skip to content
This repository has been archived by the owner on Jan 17, 2024. It is now read-only.

Commit

Permalink
Initial commit to the empty repo
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Hartmann authored and Michael Hartmann committed Mar 3, 2019
0 parents commit 5ec3bdb
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#iexfinance-py

This is a minimal wrapper for the iex finance REST api
Empty file added __init__.py
Empty file.
44 changes: 44 additions & 0 deletions stock.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import requests
import os

IEXCLOUD_STOCK_BASE_URL = 'https://cloud.iexapis.com/beta/stock/'

def append_token(url):
token = os.getenv('IEX_TOKEN')
return "{}?token={}".format(url, token)


IEX_STOCK_CHART_URL = IEXCLOUD_STOCK_BASE_URL + '{ticker}/chart/{range}/{date}'
def chart(ticker, range, date="", format=None):
url = IEX_STOCK_CHART_URL.replace('{ticker}', ticker).replace('{range}', range).replace('{date}', date)
result = requests.get(append_token(url))
print(append_token(url))
print(result)
result = result.json()

if format == 'pandas':
# Do your pandas formatting here
pass

if format == 'numpy':
#do your numpy formatting here
pass

return result

IEX_STOCK_FINANCIALS_URL = IEXCLOUD_STOCK_BASE_URL + '{ticker}/financials?period={period}'
def financials(ticker, period, format=None):
url = IEX_STOCK_FINANCIALS_URL.replace("{ticker}", ticker).replace("{period}", period)
result = requests.get(append_token(url)).json()

if format == 'pandas':
# Do your pandas formatting here
pass

if format == 'numpy':
#do your numpy formatting here
pass

return result

print(chart('aapl', '5Y'))

0 comments on commit 5ec3bdb

Please sign in to comment.