mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-10 18:23:55 +00:00
parent
dd37e5cfb8
commit
5bb48eaed0
|
@ -9,6 +9,7 @@ from copy import deepcopy
|
||||||
from datetime import datetime, timedelta, timezone
|
from datetime import datetime, timedelta, timezone
|
||||||
from typing import Any, Dict, List, Optional, Tuple
|
from typing import Any, Dict, List, Optional, Tuple
|
||||||
|
|
||||||
|
from numpy import nan
|
||||||
from pandas import DataFrame
|
from pandas import DataFrame
|
||||||
|
|
||||||
from freqtrade.configuration import TimeRange, validate_config_consistency
|
from freqtrade.configuration import TimeRange, validate_config_consistency
|
||||||
|
@ -289,10 +290,12 @@ class Backtesting:
|
||||||
# To avoid using data from future, we use buy/sell signals shifted
|
# To avoid using data from future, we use buy/sell signals shifted
|
||||||
# from the previous candle
|
# from the previous candle
|
||||||
for col in headers[5:]:
|
for col in headers[5:]:
|
||||||
|
tag_col = col in ('enter_tag', 'exit_tag')
|
||||||
if col in df_analyzed.columns:
|
if col in df_analyzed.columns:
|
||||||
df_analyzed.loc[:, col] = df_analyzed.loc[:, col].shift(1)
|
df_analyzed.loc[:, col] = df_analyzed.loc[:, col].replace(
|
||||||
|
[nan], [0 if not tag_col else None]).shift(1)
|
||||||
else:
|
else:
|
||||||
df_analyzed.loc[:, col] = 0 if col not in ('enter_tag', 'exit_tag') else None
|
df_analyzed.loc[:, col] = 0 if not tag_col else None
|
||||||
|
|
||||||
# Update dataprovider cache
|
# Update dataprovider cache
|
||||||
self.dataprovider._set_cached_df(pair, self.timeframe, df_analyzed, CandleType.SPOT)
|
self.dataprovider._set_cached_df(pair, self.timeframe, df_analyzed, CandleType.SPOT)
|
||||||
|
|
|
@ -57,10 +57,6 @@ def _build_backtest_dataframe(data):
|
||||||
# Ensure floats are in place
|
# Ensure floats are in place
|
||||||
for column in ['open', 'high', 'low', 'close', 'volume']:
|
for column in ['open', 'high', 'low', 'close', 'volume']:
|
||||||
frame[column] = frame[column].astype('float64')
|
frame[column] = frame[column].astype('float64')
|
||||||
if 'enter_tag' not in columns:
|
|
||||||
frame['enter_tag'] = None
|
|
||||||
if 'exit_tag' not in columns:
|
|
||||||
frame['exit_tag'] = None
|
|
||||||
|
|
||||||
# Ensure all candles make kindof sense
|
# Ensure all candles make kindof sense
|
||||||
assert all(frame['low'] <= frame['close'])
|
assert all(frame['low'] <= frame['close'])
|
||||||
|
|
Loading…
Reference in New Issue
Block a user