In context of simple linear regression, “slope” refers to the steepness or incline of a straight line that best fits a set of data points. It’s a measure of how much the dependent variable (often denoted as “y”) changes for a unit change in the independent variable (usually denoted as “x”). In other words, the slope on technical indicator represents the rate of change of “y” concerning “x.”
The slope as a technical indicator is a crucial parameter in linear regression, because it helps us understand how a change in the independent variable affects the dependent variable. If the slope is positive, it indicates a positive relationship, meaning that as “x” increases, “y” also increases. If the slope is negative, it suggests a negative relationship, where an increase in “x” leads to a decrease in “y.”
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 Slope function of the Technical Indicators API you can find on our documentation web-page.
Accessing the EODHD API
To access the EODHD 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")
Please note that you can also specify the API key in a configuration file or as an environment variable, as 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 Slope as a part of Technical Indicators API
After we are done with the API client, we can start to request Slope on Technical Indicator API.
resp = api.get_technical_indicator_data(ticker = "AAPL.US", function = "slope")
The API response will be a single JSON structure.
Converting JSON Response to DataFrame
To convert JSON to DataFrame, it is possible to use:
slope = pd.DataFrame(resp)
All data in the DataFrame will contain information such as date and slope for the stock symbol which was used when we called the API, (“AAPL.US” in the example)
Extended parameters of the Slope function from the Technical Indicators API
For a more accurate research, it is possible to use the additional “period” parameter of the Slope function.
Period is the number of data points used to calculate each weighted moving average value. The valid range is from 2 to 100000 with 50 as the default value.
slope_extended = api.get_technical_indicator_data(ticker = "AAPL.US", function = "slope", period = 100)
The API response is a JSON array containing data for all the requested tickers. You can convert the resulting JSON array to a DataFrame for further analysis:
sl_e = pd.DataFrame(slope)
To explore and analyze the slope parameter further, you can utilize the Technical Indicators API provided by EODHD. Ensure you have the necessary libraries installed before working with the API, and detailed information on using the slope parameter can be found in our documentation.
By accessing the EODHD API and using the “APIClient” class, you can easily request slope data for specific stock symbols. The resulting JSON response can be converted into a DataFrame for comprehensive analysis.
The slope is a valuable tool for understanding relationships in data. By leveraging the Technical Indicator API, you can explore this parameter to gain valuable insights into your chosen stocks.