Skip to content

Commit

Permalink
Merge pull request #2313 from ranaroussi/main
Browse files Browse the repository at this point in the history
sync main -> dev
  • Loading branch information
ValueRaider authored Feb 22, 2025
2 parents d40ad62 + 403607c commit f2a8d01
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 3 deletions.
21 changes: 21 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
Change Log
===========

0.2.54
------
Hotfix user-agent #2277

0.2.53
------
Fixes:
- Fix: Failed to parse holders JSON data #2234
- Fix: Bad data in Holders #2244
- Stop CSRF-cookie-fetch fail killing yfinance #2249
- Fix Market Docs #2250
- Fix: Broken "See also" links in documentation #2253
- Fix: Interval check and error message formatting in multi.py #2256
Improve:
- Add pre- / post-stock prices (and other useful information) #2212
- Warn user when use download() without specifying auto_adjust #2230
- Refactor: Earnings Dates – Switch to API Fetching #2247
- Improve prices div repair #2260
Maintenance:
- Add GitHub Actions workflow and fix failing tests #2233

0.2.52
------
Features:
Expand Down
2 changes: 1 addition & 1 deletion meta.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% set name = "yfinance" %}
{% set version = "0.2.52" %}
{% set version = "0.2.54" %}

package:
name: "{{ name|lower }}"
Expand Down
18 changes: 18 additions & 0 deletions yfinance/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -624,3 +624,21 @@ def merge_two_level_dicts(dict1, dict2):
"highest_controversy"}
}
EQUITY_SCREENER_FIELDS = merge_two_level_dicts(EQUITY_SCREENER_FIELDS, COMMON_SCREENER_FIELDS)

USER_AGENTS = [
# Chrome
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36",
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36",
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36",

# Firefox
"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:135.0) Gecko/20100101 Firefox/135.0",
"Mozilla/5.0 (Macintosh; Intel Mac OS X 14.7; rv:135.0) Gecko/20100101 Firefox/135.0",
"Mozilla/5.0 (X11; Linux i686; rv:135.0) Gecko/20100101 Firefox/135.0",

# Safari
"Mozilla/5.0 (Macintosh; Intel Mac OS X 14_7_4) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.3 Safari/605.1.15",

# Edge
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36 Edg/131.0.2903.86"
]
5 changes: 4 additions & 1 deletion yfinance/data.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import functools
import random
from functools import lru_cache

import requests as requests
Expand All @@ -10,6 +11,7 @@
from . import utils, cache
import threading

from .const import USER_AGENTS
from .exceptions import YFRateLimitError

cache_maxsize = 64
Expand Down Expand Up @@ -59,7 +61,8 @@ class YfData(metaclass=SingletonMeta):
Singleton means one session one cookie shared by all threads.
"""
user_agent_headers = {
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36'}
'User-Agent': random.choice(USER_AGENTS)
}

def __init__(self, session=None):
self._crumb = None
Expand Down
2 changes: 1 addition & 1 deletion yfinance/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version = "0.2.52"
version = "0.2.54"

0 comments on commit f2a8d01

Please sign in to comment.