yfinance icon indicating copy to clipboard operation
yfinance copied to clipboard

Setting custom User Agent for multiple ticker downloads

Open olearyw opened this issue 3 years ago • 3 comments

I'm trying to set as custom user agent header for fetching multiple tickers.

Does anyone know if this is available or will be available in the near future?

Regards,

olearyw avatar Apr 27 '21 04:04 olearyw

Not supported by the looks of it.

https://github.com/ranaroussi/yfinance/blob/main/yfinance/multi.py#L179

Just need to pass the session object down there so shouldn't be too hard to implement this.

dkoleary88 avatar Apr 27 '21 06:04 dkoleary88

Seems it is supported by modifying requests object, library methods have parameter named session which takes requests object. Sample code is on ReadMe file or here

jemshit avatar May 05 '21 10:05 jemshit

This could be implemented easily with e.g. yf.set_custom_header(...), storing internally in a global variable for use later. Or maybe there is a better way

If someone implements and submits a good PR, I can merge.

ValueRaider avatar Jan 06 '23 15:01 ValueRaider