In finance, a Moving Average (MA) is a stock indicator commonly used in technical analysis:

Moving averages are used in calculations to analyze data points by creating a series of averages of different selections of the full data set. 

Register & Get Data

Please note: before continuing to work with our APIs, make sure that you import and install all required libraries. A more detailed information about the functions of SMA, WMA and EMA of the Technical Indicators API can be found on our documentation web-page.

Accessing the EODHD API

To access the API, we need to create an instance of the “APIClient” class and pass to it our API key. In this example, we will use the demo API key provided by EODHD, but in your real application, you should use your registered API key.

api = APIClient("demo")

You can also specify the API key in a configuration file as it described in the library documentation here.

1. Use the “DEMO” API key to test our data from a limited set of the tickers without registering:
AAPL.US | TSLA.US VTI.US | AMZN.US | BTC-USD | EUR-USD
Real-Time Data and All of the APIs (except Bulk) are included without limitations on API calls.
2. Register to get your free API key (limitated by 20 API calls per day) with access to:
End-Of-Day Historical Data with only past year for any ticker and List of tickers per Exchange.
3. To unlock your API key we recommend to choose subscription which covers your needs.

Exploring the WMA

Firstly, let`s try to request WMA data from the Technical Indicators API.

WMA is an average that has multiplying factors to give different weights to data at different positions in the sample window. 

The API response will be a single JSON structure.

To convert JSON to DataFrame, it is possible to use the following code. All data in the DataFrame will contain information such as date and the column corresponding to the parameter that you call in the function. All given information will be available for stock symbol, which was used when we called API, in particular (“AAPL.US”).

Exploring the EMA

Secondly, we will request EMA data from the Technical Indicators API.

EMA is a first-order infinite impulse response filter that applies weighting factors which decrease exponentially. The weights for older dates decrease exponentially, never reaching zero. 

The API response will be a single JSON structure.

To convert JSON to DataFrame, it is possible to use the following code. All data in the DataFrame will contain information such as date and the column corresponding to the parameter that you call in the function. All given information will be available for stock symbol, which was used when we called API, in particular (“AAPL.US”).

Exploring the SMA

The next step is to start requesting SMA data from the Technical Indicators API.

SMA is normally taken from an equal number of data on either side of a central value. This ensures that variations in the mean are aligned with the variations in the data rather than being shifted in time.

simple_ma = api.get_technical_indicator_data(ticker = "AAPL.US", function = "sma")

The API response will be a single JSON structure.

To convert JSON to DataFrame, it is possible to use the following code. All data in the DataFrame will contain information such as date and the column corresponding to the parameter that you call in the function. All given information will be available for stock symbol, which was used when we called API, in particular (“AAPL.US”).

sma = pd.DataFrame(simple_ma)
print(sma)

Extended parameters of SMA

For a more accurate research, it is possible to use parameters that lays in Moving Average functions. For all three function is available one parameter, named period. It is the number of data points used to calculate each simple moving average value. Valid range from 2 to 100000 with the default value – 50.

sma_extended = api.get_technical_indicator_data(ticker = "AAPL.US", function = "sma", period = 100)
sma_e = pd.DataFrame(sma_extended)
print(sma_e)

Conclusion

We’ve explored the essential concepts of SMA, WMA, and EMA as integral components of our Technical Indicators API. These moving averages provide unique methods of analyzing stock data, and we’ve discussed how to access and utilize this information. Now you have the flexibility to fine-tune your analysis for a more accurate research in the dynamic world of stock trading.

Register & Get Data

Do you enjoy our articles?

We can send new ones right to your email box