Skip to content

Commit 4e11170

Browse files
authored
Merge pull request #101 from Lumiwealth/features/backtesting_last_price_discrepency_
There was a time shift error with bars. Corrected this and modified i…
2 parents 812c1d4 + 322ee56 commit 4e11170

File tree

2 files changed

+21
-23
lines changed

2 files changed

+21
-23
lines changed

lumibot/backtesting/data_source_backtesting.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,6 @@ def _pull_source_symbol_bars(self, asset, length, timestep=None, timeshift=0):
6565
if result is None:
6666
return result
6767
else:
68-
filter_criteria = result.index < self._datetime
68+
filter_criteria = result.index <= self._datetime
6969
result = result[filter_criteria]
7070
return result

tests/test_main_pandas_daily.py

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -165,41 +165,40 @@ def test_integration():
165165
expected_result = {
166166
"buy_and_hold": {
167167
"cagr": 0.1476027590432618,
168-
"romad": 2.2315656039426397,
168+
"volatility": 0.13352288364371973,
169169
"sharpe": 1.1054491560945578,
170+
"romad": 2.2315656039426397,
170171
"total_return": 0.09509502182006835,
171-
"volatility": 0.13352288364371973,
172+
},
173+
"simple": {
174+
"cagr": 0.005829326013952141,
175+
"volatility": 0.006478334119743725,
176+
"sharpe": 0.8998186734744613,
177+
"romad": 1.6573403606987755,
178+
"total_return": 0.003842514038087108,
172179
},
173180
"debt_trading": {
174181
"cagr": 0.20554760657213134,
175-
"romad": 8.00686191195888,
182+
"volatility": 0.07017662276132623,
176183
"sharpe": 2.929003968617979,
184+
"romad": 8.00686191195888,
177185
"total_return": 0.13127250881195174,
178-
"volatility": 0.07017662276132623,
186+
},
187+
"momentum": {
188+
"cagr": 0.48736434348385216,
189+
"volatility": 0.11638046363125136,
190+
"sharpe": 4.187681748957919,
191+
"romad": 14.647567392415182,
192+
"total_return": 0.29946557283401365,
179193
},
180194
"diversification": {
181195
"cagr": 0.19794477299026614,
182-
"romad": 6.443675455209815,
196+
"volatility": 0.0570697876160907,
183197
"sharpe": 3.4684687162644363,
198+
"romad": 6.443675455209815,
184199
"total_return": 0.1265600008964547,
185-
"volatility": 0.0570697876160907,
186-
},
187-
"momentum": {
188-
"cagr": 0.4848441103037764,
189-
"romad": 14.722161562758469,
190-
"sharpe": 4.175720386980683,
191-
"total_return": 0.2980123232841483,
192-
"volatility": 0.11611029124829647,
193-
},
194-
"simple": {
195-
"cagr": 0.005829326013952141,
196-
"romad": 1.6573403606987755,
197-
"sharpe": 0.8998186734744613,
198-
"total_return": 0.003842514038087108,
199-
"volatility": 0.006478334119743725,
200200
},
201201
}
202-
203202
for strategy, results in agg_results.items():
204203
assert results["cagr"] == expected_result[strategy]["cagr"]
205204
assert results["romad"] == expected_result[strategy]["romad"]
@@ -217,6 +216,5 @@ def remove_test_dir():
217216

218217
request.addfinalizer(remove_test_dir)
219218

220-
221219
if __name__ == "__main__":
222220
test_integration()

0 commit comments

Comments
 (0)