ivolatility-backtesting 2.138__tar.gz → 2.139__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ivolatility_backtesting
3
- Version: 2.138
3
+ Version: 2.139
4
4
  Summary: A universal backtesting framework for financial strategies using the IVolatility API.
5
5
  Author-email: IVolatility <support@ivolatility.com>
6
6
  Project-URL: Homepage, https://ivolatility.com
@@ -35,6 +35,34 @@ import seaborn as sns
35
35
  from datetime import datetime, timedelta
36
36
  import ivolatility as ivol # PATCHED: Session + connection pooling (~5x faster)
37
37
  import os
38
+
39
+
40
+ # Distinctive User-Agent on ALL REST traffic: lets the gateway/Graylog tell
41
+ # framework calls apart from hand-written scripts, and workspace runs from
42
+ # local pip installs (CODER_AGENT_URL is set inside Coder workspaces only).
43
+ def _ivb_user_agent():
44
+ try:
45
+ from importlib.metadata import version as _pkg_version
46
+ _ver = _pkg_version('ivolatility_backtesting')
47
+ except Exception:
48
+ _ver = 'dev'
49
+ _env = 'workspace' if os.getenv('CODER_AGENT_URL') else 'local'
50
+ try:
51
+ import requests as _rq
52
+ _rq_ver = _rq.__version__
53
+ except Exception:
54
+ _rq_ver = '?'
55
+ return f'ivolatility-backtesting/{_ver} ({_env}) python-requests/{_rq_ver}'
56
+
57
+
58
+ _IVB_UA = _ivb_user_agent()
59
+ try:
60
+ # _session lives in the ivolatility.ivolatility submodule; the top-level
61
+ # package does not re-export it (same lookup as _thread_safe_session)
62
+ _ivol_inner = getattr(ivol, 'ivolatility', ivol)
63
+ _ivol_inner._session.headers['User-Agent'] = _IVB_UA # SDK global session
64
+ except Exception:
65
+ pass
38
66
  import time
39
67
  import psutil
40
68
  import warnings
@@ -1690,6 +1718,7 @@ def _create_sdk_like_session():
1690
1718
  adapter = HTTPAdapter(pool_connections=10, pool_maxsize=10, max_retries=retry)
1691
1719
  s.mount("https://", adapter)
1692
1720
  s.mount("http://", adapter)
1721
+ s.headers['User-Agent'] = _IVB_UA
1693
1722
  return s
1694
1723
 
1695
1724
 
@@ -20904,7 +20933,7 @@ def _resolve_futures_underlying(symbol, region=None, mic=None,
20904
20933
  try:
20905
20934
  r = _requests.get(
20906
20935
  'https://restapi.ivolatility.com/futures/eod/fut-underlying-info',
20907
- params=params, timeout=60)
20936
+ params=params, timeout=60, headers={'User-Agent': _IVB_UA})
20908
20937
  if r.status_code != 200:
20909
20938
  if debuginfo >= 1:
20910
20939
  print(f" ⚠️ fut-underlying-info HTTP {r.status_code} "
@@ -21125,7 +21154,7 @@ def _load_futures_for_hedge(config, preloaded):
21125
21154
  params={'apiKey': _api_key, 'symbol': fut_root,
21126
21155
  'from': current.strftime('%Y-%m-%d'),
21127
21156
  'to': chunk_end.strftime('%Y-%m-%d')},
21128
- timeout=30)
21157
+ timeout=30, headers={'User-Agent': _IVB_UA})
21129
21158
  if r.status_code == 200:
21130
21159
  data = r.json().get('data', [])
21131
21160
  all_rows.extend(data)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ivolatility_backtesting
3
- Version: 2.138
3
+ Version: 2.139
4
4
  Summary: A universal backtesting framework for financial strategies using the IVolatility API.
5
5
  Author-email: IVolatility <support@ivolatility.com>
6
6
  Project-URL: Homepage, https://ivolatility.com
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "ivolatility_backtesting"
7
- version = "2.138"
7
+ version = "2.139"
8
8
  description = "A universal backtesting framework for financial strategies using the IVolatility API."
9
9
  readme = "README.md"
10
10
  authors = [