Welcome to the Forum

Creating an account is currently only possible via registration at SimFin.

Duplicated indicators values from SimFin API

Hello!

First of all, I wanted to say that I love what you are doing here, it's a great idea and I think it will help a lot of people :)
I'm trying to use the API for retrieving the P/E ratio of all the companies in the last 5 trailing years.

My request looks like this:

URL: https://simfin.com/api/v1/finder?api-key=[MY_API_KEY]

Request body (for simplicity let's take only 3 trailing years instead of 5):
{
"search":[
{
"indicatorId":"4-14",
"meta":{
"id":6,
"value":"ttm",
"operator":"eq"
},
"condition":null
},
{
"indicatorId":"4-14",
"meta":{
"id":6,
"value":"ttm-1",
"operator":"eq"
},
"condition":null
},
{
"indicatorId":"4-14",
"meta":{
"id":6,
"value":"ttm-2",
"operator":"eq"
},
"condition":null
}
],
"resultsPerPage":0
}


The response looks like this:

"results": [
{
"simId": 668481,
"name": "GARDNER DENVER INC",
"values": [
{
"indicatorId": "4-14",
"value": 5356.86
},
{
"indicatorId": "4-14",
"value": 5356.86
},
{
"indicatorId": "4-14",
"value": 5356.86
},
...

And it repeats the same way for each one of the companies.
As you can see, my problem is that the response contains the same P/E ratio value over the years, while I was expecting different value in each year.

Am I doing something wrong?
Anything to change in my request to get the right result?

Thanks in advance

Comments

  • Hi yarden,

    P/E is one of a few ratios for which we don't calculate historical figures yet unfortunately, one of the reasons being that it's not totally obvious which historical price to use. If you have a good suggestion how to solve this please let me know (i.e. which price to take). It's on the to-do list though to find a solution here and implement it.
  • I'm not a professional, but as an amateur investor I would calculate a historical P/E ratio by myself as follows:

    Calculate the EPS- usually calculated according to a period of 4 quarters
    (for "ttm" take the last 4 quarters, for "ttm-1" take the preceding 4 quarters and so on)

    Calculate the stock price per share- corresponds to the price at the last day/quarter of the earnings period
    (for "ttm" take the price at the last day of the last quarter, for "ttm-1" take the price at the last day of the quarter that was 4 quarters ago and so on)

    then, divide stock price by EPS to get the P/E
  • Yes EPS is available historically already, that is not a problem.

    The question is really what share price to take, "price at the last day/quarter of the earnings period" is one possibility for sure, but also a bit random (I've also heard beginning of the period for example), and the end of period share price is also a bit tricky because it's a price that doesn't reflect the actual earnings of that period (but maybe that's also wanted?), since the earnings are published a bit later than at the exact end of the reporting period.
  • Hmm that's interesting.. never thought of it that way
    Maybe if there was an indicator for the price per share with historical data, you could leave the choice of how to calculate the P/E to the user

    I guess the closest indicator to that right now is the "Market Capitalisation" (4-11) but I don't know the number of shares to divide it by + there is no historical data of it.

    By the way, I tried to retrieve historical data on the EPS indicator and it also gave me duplicated values (tried indicators 4-12, 4-13)
  • edited January 14
    I think the best way to calculate historical P/E ratios yourself is to just take the historical EPS (which should work, see code below) and then see for yourself what share price you want to take

    For indicator 4-12 and Apple this code should give you historical EPS for the periods TTM, TTM-1 and TTM-2:
    import requests

    data = {
    "search": [
    {
    "indicatorId": "4-12",
    "meta": [
    {
    "id": 6,
    "value": "TTM",
    "operator": "eq"
    },
    ],
    },
    {
    "indicatorId": "4-12",
    "meta": [
    {
    "id": 6,
    "value": "TTM-1",
    "operator": "eq"
    },
    ],
    },
    {
    "indicatorId": "4-12",
    "meta": [
    {
    "id": 6,
    "value": "TTM-2",
    "operator": "eq"
    },
    ],
    }
    ],
    "simIdList": [
    111052
    ]
    }

    r = requests.post('https://simfin.com/api/v1/finder?api-key=YOUR_API_KEY', json=data)
    print(r.content)
  • Thanks for the code example, it helped me fix my problem with retrieving the EPS values. I found out that my request was missing square brackets [] in the "meta" field.
Sign In to comment.