Skip to content

Commit b4cbf4c

Browse files
authored
Merge pull request #41 from EodHistoricalData/dev
Dev
2 parents 790c0f8 + 14389ac commit b4cbf4c

4 files changed

Lines changed: 85 additions & 8 deletions

File tree

eodhd/APIs/TechnicalIndicatorAPI.py

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ class TechnicalIndicatorAPI(BaseAPI):
1010

1111
def get_technical_indicator_data(self, api_token: str, ticker: str, function: str, period: int = 50,
1212
date_from: str = None, date_to: str = None, order: str = 'a',
13-
splitadjusted_only: str = '0'):
13+
splitadjusted_only: str = '0', agg_period = None,
14+
fast_kperiod = None, slow_kperiod = None, slow_dperiod = None,
15+
fast_dperiod = None, fast_period = None, slow_period = None,
16+
signal_period = None, acceleration = None, maximum = None):
1417
endpoint = 'technical/'
1518

1619
if ticker.strip() == "" or ticker is None:
@@ -29,6 +32,41 @@ def get_technical_indicator_data(self, api_token: str, ticker: str, function: st
2932
if date_from is not None:
3033
query_string += "&from=" + date_from
3134

35+
if function == 'splitadjusted':
36+
possible_agg_period = ['d', 'w', 'm']
37+
if agg_period is not None:
38+
if agg_period not in possible_agg_period:
39+
raise ValueError("agg_period must be in ['d', 'w', 'm']")
40+
query_string += "&agg_period=" + agg_period
41+
42+
if function == 'stochastic':
43+
if fast_kperiod is not None:
44+
query_string += "&fast_kperiod=" + fast_kperiod
45+
if slow_kperiod is not None:
46+
query_string += "&slow_kperiod=" + slow_kperiod
47+
if slow_dperiod is not None:
48+
query_string += "&slow_dperiod=" + slow_dperiod
49+
50+
if function == 'stochrsi':
51+
if fast_kperiod is not None:
52+
query_string += "&fast_kperiod=" + fast_kperiod
53+
if fast_dperiod is not None:
54+
query_string += "&fast_dperiod=" + fast_dperiod
55+
56+
if function == 'macd':
57+
if fast_period is not None:
58+
query_string += "&fast_period=" + fast_period
59+
if slow_period is not None:
60+
query_string += "&slow_period=" + slow_period
61+
if signal_period is not None:
62+
query_string += "&signal_period=" + signal_period
63+
64+
if function == 'sar':
65+
if acceleration is not None:
66+
query_string += "&acceleration=" + acceleration
67+
if maximum is not None:
68+
query_string += "&maximum=" + maximum
69+
3270
return self._rest_get_method(api_key = api_token, endpoint = endpoint, uri = ticker, querystring = query_string)
3371

3472

eodhd/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88

99

1010
# Version of eodhd package
11-
__version__ = "1.0.25"
11+
__version__ = "1.0.26"

eodhd/apiclient.py

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,16 @@ def get_technical_indicator_data(
457457
date_to: str = None,
458458
order: str = "a",
459459
splitadjusted_only: str = "0",
460+
agg_period: str = None,
461+
fast_kperiod: int = None,
462+
slow_kperiod: int = None,
463+
slow_dperiod: int = None,
464+
fast_dperiod: int = None,
465+
fast_period: int = None,
466+
slow_period: int = None,
467+
signal_period: int = None,
468+
acceleration: float = None,
469+
maximum: float = None
460470
) -> list:
461471
"""Available args:
462472
ticker (required) - consists of two parts: [SYMBOL_NAME].[EXCHANGE_ID]. Example: AAPL.US
@@ -467,16 +477,35 @@ def get_technical_indicator_data(
467477
'cci', 'sar', 'bbands', 'format_amibroker', 'splitadjusted']
468478
Description for possible functions you get here:
469479
https://eodhistoricaldata.com/financial-apis/technical-indicators-api/
470-
period the number of data points used to calculate each moving average value.
471-
Valid range from 2 to 100000 with the default value 50.
480+
period - the number of data points used to calculate each moving average value.
481+
Valid range from 2 to 100000 with the default value - 50.
472482
date_from (not required) - date from with format Y-m-d. Example: 2000-01-01
473483
date_to (not required) - date from with format Y-m-d. Example: 2000-01-01
474-
order use ‘a’ for ascending dates (from old to new) and ‘d’ for descending dates (from new to old).
484+
order - use 'a' for ascending dates (from old to new) and 'd' for descending dates (from new to old).
475485
By default, dates are shown in ascending order.
476-
splitadjusted_only default value is ‘0’.
486+
splitadjusted_only - default value is '0'.
477487
By default, we calculate data for some functions by closes adjusted with splits and dividends.
478-
If you need to calculate the data by closes adjusted only with splits, set this parameter to ‘1’.
488+
If you need to calculate the data by closes adjusted only with splits, set this parameter to '1'.
479489
Works with the following functions: sma, ema, wma, volatility, rsi, slope, and macd.
490+
491+
For some functions can be used additional parameters:
492+
1. For splitadjusted:
493+
agg_period [optional] – aggregation period. Default value – 'd'. Possible values: d – daily, w – weekly, m – monthly.
494+
2. For stochastic:
495+
fast_kperiod [optional] – Fast K-period, the default value is 14. Valid range from 2 to 100000.
496+
slow_kperiod [optional] – Slow K-period, the default value is 3. Valid range from 2 to 100000.
497+
slow_dperiod [optional] – Slow D-period, the default value is 3. Valid range from 2 to 100000.
498+
3. For stochrsi:
499+
fast_kperiod [optional] – Fast K-period, the default value is 14. Valid range from 2 to 100000.
500+
fast_dperiod [optional] – Fast D-period, the default value is 14. Valid range from 2 to 100000.
501+
4. For macd:
502+
fast_period [optional] – the default value is 12. Valid range from 2 to 100000.
503+
slow_period [optional] – the default value is 26. Valid range from 2 to 100000.
504+
signal_period [optional] – the default value is 9. Valid range from 2 to 100000.
505+
5. For sar:
506+
acceleration [optional] – Acceleration Factor used up to the Maximum value. Default value – 0.02.
507+
maximum [optional] – Acceleration Factor Maximum value. Default value – 0.20.
508+
For those functions use this parameters to set periods.
480509
"""
481510

482511
api_call = TechnicalIndicatorAPI()
@@ -489,6 +518,16 @@ def get_technical_indicator_data(
489518
date_to=date_to,
490519
order=order,
491520
splitadjusted_only=splitadjusted_only,
521+
agg_period=agg_period,
522+
fast_kperiod=fast_kperiod,
523+
slow_kperiod=slow_kperiod,
524+
slow_dperiod=slow_dperiod,
525+
fast_dperiod=fast_dperiod,
526+
fast_period=fast_period,
527+
slow_period=slow_period,
528+
signal_period=signal_period,
529+
acceleration=acceleration,
530+
maximum=maximum
492531
)
493532

494533
def get_live_stock_prices(self, ticker, date_to=None, date_from=None, s=None) -> list:

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# This call to setup() does all the work
1717
setup(
1818
name="eodhd",
19-
version="1.0.25",
19+
version="1.0.26",
2020
description="Official EODHD API Python Library",
2121
long_description=long_description,
2222
long_description_content_type="text/markdown",

0 commit comments

Comments
 (0)