forked from hackingthemarkets/iex-cloud-dashboard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
iex.py
61 lines (41 loc) · 1.79 KB
/
iex.py
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import requests
class IEXStock:
def __init__(self, token, symbol, environment='production'):
if environment == 'production':
self.BASE_URL = 'https://cloud.iexapis.com/v1'
else:
self.BASE_URL = 'https://sandbox.iexapis.com/v1'
self.token = token
self.symbol = symbol
def get_logo(self):
url = f"{self.BASE_URL}/stock/{self.symbol}/logo?token={self.token}"
r = requests.get(url)
return r.json()
def get_company_info(self):
url = f"{self.BASE_URL}/stock/{self.symbol}/company?token={self.token}"
r = requests.get(url)
return r.json()
def get_company_news(self, last=10):
url = f"{self.BASE_URL}/stock/{self.symbol}/news/last/{last}?token={self.token}"
r = requests.get(url)
return r.json()
def get_stats(self):
url = f"{self.BASE_URL}/stock/{self.symbol}/advanced-stats?token={self.token}"
r = requests.get(url)
return r.json()
def get_fundamentals(self, period='quarterly', last=4):
url = f"{self.BASE_URL}/time-series/fundamentals/{self.symbol}/{period}?last={last}&token={self.token}"
r = requests.get(url)
return r.json()
def get_dividends(self, range='5y'):
url = f"{self.BASE_URL}/stock/{self.symbol}/dividends/{range}?token={self.token}"
r = requests.get(url)
return r.json()
def get_institutional_ownership(self):
url = f"{self.BASE_URL}/stock/{self.symbol}/institutional-ownership?token={self.token}"
r = requests.get(url)
return r.json()
def get_insider_transactions(self):
url = f"{self.BASE_URL}/stock/{self.symbol}/insider-transactions?token={self.token}"
r = requests.get(url)
return r.json()