Skip to content

Commit 217312e

Browse files
authored
Merge pull request #110 from iterativv/hotfix/tests
Update to latest available data
2 parents cdd1593 + 1d02d2e commit 217312e

File tree

5 files changed

+31
-29
lines changed

5 files changed

+31
-29
lines changed

.github/workflows/tests.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ jobs:
6666

6767
- name: Run Tests
6868
env:
69-
EXTRA_ARGS: tests/backtests -k 'binance and ${{ matrix.timerange }}'
69+
EXTRA_ARGS: -p no:cacheprovider tests/backtests -k 'binance and ${{ matrix.timerange }}'
7070
run: |
7171
mkdir artifacts
7272
chmod 777 artifacts
@@ -113,7 +113,7 @@ jobs:
113113

114114
- name: Run Tests
115115
env:
116-
EXTRA_ARGS: tests/backtests -k 'kucoin and ${{ matrix.timerange }}'
116+
EXTRA_ARGS: -p no:cacheprovider tests/backtests -k 'kucoin and ${{ matrix.timerange }}'
117117
run: |
118118
mkdir artifacts
119119
chmod 777 artifacts
@@ -149,7 +149,7 @@ jobs:
149149

150150
- name: Run Tests
151151
env:
152-
EXTRA_ARGS: --ignore tests/backtests/
152+
EXTRA_ARGS: -p no:cacheprovider --ignore tests/backtests/
153153
run: |
154154
mkdir artifacts
155155
chmod 777 artifacts $(pwd)

NostalgiaForInfinityNext.py

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3890,7 +3890,7 @@ def base_tf_btc_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFr
38903890
# Add prefix
38913891
# -----------------------------------------------------------------------------------------
38923892
ignore_columns = ['date', 'open', 'high', 'low', 'close', 'volume']
3893-
dataframe.rename(columns=lambda s: "btc_" + s if (not s in ignore_columns) else s, inplace=True)
3893+
dataframe.rename(columns=lambda s: f"btc_{s}" if s not in ignore_columns else s, inplace=True)
38943894

38953895
return dataframe
38963896

@@ -3903,7 +3903,7 @@ def info_tf_btc_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFr
39033903
# Add prefix
39043904
# -----------------------------------------------------------------------------------------
39053905
ignore_columns = ['date', 'open', 'high', 'low', 'close', 'volume']
3906-
dataframe.rename(columns=lambda s: "btc_" + s if (not s in ignore_columns) else s, inplace=True)
3906+
dataframe.rename(columns=lambda s: f"btc_{s}" if s not in ignore_columns else s, inplace=True)
39073907

39083908
return dataframe
39093909

@@ -3918,7 +3918,7 @@ def daily_tf_btc_indicators(self, dataframe: DataFrame, metadata: dict) -> DataF
39183918
# Add prefix
39193919
# -----------------------------------------------------------------------------------------
39203920
ignore_columns = ['date', 'open', 'high', 'low', 'close', 'volume']
3921-
dataframe.rename(columns=lambda s: "btc_" + s if (not s in ignore_columns) else s, inplace=True)
3921+
dataframe.rename(columns=lambda s: f"btc_{s}" if s not in ignore_columns else s, inplace=True)
39223922

39233923
return dataframe
39243924

@@ -3937,21 +3937,21 @@ def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame
39373937
btc_base_tf = self.dp.get_pair_dataframe(btc_info_pair, self.timeframe)
39383938
btc_base_tf = self.base_tf_btc_indicators(btc_base_tf, metadata)
39393939
dataframe = merge_informative_pair(dataframe, btc_base_tf, self.timeframe, self.timeframe, ffill=True)
3940-
drop_columns = [(s + "_" + self.timeframe) for s in ['date', 'open', 'high', 'low', 'close', 'volume']]
3940+
drop_columns = [f"{s}_{self.timeframe}" for s in ['date', 'open', 'high', 'low', 'close', 'volume']]
39413941
dataframe.drop(columns=dataframe.columns.intersection(drop_columns), inplace=True)
39423942

39433943
if self.has_BTC_info_tf:
39443944
btc_info_tf = self.dp.get_pair_dataframe(btc_info_pair, self.info_timeframe)
39453945
btc_info_tf = self.info_tf_btc_indicators(btc_info_tf, metadata)
39463946
dataframe = merge_informative_pair(dataframe, btc_info_tf, self.timeframe, self.info_timeframe, ffill=True)
3947-
drop_columns = [(s + "_" + self.info_timeframe) for s in ['date', 'open', 'high', 'low', 'close', 'volume']]
3947+
drop_columns = [f"{s}_{self.info_timeframe}" for s in ['date', 'open', 'high', 'low', 'close', 'volume']]
39483948
dataframe.drop(columns=dataframe.columns.intersection(drop_columns), inplace=True)
39493949

