14
14
from pandas_datareader .yahoo .options import Options as YahooOptions
15
15
from pandas_datareader .google .options import Options as GoogleOptions
16
16
17
- from pandas_datareader .iex .stats import DailySummaryReader as IEXHistorical
18
- from pandas_datareader .iex .stats import MonthlySummaryReader as IEXMonthSummary
19
17
from pandas_datareader .iex .deep import Deep as IEXDeep
20
- from pandas_datareader .iex .stats import RecentReader as IEXRecents
21
- from pandas_datareader .iex .stats import RecordsReader as IEXRecords
22
- from pandas_datareader .iex .market import MarketReader as IEXMarkets
23
18
from pandas_datareader .iex .tops import LastReader as IEXLasts
24
19
from pandas_datareader .iex .tops import TopsReader as IEXTops
25
- from pandas_datareader .iex .ref import SymbolsReader as IEXSymbols
26
20
27
21
from pandas_datareader .eurostat import EurostatReader
28
22
from pandas_datareader .fred import FredReader
@@ -75,31 +69,118 @@ def get_last_iex(*args, **kwargs):
75
69
76
70
77
71
def get_markets_iex (* args , ** kwargs ):
78
- return IEXMarkets (* args , ** kwargs ).read ()
72
+ """
73
+ Returns near-real time volume data across markets segregated by tape
74
+ and including a percentage of overall volume during the session
75
+
76
+ This endpoint does not accept any parameters.
77
+
78
+ Reference: https://www.iextrading.com/developer/docs/#markets
79
+
80
+ :return: DataFrame
81
+ """
82
+ from pandas_datareader .iex .market import MarketReader
83
+ return MarketReader (* args , ** kwargs ).read ()
79
84
80
85
81
- def get_data_iex (* args , ** kwargs ):
82
- return IEXHistorical (* args , ** kwargs ).read ()
86
+ def get_dailysummary_iex (* args , ** kwargs ):
87
+ """
88
+ Returns a summary of daily market volume statistics. Without parameters,
89
+ this will return the most recent trading session by default.
90
+
91
+ :param start:
92
+ A datetime object - the beginning of the date range.
93
+ :param end:
94
+ A datetime object - the end of the date range.
95
+
96
+ Reference: https://www.iextrading.com/developer/docs/#historical-daily
97
+
98
+ :return: DataFrame
99
+ """
100
+ from pandas_datareader .iex .stats import DailySummaryReader
101
+ return DailySummaryReader (* args , ** kwargs ).read ()
83
102
84
103
85
104
def get_summary_iex (* args , ** kwargs ):
86
- return IEXMonthSummary (* args , ** kwargs ).read ()
105
+ """
106
+ Returns an aggregated monthly summary of market volume and a variety of
107
+ related metrics for trades by lot size, security market cap, and venue.
108
+ In the absence of parameters, this will return month-to-date statistics.
109
+ For ranges spanning multiple months, this will return one row per month.
110
+
111
+ :param start:
112
+ A datetime object - the beginning of the date range.
113
+ :param end:
114
+ A datetime object - the end of the date range.
115
+
116
+ :return: DataFrame
117
+ """
118
+ from pandas_datareader .iex .stats import MonthlySummaryReader
119
+ return MonthlySummaryReader (* args , ** kwargs ).read ()
87
120
88
121
89
122
def get_records_iex (* args , ** kwargs ):
90
- return IEXRecords (* args , ** kwargs ).read ()
123
+ """
124
+ Returns the record value, record date, recent value, and 30-day average for
125
+ market volume, # of symbols traded, # of routed trades and notional value.
126
+ This function accepts no additional parameters.
127
+
128
+ Reference: https://www.iextrading.com/developer/docs/#records
129
+
130
+ :return: DataFrame
131
+ """
132
+ from pandas_datareader .iex .stats import RecordsReader
133
+ return RecordsReader (* args , ** kwargs ).read ()
91
134
92
135
93
136
def get_recent_iex (* args , ** kwargs ):
94
- return IEXRecents (* args , ** kwargs ).read ()
137
+ """
138
+ Returns market volume and trade routing statistics for recent sessions.
139
+ Also reports IEX's relative market share, lit share volume and a boolean
140
+ halfday indicator.
141
+
142
+ Reference: https://www.iextrading.com/developer/docs/#recent
143
+
144
+ :return: DataFrame
145
+ """
146
+ from pandas_datareader .iex .stats import RecentReader
147
+ return RecentReader (* args , ** kwargs ).read ()
95
148
96
149
97
150
def get_iex_symbols (* args , ** kwargs ):
98
- return IEXSymbols (* args , ** kwargs ).read ()
151
+ """
152
+ Returns a list of all equity symbols available for trading on IEX. Accepts
153
+ no additional parameters.
154
+
155
+ Reference: https://www.iextrading.com/developer/docs/#symbols
156
+
157
+ :return: DataFrame
158
+ """
159
+ from pandas_datareader .iex .ref import SymbolsReader
160
+ return SymbolsReader (* args , ** kwargs ).read ()
99
161
100
162
101
163
def get_iex_book (* args , ** kwargs ):
102
- return IEXDeep (* args , ** kwargs ).read ()
164
+ """
165
+ Returns an array of dictionaries with depth of book data from IEX for up to
166
+ 10 securities at a time. Returns a dictionary of the bid and ask books.
167
+
168
+ :param symbols:
169
+ A string or list of strings of valid tickers
170
+ :param service:
171
+ 'book': Live depth of book data
172
+ 'op-halt-status': Checks to see if the exchange has instituted a halt
173
+ 'security-event': Denotes individual security related event
174
+ 'ssr-status': Short Sale Price Test restrictions, per reg 201 of SHO
175
+ 'system-event': Relays current feed status (i.e. market open)
176
+ 'trades': Retrieves recent executions, trade size/price and flags
177
+ 'trade-breaks': Lists execution breaks for the current trading session
178
+ 'trading-status': Returns status and cause codes for securities
179
+
180
+ :return: Object
181
+ """
182
+ from pandas_datareader .iex .deep import Deep
183
+ return Deep (* args , ** kwargs ).read ()
103
184
104
185
105
186
def DataReader (name , data_source = None , start = None , end = None ,
@@ -129,7 +210,9 @@ def DataReader(name, data_source=None, start=None, end=None,
129
210
single value given for symbol, represents the pause between retries.
130
211
session : Session, default None
131
212
requests.sessions.Session instance to be used
132
-
213
+ access_key : (str, None)
214
+ Optional parameter to specify an API key for certain data sources.
215
+
133
216
Examples
134
217
----------
135
218
@@ -142,7 +225,14 @@ def DataReader(name, data_source=None, start=None, end=None,
142
225
143
226
# Data from Google Finance
144
227
aapl = DataReader("AAPL", "google")
145
-
228
+
229
+ # Price and volume data from IEX
230
+ tops = DataReader(["GS", "AAPL"], "iex-tops")
231
+ # Top of book executions from IEX
232
+ gs = DataReader("GS", "iex-last")
233
+ # Real-time depth of book data from IEX
234
+ gs = DataReader("GS", "iex-book")
235
+
146
236
# Data from FRED
147
237
vix = DataReader("VIXCLS", "fred")
148
238
@@ -166,6 +256,7 @@ def DataReader(name, data_source=None, start=None, end=None,
166
256
return YahooActionReader (symbols = name , start = start , end = end ,
167
257
retry_count = retry_count , pause = pause ,
168
258
session = session ).read ()
259
+
169
260
elif data_source == "yahoo-dividends" :
170
261
return YahooDailyReader (symbols = name , start = start , end = end ,
171
262
adjust_price = False , chunksize = 25 ,
@@ -209,25 +300,30 @@ def DataReader(name, data_source=None, start=None, end=None,
209
300
return OECDReader (symbols = name , start = start , end = end ,
210
301
retry_count = retry_count , pause = pause ,
211
302
session = session ).read ()
303
+
212
304
elif data_source == "eurostat" :
213
305
return EurostatReader (symbols = name , start = start , end = end ,
214
306
retry_count = retry_count , pause = pause ,
215
307
session = session ).read ()
308
+
216
309
elif data_source == "edgar-index" :
217
310
return EdgarIndexReader (symbols = name , start = start , end = end ,
218
311
retry_count = retry_count , pause = pause ,
219
312
session = session ).read ()
313
+
220
314
elif data_source == "oanda" :
221
315
return get_oanda_currency_historical_rates (
222
316
start , end ,
223
317
quote_currency = "USD" , base_currency = name ,
224
318
reversed = True , session = session
225
319
)
320
+
226
321
elif data_source == 'nasdaq' :
227
322
if name != 'symbols' :
228
323
raise ValueError ("Only the string 'symbols' is supported for "
229
324
"Nasdaq, not %r" % (name ,))
230
325
return get_nasdaq_symbols (retry_count = retry_count , pause = pause )
326
+
231
327
else :
232
328
msg = "data_source=%r is not implemented" % data_source
233
329
raise NotImplementedError (msg )
0 commit comments