lumibot 4.1.1__py3-none-any.whl → 4.1.2__py3-none-any.whl
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.
Potentially problematic release.
This version of lumibot might be problematic. Click here for more details.
- lumibot/tools/thetadata_helper.py +15 -10
- {lumibot-4.1.1.dist-info → lumibot-4.1.2.dist-info}/METADATA +16 -5
- {lumibot-4.1.1.dist-info → lumibot-4.1.2.dist-info}/RECORD +9 -8
- {lumibot-4.1.1.dist-info → lumibot-4.1.2.dist-info}/WHEEL +1 -1
- tests/backtest/test_databento_parity.py +81 -0
- tests/test_databento_backtesting.py +44 -0
- {lumibot-4.1.1.data/data → lumibot/resources}/ThetaTerminal.jar +0 -0
- {lumibot-4.1.1.dist-info → lumibot-4.1.2.dist-info/licenses}/LICENSE +0 -0
- {lumibot-4.1.1.dist-info → lumibot-4.1.2.dist-info}/top_level.txt +0 -0
|
@@ -498,20 +498,25 @@ def start_theta_data_client(username: str, password: str):
|
|
|
498
498
|
logger.info("ThetaTerminal.jar not found, copying from lumibot package...")
|
|
499
499
|
import shutil as shutil_copy
|
|
500
500
|
|
|
501
|
-
|
|
502
|
-
|
|
501
|
+
package_root = Path(__file__).resolve().parent.parent
|
|
502
|
+
candidate_paths = [
|
|
503
|
+
package_root / "resources" / "ThetaTerminal.jar",
|
|
504
|
+
package_root.parent / "ThetaTerminal.jar", # legacy location fallback
|
|
505
|
+
]
|
|
503
506
|
|
|
504
|
-
if
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
logger.info(f"Successfully copied ThetaTerminal.jar to {jar_file}")
|
|
508
|
-
else:
|
|
507
|
+
lumibot_jar = next((path for path in candidate_paths if path.exists()), None)
|
|
508
|
+
|
|
509
|
+
if lumibot_jar is None:
|
|
509
510
|
raise FileNotFoundError(
|
|
510
|
-
|
|
511
|
-
f"
|
|
512
|
-
f"or manually place
|
|
511
|
+
"ThetaTerminal.jar not bundled with lumibot installation. "
|
|
512
|
+
f"Searched: {', '.join(str(path) for path in candidate_paths)}. "
|
|
513
|
+
f"Please reinstall lumibot or manually place the jar at {jar_file}"
|
|
513
514
|
)
|
|
514
515
|
|
|
516
|
+
logger.info(f"Copying ThetaTerminal.jar from {lumibot_jar} to {jar_file}")
|
|
517
|
+
shutil_copy.copy2(lumibot_jar, jar_file)
|
|
518
|
+
logger.info(f"Successfully copied ThetaTerminal.jar to {jar_file}")
|
|
519
|
+
|
|
515
520
|
if not jar_file.exists():
|
|
516
521
|
raise FileNotFoundError(f"ThetaTerminal.jar not found at {jar_file}")
|
|
517
522
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: lumibot
|
|
3
|
-
Version: 4.1.
|
|
3
|
+
Version: 4.1.2
|
|
4
4
|
Summary: Backtesting and Trading Library, Made by Lumiwealth
|
|
5
5
|
Home-page: https://github.com/Lumiwealth/lumibot
|
|
6
6
|
Author: Robert Grzesik
|
|
@@ -13,7 +13,7 @@ Description-Content-Type: text/markdown
|
|
|
13
13
|
License-File: LICENSE
|
|
14
14
|
Requires-Dist: polygon-api-client>=1.13.3
|
|
15
15
|
Requires-Dist: alpaca-py>=0.42.0
|
|
16
|
-
Requires-Dist:
|
|
16
|
+
Requires-Dist: alpha_vantage
|
|
17
17
|
Requires-Dist: ibapi==9.81.1.post1
|
|
18
18
|
Requires-Dist: yfinance>=0.2.61
|
|
19
19
|
Requires-Dist: matplotlib>=3.3.3
|
|
@@ -21,7 +21,7 @@ Requires-Dist: quandl
|
|
|
21
21
|
Requires-Dist: numpy>=1.20.0
|
|
22
22
|
Requires-Dist: pandas>=2.2.0
|
|
23
23
|
Requires-Dist: polars>=1.32.3
|
|
24
|
-
Requires-Dist:
|
|
24
|
+
Requires-Dist: pandas_market_calendars>=5.1.0
|
|
25
25
|
Requires-Dist: pandas-ta-classic>=0.3.14b0
|
|
26
26
|
Requires-Dist: plotly>=5.18.0
|
|
27
27
|
Requires-Dist: sqlalchemy
|
|
@@ -40,7 +40,7 @@ Requires-Dist: tqdm
|
|
|
40
40
|
Requires-Dist: lumiwealth-tradier>=0.1.17
|
|
41
41
|
Requires-Dist: pytz
|
|
42
42
|
Requires-Dist: psycopg2-binary
|
|
43
|
-
Requires-Dist:
|
|
43
|
+
Requires-Dist: exchange_calendars>=4.6.0
|
|
44
44
|
Requires-Dist: duckdb
|
|
45
45
|
Requires-Dist: tabulate
|
|
46
46
|
Requires-Dist: databento>=0.42.0
|
|
@@ -51,6 +51,17 @@ Requires-Dist: schwab-py>=1.5.0
|
|
|
51
51
|
Requires-Dist: Flask>=2.3
|
|
52
52
|
Requires-Dist: free-proxy
|
|
53
53
|
Requires-Dist: requests-oauthlib
|
|
54
|
+
Dynamic: author
|
|
55
|
+
Dynamic: author-email
|
|
56
|
+
Dynamic: classifier
|
|
57
|
+
Dynamic: description
|
|
58
|
+
Dynamic: description-content-type
|
|
59
|
+
Dynamic: home-page
|
|
60
|
+
Dynamic: license
|
|
61
|
+
Dynamic: license-file
|
|
62
|
+
Dynamic: requires-dist
|
|
63
|
+
Dynamic: requires-python
|
|
64
|
+
Dynamic: summary
|
|
54
65
|
|
|
55
66
|
[](https://github.com/Lumiwealth/lumibot/actions/workflows/cicd.yaml)
|
|
56
67
|
[](https://github.com/Lumiwealth/lumibot/actions/workflows/cicd.yaml)
|
|
@@ -156,6 +156,7 @@ lumibot/example_strategies/strangle.py,sha256=naYiJLcjKu9yb_06WOMAUg8t-mFEo_F0BS
|
|
|
156
156
|
lumibot/example_strategies/test_broker_functions.py,sha256=wnVS-M_OtzMgaXVBgshVEqXKGEnHVzVL_O4x5qR86cM,4443
|
|
157
157
|
lumibot/example_strategies/__pycache__/__init__.cpython-312.pyc,sha256=vawGE5mjtFUCyn6dqWSmZM2ij5pVT6YF4Cjn3KE0N-s,227
|
|
158
158
|
lumibot/example_strategies/__pycache__/test_broker_functions.cpython-312-pytest-8.4.1.pyc,sha256=Jvch4BJBA5IYmQx86yf8dDpWYFtV5ETkzrLFSxQoGkc,5452
|
|
159
|
+
lumibot/resources/ThetaTerminal.jar,sha256=K6GeeFcN8-gvyL2x5iq5pzD79KfPJvMK8iiezi3TmNQ,11834389
|
|
159
160
|
lumibot/resources/conf.yaml,sha256=rjB9-10JP7saZ_edjX5bQDGfuc3amOQTUUUr-UiMpNA,597
|
|
160
161
|
lumibot/strategies/__init__.py,sha256=jEZ95K5hG0f595EXYKWwL2_UsnWWk5Pug361PK2My2E,79
|
|
161
162
|
lumibot/strategies/_strategy.py,sha256=QCrrZQzTZ0GjsNyNNxHNI3WaNZ98yvxT-E0dbOBETMg,109685
|
|
@@ -187,7 +188,7 @@ lumibot/tools/polygon_helper_async.py,sha256=YHDXa9kmkkn8jh7hToY6GP5etyXS9Tj-uky
|
|
|
187
188
|
lumibot/tools/polygon_helper_polars_optimized.py,sha256=NaIZ-5Av-G2McPEKHyJ-x65W72W_Agnz4lRgvXfQp8c,30415
|
|
188
189
|
lumibot/tools/projectx_helpers.py,sha256=EIemLfbG923T_RBV_i6s6A9xgs7dt0et0oCnhFwdWfA,58299
|
|
189
190
|
lumibot/tools/schwab_helper.py,sha256=CXnYhgsXOIb5MgmIYOp86aLxsBF9oeVrMGrjwl_GEv0,11768
|
|
190
|
-
lumibot/tools/thetadata_helper.py,sha256=
|
|
191
|
+
lumibot/tools/thetadata_helper.py,sha256=dLWBCGlNGv97HZVcj8hFPA0gnfDk-AAWUl88Ravr99c,42905
|
|
191
192
|
lumibot/tools/types.py,sha256=x-aQBeC6ZTN2-pUyxyo69Q0j5e0c_swdfe06kfrWSVc,1978
|
|
192
193
|
lumibot/tools/yahoo_helper.py,sha256=htcKKkuktatIckVKfLc_ms0X75mXColysQhrZW244z8,19497
|
|
193
194
|
lumibot/tools/yahoo_helper_polars_optimized.py,sha256=g9xBN-ReHSW4Aj9EMU_OncBXVS1HpfL8LTHit9ZxFY4,7417
|
|
@@ -224,7 +225,7 @@ lumibot/trading_builtins/safe_list.py,sha256=IIjZOHSiZYK25A4WBts0oJaZNOJDsjZL65M
|
|
|
224
225
|
lumibot/trading_builtins/__pycache__/__init__.cpython-312.pyc,sha256=ksqDHG5HzxBeh3sDNn2NjEhYtj3dI6TvuQoe03VAItg,345
|
|
225
226
|
lumibot/trading_builtins/__pycache__/custom_stream.cpython-312.pyc,sha256=w9EEoPd4LTBKmS8x6x-umicO1GwzaHlZnAv7MC2A78o,7397
|
|
226
227
|
lumibot/trading_builtins/__pycache__/safe_list.cpython-312.pyc,sha256=2MQnqSCnMHHVu_gMK-3xBVSdHFyhxGR7_UrNdOvb4So,4875
|
|
227
|
-
lumibot-4.1.
|
|
228
|
+
lumibot-4.1.2.dist-info/licenses/LICENSE,sha256=fYhGIyxjyNXACgpNQS3xxpxDOaVOWRVxZMCRbsDv8k0,35130
|
|
228
229
|
tests/__init__.py,sha256=3-VoT-nAuqMfwufd4ceN6fXaHl_zCfDCSXJOTp1ywYQ,393
|
|
229
230
|
tests/conftest.py,sha256=UBw_2fx7r6TZPKus2b1Qxrzmd4bg8EEBnX1vCHUuSVA,3311
|
|
230
231
|
tests/fixtures.py,sha256=wOHQsh1SGHnXe_PGi6kDWI30CS_Righi7Ig7vwSEKT4,9082
|
|
@@ -266,7 +267,7 @@ tests/test_continuous_futures_resolution.py,sha256=1fob1-GF7QZrxiMK1EKcI2-LDP6bz
|
|
|
266
267
|
tests/test_data_source.py,sha256=MLZBZbUYQjt9FC9zrZ6ALL0ElHjByno6x2ls9XrYQH0,1991
|
|
267
268
|
tests/test_databento_asset_validation.py,sha256=bKSY_vWUb7IoVFfyI7Lk88DMjEgRcSw5dNPmKOc9-AI,5193
|
|
268
269
|
tests/test_databento_auto_expiry_integration.py,sha256=uPAyYTMTzEqppUUZx99G8pvnvAp7QQDuknfU6_IQJA8,11886
|
|
269
|
-
tests/test_databento_backtesting.py,sha256=
|
|
270
|
+
tests/test_databento_backtesting.py,sha256=LqcuHgjivmHIcEcCjZNSPDdD7epCwdaKtj6Q6Q4KTF0,20671
|
|
270
271
|
tests/test_databento_backtesting_polars.py,sha256=V9Z7-WG2TNKpHQVF5vGJSIdgUsuhJwlopZV66FREWA0,8097
|
|
271
272
|
tests/test_databento_data.py,sha256=HakjDileGpicQc_OXeX7l8ncIDn3FtxP8ymKA6TQp8o,18860
|
|
272
273
|
tests/test_databento_helper.py,sha256=C2FRkD3341FFHc09bObEYYN7eqUsO9aewyaLX9hCdvU,43465
|
|
@@ -337,6 +338,7 @@ tests/backtest/test_crypto_cash_regressions.py,sha256=-f0wjb-9nXpggS30N4zomYl098
|
|
|
337
338
|
tests/backtest/test_daily_data_timestamp_comparison.py,sha256=DeMLH0hwl0zEybJF0YTyBgfO8p96DGLahiBCwVQKjA4,35910
|
|
338
339
|
tests/backtest/test_databento.py,sha256=L7UIN0IjxdVzE65ujBvsoKyQhY4KHTctIOeOeWvVNBY,7485
|
|
339
340
|
tests/backtest/test_databento_comprehensive_trading.py,sha256=M7M2YHVkYRi5xBXifUESCnX5BFdtUDXy-HAhgazBAC4,23615
|
|
341
|
+
tests/backtest/test_databento_parity.py,sha256=bG10kIJlkLnXfPaEYMVhaf8D5V5Gf-qoyB9PW-H8JzM,2553
|
|
340
342
|
tests/backtest/test_debug_avg_fill_price.py,sha256=W4pgvCkAwmqlK82yzlw7u-s8VXe-dIQjPu-BVQkwJvg,3520
|
|
341
343
|
tests/backtest/test_dividends.py,sha256=tDEnK4IcqHPHYPXAfUlApEBOf-iMROSl3aCap0BX1nI,9970
|
|
342
344
|
tests/backtest/test_example_strategies.py,sha256=mSRRONtKdd7x0DUiuqCZD3YXLiPS8kAGn5wT1f_gDlk,15482
|
|
@@ -354,8 +356,7 @@ tests/backtest/test_thetadata.py,sha256=xWYfC9C4EhbMDb29qyZWHO3sSWaLIPzzvcMbHCt5
|
|
|
354
356
|
tests/backtest/test_thetadata_comprehensive.py,sha256=-gN3xLJcJtlB-k4vlaK82DCZDGDmr0LNZZDzn-aN3l4,26120
|
|
355
357
|
tests/backtest/test_thetadata_vs_polygon.py,sha256=dZqsrOx3u3cz-1onIO6o5BDRjI1ey7U9vIkZupfXoig,22831
|
|
356
358
|
tests/backtest/test_yahoo.py,sha256=uHb9aK3uHYEvA7MI_y1dbKm7mjHrErlxU7TJOgVdzs8,1966
|
|
357
|
-
lumibot-4.1.
|
|
358
|
-
lumibot-4.1.
|
|
359
|
-
lumibot-4.1.
|
|
360
|
-
lumibot-4.1.
|
|
361
|
-
lumibot-4.1.1.dist-info/RECORD,,
|
|
359
|
+
lumibot-4.1.2.dist-info/METADATA,sha256=45LvQ6tGhCYieVoXNPDspLGbhfj7JccZ1xZFzTilsHs,11721
|
|
360
|
+
lumibot-4.1.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
361
|
+
lumibot-4.1.2.dist-info/top_level.txt,sha256=otUnUjDFVASauEDiTiAzNgMyqQ1B6jjS3QqqP-WSx38,14
|
|
362
|
+
lumibot-4.1.2.dist-info/RECORD,,
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"""Parity checks between DataBento pandas and polars backends."""
|
|
2
|
+
|
|
3
|
+
import shutil
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
from datetime import datetime
|
|
6
|
+
|
|
7
|
+
import pandas as pd
|
|
8
|
+
import pytest
|
|
9
|
+
import pytz
|
|
10
|
+
|
|
11
|
+
from lumibot.backtesting.databento_backtesting import DataBentoDataBacktesting as DataBentoPandas
|
|
12
|
+
from lumibot.data_sources.databento_data_polars_backtesting import DataBentoDataPolarsBacktesting
|
|
13
|
+
from lumibot.entities import Asset
|
|
14
|
+
from lumibot.credentials import DATABENTO_CONFIG
|
|
15
|
+
from lumibot.tools import databento_helper, databento_helper_polars
|
|
16
|
+
|
|
17
|
+
DATABENTO_API_KEY = DATABENTO_CONFIG.get("API_KEY")
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def _clear_databento_caches():
|
|
21
|
+
for cache_dir in (
|
|
22
|
+
databento_helper.LUMIBOT_DATABENTO_CACHE_FOLDER,
|
|
23
|
+
databento_helper_polars.LUMIBOT_DATABENTO_CACHE_FOLDER,
|
|
24
|
+
):
|
|
25
|
+
path = Path(cache_dir)
|
|
26
|
+
if path.exists():
|
|
27
|
+
shutil.rmtree(path)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
@pytest.mark.apitest
|
|
31
|
+
@pytest.mark.skipif(
|
|
32
|
+
not DATABENTO_API_KEY or DATABENTO_API_KEY == '<your key here>',
|
|
33
|
+
reason="This test requires a Databento API key",
|
|
34
|
+
)
|
|
35
|
+
def test_databento_price_parity():
|
|
36
|
+
"""Ensure pandas and polars backends deliver identical prices."""
|
|
37
|
+
|
|
38
|
+
_clear_databento_caches()
|
|
39
|
+
|
|
40
|
+
tz = pytz.timezone("America/New_York")
|
|
41
|
+
start = tz.localize(datetime(2025, 9, 15, 0, 0))
|
|
42
|
+
end = tz.localize(datetime(2025, 9, 29, 23, 59))
|
|
43
|
+
asset = Asset("MES", asset_type=Asset.AssetType.CONT_FUTURE)
|
|
44
|
+
|
|
45
|
+
pandas_ds = DataBentoPandas(
|
|
46
|
+
datetime_start=start,
|
|
47
|
+
datetime_end=end,
|
|
48
|
+
api_key=DATABENTO_API_KEY,
|
|
49
|
+
show_progress_bar=False,
|
|
50
|
+
)
|
|
51
|
+
polars_ds = DataBentoDataPolarsBacktesting(
|
|
52
|
+
datetime_start=start,
|
|
53
|
+
datetime_end=end,
|
|
54
|
+
api_key=DATABENTO_API_KEY,
|
|
55
|
+
show_progress_bar=False,
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
# Prime caches
|
|
59
|
+
pandas_bars = pandas_ds.get_historical_prices(asset, 500, timestep="minute").df
|
|
60
|
+
polars_bars = polars_ds.get_historical_prices(asset, 500, timestep="minute").df
|
|
61
|
+
|
|
62
|
+
pd.testing.assert_frame_equal(polars_bars, pandas_bars)
|
|
63
|
+
|
|
64
|
+
checkpoints = [
|
|
65
|
+
(0, 0),
|
|
66
|
+
(3, 40),
|
|
67
|
+
(4, 0),
|
|
68
|
+
(7, 35),
|
|
69
|
+
(11, 5),
|
|
70
|
+
(14, 5),
|
|
71
|
+
]
|
|
72
|
+
|
|
73
|
+
for hour, minute in checkpoints:
|
|
74
|
+
current_dt = tz.localize(datetime(2025, 9, 15, hour, minute))
|
|
75
|
+
pandas_ds._datetime = current_dt
|
|
76
|
+
polars_ds._datetime = current_dt
|
|
77
|
+
pandas_price = pandas_ds.get_last_price(asset)
|
|
78
|
+
polars_price = polars_ds.get_last_price(asset)
|
|
79
|
+
assert pandas_price == pytest.approx(polars_price), (
|
|
80
|
+
f"Mismatch at {current_dt}: pandas={pandas_price}, polars={polars_price}"
|
|
81
|
+
)
|
|
@@ -2,6 +2,7 @@ import unittest
|
|
|
2
2
|
from unittest.mock import Mock, patch, MagicMock
|
|
3
3
|
from datetime import datetime, timedelta
|
|
4
4
|
import pandas as pd
|
|
5
|
+
import pytz
|
|
5
6
|
|
|
6
7
|
from lumibot.backtesting.databento_backtesting import DataBentoDataBacktesting
|
|
7
8
|
from lumibot.entities import Asset, Data
|
|
@@ -224,6 +225,49 @@ class TestDataBentoDataBacktesting(unittest.TestCase):
|
|
|
224
225
|
self.assertEqual(result, 4250.75)
|
|
225
226
|
mock_get_last_price.assert_called_once()
|
|
226
227
|
|
|
228
|
+
@patch('lumibot.tools.databento_helper.DATABENTO_AVAILABLE', True)
|
|
229
|
+
@patch('lumibot.tools.databento_helper.get_last_price_from_databento')
|
|
230
|
+
def test_get_last_price_uses_current_bar_when_available(self, mock_get_last_price):
|
|
231
|
+
"""
|
|
232
|
+
Ensure we reuse the latest completed bar from cache (rather than hitting the API)
|
|
233
|
+
when no earlier bar exists in the window.
|
|
234
|
+
"""
|
|
235
|
+
ny = pytz.timezone("America/New_York")
|
|
236
|
+
current_dt = ny.localize(datetime(2025, 1, 1, 9, 30))
|
|
237
|
+
|
|
238
|
+
backtester = DataBentoDataBacktesting(
|
|
239
|
+
datetime_start=self.start_date,
|
|
240
|
+
datetime_end=self.end_date,
|
|
241
|
+
api_key=self.api_key
|
|
242
|
+
)
|
|
243
|
+
backtester._datetime = current_dt
|
|
244
|
+
|
|
245
|
+
# Seed cached data with a single bar at the current timestamp
|
|
246
|
+
test_df = pd.DataFrame(
|
|
247
|
+
{
|
|
248
|
+
"open": [100.0],
|
|
249
|
+
"high": [101.0],
|
|
250
|
+
"low": [99.5],
|
|
251
|
+
"close": [100.5],
|
|
252
|
+
"volume": [1000],
|
|
253
|
+
},
|
|
254
|
+
index=pd.DatetimeIndex([current_dt]),
|
|
255
|
+
)
|
|
256
|
+
|
|
257
|
+
data = Data(
|
|
258
|
+
self.test_asset,
|
|
259
|
+
df=test_df,
|
|
260
|
+
timestep="minute",
|
|
261
|
+
quote=Asset("USD", "forex"),
|
|
262
|
+
)
|
|
263
|
+
search_asset = (self.test_asset, Asset("USD", "forex"))
|
|
264
|
+
backtester.pandas_data[search_asset] = data
|
|
265
|
+
|
|
266
|
+
price = backtester.get_last_price(asset=self.test_asset)
|
|
267
|
+
|
|
268
|
+
self.assertEqual(price, 100.5)
|
|
269
|
+
mock_get_last_price.assert_not_called()
|
|
270
|
+
|
|
227
271
|
@patch('lumibot.tools.databento_helper.DATABENTO_AVAILABLE', True)
|
|
228
272
|
def test_get_chains(self):
|
|
229
273
|
"""Test options chains retrieval (should return empty dict)"""
|
|
File without changes
|
|
File without changes
|
|
File without changes
|