39503950
if self.has_BTC_daily_tf:
39513951
btc_daily_tf = self.dp.get_pair_dataframe(btc_info_pair, '1d')
39523952
btc_daily_tf = self.daily_tf_btc_indicators(btc_daily_tf, metadata)
39533953
dataframe = merge_informative_pair(dataframe, btc_daily_tf, self.timeframe, '1d', ffill=True)
3954-
drop_columns = [(s + "_" + '1d') for s in ['date', 'open', 'high', 'low', 'close', 'volume']]
3954+
drop_columns = [f"{s}_1d" for s in ['date', 'open', 'high', 'low', 'close', 'volume']]
39553955
dataframe.drop(columns=dataframe.columns.intersection(drop_columns), inplace=True)
39563956

39573957

@@ -3962,7 +3962,7 @@ def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame
39623962
if self.info_timeframe != 'none':
39633963
informative_1h = self.informative_1h_indicators(dataframe, metadata)
39643964
dataframe = merge_informative_pair(dataframe, informative_1h, self.timeframe, self.info_timeframe, ffill=True)
3965-
drop_columns = [(s + "_" + self.info_timeframe) for s in ['date']]
3965+
drop_columns = [f"{s}_{self.info_timeframe}" for s in ['date']]
39663966
dataframe.drop(columns=dataframe.columns.intersection(drop_columns), inplace=True)
39673967

39683968
'''
@@ -3974,9 +3974,9 @@ def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame
39743974
resampled = self.resampled_tf_indicators(resampled, metadata)
39753975
# Merge resampled info dataframe
39763976
dataframe = resampled_merge(dataframe, resampled, fill_na=True)
3977-
dataframe.rename(columns=lambda s: s+"_{}".format(self.res_timeframe) if "resample_" in s else s, inplace=True)
3977+
dataframe.rename(columns=lambda s: f"{s}_{self.res_timeframe}" if "resample_" in s else s, inplace=True)
39783978
dataframe.rename(columns=lambda s: s.replace("resample_{}_".format(self.res_timeframe.replace("m","")), ""), inplace=True)
3979-
drop_columns = [(s + "_" + self.res_timeframe) for s in ['date']]
3979+
drop_columns = [f"{s}_{self.res_timeframe}" for s in ['date']]
39803980
dataframe.drop(columns=dataframe.columns.intersection(drop_columns), inplace=True)
39813981

39823982
'''
@@ -4658,7 +4658,7 @@ def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
46584658

46594659
item_buy_logic.append(dataframe['volume'] > 0)
46604660
item_buy = reduce(lambda x, y: x & y, item_buy_logic)
4661-
dataframe.loc[item_buy, 'buy_tag'] += str(index) + ' '
4661+
dataframe.loc[item_buy, 'buy_tag'] += f"{index} "
46624662
conditions.append(item_buy)
46634663

