This repository has been archived by the owner on Jan 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Michael Hartmann
authored and
Michael Hartmann
committed
Mar 3, 2019
0 parents
commit 5ec3bdb
Showing
3 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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')) |