atreadw1492 / yahoo_fin

Scrape stock price history from new (Spring 2017) Yahoo Finance layout
MIT License
286 stars 125 forks source link

get_earnings_history - multiple monthly data #47

Open dss010101 opened 3 years ago

dss010101 commented 3 years ago

Hi When i call get_earnings_history with interval='1mo', for the current month, i get two rows. i feel it should simply be the price up to the current date or maybe a parameter to indicate how to deal with that

2021-02-01 3731.169922 3950.429932 3725.620117 3811.149902 3811.149902 98596960000 ^GSPC 2021-03-01 3842.510010 3994.409912 3723.340088 3972.889893 3972.889893 120863560000 ^GSPC 2021-04-01 3992.780029 4218.779785 3992.780029 4181.169922 4181.169922 82869290000 ^GSPC 2021-05-01 4191.979980 4209.390137 4128.589844 4201.620117 4201.620117 17036160000 ^GSPC 2021-05-07 4210.339844 4236.720215 4201.640137 4228.870117 4228.870117 543666845 ^GSPC

This causes a problem if i want to see monthly performance to date for the last month. The following would yield an incorrect value for the current month - it should use current day's close along with previous months close.

    `df['ret_pct'] = df['close'].pct_change(1) * 100`