Skip to content

Commit 55e0aff

Browse files
committed
Add include_today option to HistoricalReader
1 parent 64ee3af commit 55e0aff

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

docs/source/whatsnew/v0.5.1.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Enhancements
1212
- Re-added dropped ``date`` column in some calls (:issue:`238`)
1313
- Added support for `Crytpocurrency Book <https://iexcloud.io/docs/api/#cryptocurrency-book>`__ - ``iexfinance.crypto.get_crypto_book``
1414
- Added support for `Cryptocurrency Price <https://iexcloud.io/docs/api/#cryptocurrency-price>`__ - ``iexfinance.crypto.get_crypto_price``
15+
- Added `include_today` option for `HistoricalReader` and `get_historical_data`
1516

1617
Bug Fixes
1718
~~~~~~~~~

iexfinance/stocks/__init__.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
from iexfinance.utils.exceptions import ImmediateDeprecationError
1111

1212

13-
def get_historical_data(symbols, start=None, end=None, close_only=False, **kwargs):
13+
def get_historical_data(
14+
symbols, start=None, end=None, close_only=False, include_today=False, **kwargs
15+
):
1416
"""
1517
Function to obtain historical date for a symbol or list of
1618
symbols. Return an instance of HistoricalReader
@@ -30,6 +32,8 @@ def get_historical_data(symbols, start=None, end=None, close_only=False, **kwarg
3032
close_only: bool, default False
3133
Returns adjusted data only with keys ``date``, ``close``, and
3234
``volume``
35+
include_today: bool, default False
36+
Appends data from the current trading day
3337
kwargs:
3438
Additional Request Parameters (see base class)
3539
@@ -39,7 +43,12 @@ def get_historical_data(symbols, start=None, end=None, close_only=False, **kwarg
3943
Historical stock prices over date range, start to end
4044
"""
4145
return HistoricalReader(
42-
symbols, start=start, end=end, close_only=close_only, **kwargs
46+
symbols,
47+
start=start,
48+
end=end,
49+
close_only=close_only,
50+
include_today=include_today,
51+
**kwargs
4352
).fetch()
4453

4554

iexfinance/stocks/historical.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,19 @@ class HistoricalReader(Stock):
1414
Reference: https://iextrading.com/developer/docs/#chart
1515
"""
1616

17-
def __init__(self, symbols, start=None, end=None, close_only=False, **kwargs):
17+
def __init__(
18+
self,
19+
symbols,
20+
start=None,
21+
end=None,
22+
close_only=False,
23+
include_today=False,
24+
**kwargs
25+
):
1826
start = start or datetime.datetime.today() - datetime.timedelta(days=365)
1927
self.start, self.end = _sanitize_dates(start, end)
2028
self.close_only = close_only
29+
self.include_today = include_today
2130
super(HistoricalReader, self).__init__(symbols, **kwargs)
2231

2332
@property
@@ -58,6 +67,7 @@ def params(self):
5867
"range": self.chart_range,
5968
"chartByDay": self.single_day,
6069
"chartCloseOnly": self.close_only,
70+
"includeToday": self.include_today,
6171
}
6272
if self.single_day:
6373
try:

0 commit comments

Comments
 (0)