Comments (6)
well it has - it's a simple limitation (i call it bug) in scikit-optimize (scikit-optimize/scikit-optimize#967).
There's never really been a solution to this (given that scikit-optimize is no longer maintained, that's no surprise) - so the solution essentially remains the same - use strings with a separator that you can easily split it again.
from freqtrade.
Thank you very much, I came up with something like that as well. Quite handy addition to the usually fast expanding search space, that is not really inclined to converge to the global min.
sim = [(0.2, 0.1, 0.5), (0.3, 0.1, 0.7), (0.4, 0.1, 0.3)]
def format_number(n): if isinstance(n, float): # Format float to remove trailing zeros and keep up to 4 decimal places return f"{n:.4f}".rstrip('0').rstrip('.') elif isinstance(n, int): # Simply convert integer to string return str(n) sim_strings = [' '.join(format_number(x) for x in tuple) for tuple in sim]
I did not even know it is no longer maintained. Thanks for the quick heads up!
from freqtrade.
well we do keep it "installable" as part of a fork (otherwise some dependencies would not be updateable anymore) - but that's about it - there's no plans to add features, or fix additional bugs.
from freqtrade.
Still get it not going..
@staticmethod
def format_pair(pair):
"""Format the pair as a string with one decimal place."""
return f"{pair[0]:.1f}_{pair[1]:.1f}"
# Use static method to format pairs
simple_test_categories = [(0.2, 0.1), (0.3, 0.1), (0.4, 0.1)]
formatted_categories = [Strategy.format_pair(pair) for pair in simple_test_categories]
upper_lower_pairs = CategoricalParameter(formatted_categories, default="0.3_0.1", space='buy')
and then in populate_indicators:
def populate_indicators(self, dataframe, metadata):
"""Generate all indicators using parameters from CategoricalParameter."""
# Iterate over each value in the range of categorical parameters
for val in self.upper_lower_pairs.range:
fast, slow = map(float, val.split('_')) # Split the string and convert to float
afterwards the dynamic creation with f"" of the column names. It still leads to the error:
Epochs ━╸━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 24/1000 2% • 0:00:13 • 0:03:43
2024-05-02 18:26:54,735 - freqtrade - ERROR - Fatal exception!
Traceback (most recent call last):
File "/home/moritz/VisualStudio/freqtrade5/freqtrade/freqtrade/main.py", line 42, in main
return_code = args['func'](args)
File "/home/moritz/VisualStudio/freqtrade5/freqtrade/freqtrade/commands/optimize_commands.py", line 107, in start_hyperopt
hyperopt.start()
File "/home/moritz/VisualStudio/freqtrade5/freqtrade/freqtrade/optimize/hyperopt.py", line 615, in start
asked, is_random = self.get_asked_points(n_points=current_jobs)
File "/home/moritz/VisualStudio/freqtrade5/freqtrade/freqtrade/optimize/hyperopt.py", line 503, in get_asked_points
asked = unique_list(self.opt.ask(n_points=n_points * 5 if i > 0 else n_points))
File "/home/moritz/VisualStudio/freqtrade5/freqtrade/.venv/lib/python3.10/site-packages/skopt/optimizer/optimizer.py", line 395, in ask
x = opt.ask()
File "/home/moritz/VisualStudio/freqtrade5/freqtrade/.venv/lib/python3.10/site-packages/skopt/optimizer/optimizer.py", line 367, in ask
return self._ask()
File "/home/moritz/VisualStudio/freqtrade5/freqtrade/.venv/lib/python3.10/site-packages/skopt/optimizer/optimizer.py", line 446, in _ask
min_delta_x = min([self.space.distance(next_x, xi)
File "/home/moritz/VisualStudio/freqtrade5/freqtrade/.venv/lib/python3.10/site-packages/skopt/optimizer/optimizer.py", line 446, in <listcomp>
min_delta_x = min([self.space.distance(next_x, xi)
File "/home/moritz/VisualStudio/freqtrade5/freqtrade/.venv/lib/python3.10/site-packages/skopt/space/space.py", line 1138, in distance
distance += dim.distance(a, b)
File "/home/moritz/VisualStudio/freqtrade5/freqtrade/.venv/lib/python3.10/site-packages/skopt/space/space.py", line 743, in distance
if not (a in self and b in self):
File "/home/moritz/VisualStudio/freqtrade5/freqtrade/.venv/lib/python3.10/site-packages/skopt/space/space.py", line 720, in __contains__
return point in self.categories
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
Could you maybe share how you do it? Thank you very much
from freqtrade.
well try it the simple way - hardcoding the strings instead of trying to overengineer things ?
i doubt the segments you shared will cause this though - at least not at first glance - so most likely you're loading a wrong strategy (duplicate strategies)...
from freqtrade.
You are right, I was loading the wrong strategy. I did too many changes at once. I ended up with something like that:
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
"""Generate all indicators using parameters from CategoricalParameter."""
print("Categorical parameter range:", self.upper_lower_pairs.range)
print("Current value:", self.upper_lower_pairs.value)
# Iterate over each value in the range of categorical parameters
for val in self.upper_lower_pairs.range:
print(f"Current val: {val}, type: {type(val)}") # Debugging output
fast, slow = map(float, val.split('_')) # Split the string and convert to float
And the wrong datatype -list- still showed up. I restarted VS, restarted the .venv, ensured the pathes are correct.. I In the end I simply renamed the strategy and everything worked perfectly fine. I am such a noob.
from freqtrade.
Related Issues (20)
- Backtesting: KeyError: 'ME' HOT 5
- Trade object: Remaining amount HOT 4
- Hyperopt finished loading data, the epoch phase stayed at 0% and exited the run HOT 4
- AI Code optimization "proof-reading"? HOT 4
- How to enable sandbox mode on OKX exchange HOT 2
- Hyperopt loss going wrong way ? HOT 8
- Is it good practice to store objects in main dataframe? HOT 6
- Strategy backtesting without error alerts, auto-stop HOT 3
- Impossible to backtest on Bybit futures HOT 11
- Is it possible to plot bool indicators below or above candles & plot shapes? HOT 5
- Different results with same parameters HOT 4
- TEMA200 to long? HOT 10
- Custom Telegram message from Strategy HOT 1
- ccxt >= 4.3.21 is broken HOT 1
- FreqAI: model not retraining itself. HOT 3
- ccxt.base.errors.RequestTimeout HOT 1
- `trade()`: truncate data at "current date" to avoid lookahead bias in callbacks HOT 3
- (backtesting)Sample Strategy not work for cli, but works for web server interface HOT 1
- Add Python version 3.12 in the setup file HOT 1
- support ipv6 for api_server.listen_ip_address HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from freqtrade.