Giter Site home page Giter Site logo

Comments (6)

xmatthias avatar xmatthias commented on June 8, 2024

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.

HeinrichHaller avatar HeinrichHaller commented on June 8, 2024

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.

xmatthias avatar xmatthias commented on June 8, 2024

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.

HeinrichHaller avatar HeinrichHaller commented on June 8, 2024

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.

xmatthias avatar xmatthias commented on June 8, 2024

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.

HeinrichHaller avatar HeinrichHaller commented on June 8, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.