46644664
if conditions:
@@ -4740,17 +4740,17 @@ def _should_hold_trade(self, trade: "Trade", rate: float, sell_reason: str) -> b
47404740
trade_profit_ratio = trade_ids[trade.id]
47414741
current_profit_ratio = trade.calc_profit_ratio(rate)
47424742
if sell_reason == "force_sell":
4743-
formatted_profit_ratio = "{}%".format(trade_profit_ratio * 100)
4744-
formatted_current_profit_ratio = "{}%".format(current_profit_ratio * 100)
4743+
formatted_profit_ratio = f"{trade_profit_ratio * 100}%"
4744+
formatted_current_profit_ratio = f"{current_profit_ratio * 100}%"
47454745
log.warning(
47464746
"Force selling %s even though the current profit of %s < %s",
47474747
trade, formatted_current_profit_ratio, formatted_profit_ratio
47484748
)
47494749
return False
47504750
elif current_profit_ratio >= trade_profit_ratio:
47514751
# This pair is on the list to hold, and we reached minimum profit, sell
4752-
formatted_profit_ratio = "{}%".format(trade_profit_ratio * 100)
4753-
formatted_current_profit_ratio = "{}%".format(current_profit_ratio * 100)
4752+
formatted_profit_ratio = f"{trade_profit_ratio * 100}%"
4753+
formatted_current_profit_ratio = f"{current_profit_ratio * 100}%"
47544754
log.warning(
47554755
"Selling %s because the current profit of %s >= %s",
47564756
trade, formatted_current_profit_ratio, formatted_profit_ratio
@@ -4765,17 +4765,17 @@ def _should_hold_trade(self, trade: "Trade", rate: float, sell_reason: str) -> b
47654765
trade_profit_ratio = trade_pairs[trade.pair]
47664766
current_profit_ratio = trade.calc_profit_ratio(rate)
47674767
if sell_reason == "force_sell":
4768-
formatted_profit_ratio = "{}%".format(trade_profit_ratio * 100)
4769-
formatted_current_profit_ratio = "{}%".format(current_profit_ratio * 100)
4768+
formatted_profit_ratio = f"{trade_profit_ratio * 100}%"
4769+
formatted_current_profit_ratio = f"{current_profit_ratio * 100}%"
47704770
log.warning(
47714771
"Force selling %s even though the current profit of %s < %s",
47724772
trade, formatted_current_profit_ratio, formatted_profit_ratio
47734773
)
47744774
return False
47754775
elif current_profit_ratio >= trade_profit_ratio:
47764776
# This pair is on the list to hold, and we reached minimum profit, sell
4777-
formatted_profit_ratio = "{}%".format(trade_profit_ratio * 100)
4778-
formatted_current_profit_ratio = "{}%".format(current_profit_ratio * 100)
4777+
formatted_profit_ratio = f"{trade_profit_ratio * 100}%"
4778+
formatted_current_profit_ratio = f"{current_profit_ratio * 100}%"
47794779
log.warning(
47804780
"Selling %s because the current profit of %s >= %s",
47814781
trade, formatted_current_profit_ratio, formatted_profit_ratio
@@ -4831,7 +4831,7 @@ def williams_r(dataframe: DataFrame, period: int = 14) -> Series:
48314831

48324832
WR = Series(
48334833
(highest_high - dataframe["close"]) / (highest_high - lowest_low),
4834-
name="{0} Williams %R".format(period),
4834+
name=f"{period} Williams %R",
48354835
)
48364836

48374837
return WR * -100
@@ -5138,7 +5138,7 @@ def process_loaded_data(self, data):
51385138
self.path
51395139
)
51405140
if trade_id in open_trades:
5141-
formatted_profit_ratio = "{}%".format(profit_ratio * 100)
5141+
formatted_profit_ratio = f"{profit_ratio * 100}%"
51425142
log.warning(
51435143
"The trade %s is configured to HOLD until the profit ratio of %s is met",
51445144
open_trades[trade_id],
@@ -5163,7 +5163,7 @@ def process_loaded_data(self, data):
51635163
)
51645164
else:
51655165
profit_ratio = 0.005
5166-
formatted_profit_ratio = "{}%".format(profit_ratio * 100)
5166+
formatted_profit_ratio = f"{profit_ratio * 100}%"
51675167
for trade_id in trade_ids:
51685168
if not isinstance(trade_id, int):
51695169
log.error(
@@ -5208,7 +5208,7 @@ def process_loaded_data(self, data):
52085208
trade_pair,
52095209
self.path
52105210
)
5211-
formatted_profit_ratio = "{}%".format(profit_ratio * 100)
5211+
formatted_profit_ratio = f"{profit_ratio * 100}%"
52125212
if trade_pair in open_trades:
52135213
log.warning(
52145214
"The trade %s is configured to HOLD until the profit ratio of %s is met",

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ git clone --recursive https://github.com/iterativv/NostalgiaForInfinity.git chec
2121

2222
### Existing Checkouts
2323
```
24-
git submodule update --remote --recursive
24+
git submodule update --remote --checkout
2525
```
2626

2727

tests/backtests/test_winrate_and_drawdown.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,11 @@ def deviations():
7171
("20210301", "20210401"): {"max_drawdown": 55, "winrate": 90},
7272
},
7373
"kucoin": {
74-
("20210401", "20210501"): {"max_drawdown": 51, "winrate": 76},
75-
("20210501", "20210601"): {"max_drawdown": 51, "winrate": 76},
74+
("20210201", "20210301"): {"max_drawdown": 85, "winrate": 90},
75+
("20210401", "20210501"): {"max_drawdown": 52, "winrate": 90},
76+
("20210501", "20210601"): {"max_drawdown": 141, "winrate": 90},
7677
("20210601", "20210701"): {"max_drawdown": 51, "winrate": 76},
78+
("20210701", "20210801"): {"max_drawdown": 82, "winrate": 90},
7779
},
7880
}
7981

user_data/data

Submodule data updated 689 files

0 commit comments

Comments
 (0)