ivolatility-backtesting 2.138__tar.gz → 2.140__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.
- {ivolatility_backtesting-2.138 → ivolatility_backtesting-2.140}/PKG-INFO +1 -1
- {ivolatility_backtesting-2.138 → ivolatility_backtesting-2.140}/ivolatility_backtesting/ivolatility_backtesting.py +39 -7
- {ivolatility_backtesting-2.138 → ivolatility_backtesting-2.140}/ivolatility_backtesting.egg-info/PKG-INFO +1 -1
- {ivolatility_backtesting-2.138 → ivolatility_backtesting-2.140}/pyproject.toml +1 -1
- {ivolatility_backtesting-2.138 → ivolatility_backtesting-2.140}/README.md +0 -0
- {ivolatility_backtesting-2.138 → ivolatility_backtesting-2.140}/ivolatility_backtesting/__init__.py +0 -0
- {ivolatility_backtesting-2.138 → ivolatility_backtesting-2.140}/ivolatility_backtesting.egg-info/SOURCES.txt +0 -0
- {ivolatility_backtesting-2.138 → ivolatility_backtesting-2.140}/ivolatility_backtesting.egg-info/dependency_links.txt +0 -0
- {ivolatility_backtesting-2.138 → ivolatility_backtesting-2.140}/ivolatility_backtesting.egg-info/requires.txt +0 -0
- {ivolatility_backtesting-2.138 → ivolatility_backtesting-2.140}/ivolatility_backtesting.egg-info/top_level.txt +0 -0
- {ivolatility_backtesting-2.138 → ivolatility_backtesting-2.140}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ivolatility_backtesting
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.140
|
|
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,37 @@ 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
|
+
# ivollive/DEV: point every REST call at the internal API when IVOL_API_BASE_URL is
|
|
60
|
+
# set (workspace has an internal key, invalid for prod). Default stays external.
|
|
61
|
+
_API_BASE = __import__('os').getenv('IVOL_API_BASE_URL') or 'https://restapi.ivolatility.com'
|
|
62
|
+
try:
|
|
63
|
+
# _session lives in the ivolatility.ivolatility submodule; the top-level
|
|
64
|
+
# package does not re-export it (same lookup as _thread_safe_session)
|
|
65
|
+
_ivol_inner = getattr(ivol, 'ivolatility', ivol)
|
|
66
|
+
_ivol_inner._session.headers['User-Agent'] = _IVB_UA # SDK global session
|
|
67
|
+
except Exception:
|
|
68
|
+
pass
|
|
38
69
|
import time
|
|
39
70
|
import psutil
|
|
40
71
|
import warnings
|
|
@@ -1690,6 +1721,7 @@ def _create_sdk_like_session():
|
|
|
1690
1721
|
adapter = HTTPAdapter(pool_connections=10, pool_maxsize=10, max_retries=retry)
|
|
1691
1722
|
s.mount("https://", adapter)
|
|
1692
1723
|
s.mount("http://", adapter)
|
|
1724
|
+
s.headers['User-Agent'] = _IVB_UA
|
|
1693
1725
|
return s
|
|
1694
1726
|
|
|
1695
1727
|
|
|
@@ -8113,7 +8145,7 @@ def _api_call_internal(endpoint, cache_config, debug, debug_level, skip_parquet_
|
|
|
8113
8145
|
# TIMING: URL construction (for debug)
|
|
8114
8146
|
if debug_level >= 3 or (debug and APIManager._api_key):
|
|
8115
8147
|
t_url_start = time.perf_counter()
|
|
8116
|
-
base_url =
|
|
8148
|
+
base_url = _API_BASE
|
|
8117
8149
|
url_params = {}
|
|
8118
8150
|
for key, value in kwargs.items():
|
|
8119
8151
|
clean_key = key.rstrip('_') if key.endswith('_') else key
|
|
@@ -9284,7 +9316,7 @@ class StopLossManager:
|
|
|
9284
9316
|
# Log API call
|
|
9285
9317
|
api_key = APIManager._api_key or "API_KEY"
|
|
9286
9318
|
api_key_short = f"{api_key[:10]}...{api_key[-6:]}" if api_key and len(api_key) > 16 else api_key
|
|
9287
|
-
full_url = f"
|
|
9319
|
+
full_url = f"{_API_BASE}{endpoint}?apiKey={api_key_short}&symbol={symbol}&date={date_str}&expDate={exp_date_str}&strike={strike}&optType={api_opt_type}&minuteType={minute_interval}"
|
|
9288
9320
|
_bt_logger.info(f"[INTRADAY-OPTIONS] {full_url}")
|
|
9289
9321
|
|
|
9290
9322
|
result = method(
|
|
@@ -11466,7 +11498,7 @@ class StopLossManager:
|
|
|
11466
11498
|
|
|
11467
11499
|
# Log intraday API call with full URL
|
|
11468
11500
|
api_key = APIManager._api_key or "API_KEY"
|
|
11469
|
-
full_url = f"
|
|
11501
|
+
full_url = f"{_API_BASE}/equities/intraday/stock-prices?apiKey={api_key}&symbol={symbol}&date={date_str}&minuteType={minute_interval}"
|
|
11470
11502
|
if self.debuginfo >= 2:
|
|
11471
11503
|
print(f" 📡 Intraday API: {full_url}")
|
|
11472
11504
|
_bt_logger.info(f"[INTRADAY] {full_url}")
|
|
@@ -20903,8 +20935,8 @@ def _resolve_futures_underlying(symbol, region=None, mic=None,
|
|
|
20903
20935
|
for attempt in (1, 2):
|
|
20904
20936
|
try:
|
|
20905
20937
|
r = _requests.get(
|
|
20906
|
-
'
|
|
20907
|
-
params=params, timeout=60)
|
|
20938
|
+
f'{_API_BASE}/futures/eod/fut-underlying-info',
|
|
20939
|
+
params=params, timeout=60, headers={'User-Agent': _IVB_UA})
|
|
20908
20940
|
if r.status_code != 200:
|
|
20909
20941
|
if debuginfo >= 1:
|
|
20910
20942
|
print(f" ⚠️ fut-underlying-info HTTP {r.status_code} "
|
|
@@ -21121,11 +21153,11 @@ def _load_futures_for_hedge(config, preloaded):
|
|
|
21121
21153
|
chunk_end = min(current + _td(days=chunk_days), end_dt)
|
|
21122
21154
|
try:
|
|
21123
21155
|
r = _requests.get(
|
|
21124
|
-
'
|
|
21156
|
+
f'{_API_BASE}/futures/eod/prices',
|
|
21125
21157
|
params={'apiKey': _api_key, 'symbol': fut_root,
|
|
21126
21158
|
'from': current.strftime('%Y-%m-%d'),
|
|
21127
21159
|
'to': chunk_end.strftime('%Y-%m-%d')},
|
|
21128
|
-
timeout=30)
|
|
21160
|
+
timeout=30, headers={'User-Agent': _IVB_UA})
|
|
21129
21161
|
if r.status_code == 200:
|
|
21130
21162
|
data = r.json().get('data', [])
|
|
21131
21163
|
all_rows.extend(data)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ivolatility_backtesting
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.140
|
|
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.
|
|
7
|
+
version = "2.140"
|
|
8
8
|
description = "A universal backtesting framework for financial strategies using the IVolatility API."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
authors = [
|
|
File without changes
|
{ivolatility_backtesting-2.138 → ivolatility_backtesting-2.140}/ivolatility_backtesting/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|