burakyilmaz321 / tefas-crawler

A Python library for crawling public data from Tefas.
MIT License
75 stars 21 forks source link

Optional Fund Profit Comparison Endpoint Support #20

Open okankonur opened 7 months ago

okankonur commented 7 months ago

Hi, maybe support for fund returns comparison page can be added.

Post data sample:

        url=f"https://fundturkey.com.tr/api/DB/BindComparisonFundReturns",
        data= {
            "calismatipi": 1,
            "fontip": "YAT",
            "bastarih": "14.01.2024",
            "bittarih": "16.01.2024",
            "islemdurum": 1  
        }

Response sample:

    {
        "FONKODU": "YUN",
        "FONUNVAN": "YAPI KRED\u0130 PORTF\u00d6Y \u0130ST\u0130NYE SERBEST (D\u00d6V\u0130Z) FON",
        "FONTURACIKLAMA": "Hedge Umbrella Fund",
        "GETIRIORANI": 0.2569
    },
    {
        "FONKODU": "YZK",
        "FONUNVAN": "YAPI KRED\u0130 PORTF\u00d6Y KALAMI\u015e SERBEST FON",
        "FONTURACIKLAMA": "Hedge Umbrella Fund",
        "GETIRIORANI": 0.0964
    }

OR

        url=f"https://fundturkey.com.tr/api/DB/BindComparisonFundReturns",
        data= {
            "calismatipi": 2,
            "fontip": "YAT",
            "strperiod": "1,1,0,1,1,0,0",
            "islemdurum": 1
        }
    {
        "FONKODU": "YJH",
        "FONUNVAN": "YAPI KRED\u0130 PORTF\u00d6Y TEM\u0130Z ENERJ\u0130 DE\u011e\u0130\u015eKEN FONU",
        "FONTURACIKLAMA": "Variable Umbrella Fund",
        "GETIRI1A": -2.2096,
        "GETIRI3A": 10.8607,
        "GETIRI6A": null,
        "GETIRI1Y": 19.2132,
        "GETIRIYB": -5.4741,
        "GETIRI3Y": null,
        "GETIRI5Y": null
    },
    {
        "FONKODU": "YPV",
        "FONUNVAN": "YAPI KRED\u0130 PORTF\u00d6Y \u00dc\u00c7\u00dcNC\u00dc FON SEPET\u0130 FONU",
        "FONTURACIKLAMA": "Fund Of Funds Umbrella Fund",
        "GETIRI1A": 0.7878,
        "GETIRI3A": 10.2034,
        "GETIRI6A": null,
        "GETIRI1Y": 53.4969,
        "GETIRIYB": 2.6137,
        "GETIRI3Y": null,
        "GETIRI5Y": null
    }

islemdurum denotes if the fund is traded in Tefas. Also I would really appreciate if there was a way to make the same distinction for the historical data endpoint.

burakyilmaz321 commented 7 months ago

Thanks for the idea 👍

I was thinking about this recently. I have some sketches on how to design this as a user friendly way.

I think there should be two things:

1) A method for getting the returns between two days. 2) A method for getting GETIRI1A, GETIRI3A, etc, for any given date.

Can you pass a date to this:

        url=f"https://fundturkey.com.tr/api/DB/BindComparisonFundReturns",
        data= {
            "calismatipi": 2,
            "fontip": "YAT",
            "strperiod": "1,1,0,1,1,0,0",
            "islemdurum": 1
        }
okankonur commented 7 months ago

Thanks for the response. As far as I tested, no. If you want to get returns for a given date range you use calismatipi=1 and it returns single GETIRIORANI value like the first example in the original post. If you want the returns for 1A, 3A, etc. you use calismatipi=2. Passing any date parameter like bastarih or bittarih does not seem to change the results. It calculates according to the current date.

I agree with you on the user friendly way. I think it would be cleaner to have this functionality with other fetch methods available to end user for choosing between given date or default periods.