I keep getting the InvalidStrategy error

"Looks like the structure of your strategy directory is incorrect. Make sure to include the strategy INSIDE the init.py file".

In this case, Jesse couldn't initiate your strategy. There are three possibilities:

  • Make sure you are working in the correct Jesse project directory - to make sure your changes actually are at the right place.
  • Make sure the class name and folder name of your strategy are the same. This often happens during copy&paste of a strategy (folder) without adjusting the class name.
  • Make sure you have the minimum required functions of a strategy. should_long, go_long, and should_cancel_entry. To make things easy the best way of creating a strategy is using the make-strategy command.

You forgot to set ...

This error tells you what function/properties you forgot to set. Just set them as mentioned in the exception and you should be ready to go.

... must be either a list or a tuple.

Your quantity and price format isn't right. Check the docs to see examples how it's done right.

qty cannot be 0

This means you submitted an order with a quantity of zero. Sometimes this happens in backtests when your strategy is a losing one and runs out of capital. Some other times it's merely a mistake in how you submit the order.

Check how you calculate your qty. For example in risk_to_qty and size_to_qty you might have to increase / adjust the precision. Rounding down, which is necessary to not exceed the maximally available capital, is the problem here. With some symbols, this might happen more than with others. This is related to their very small prices with many digits after the decimal point. Setting the precision is only necessary for backtesting and optimization. The live plugin does take care of precision automatically.

Targeted strategy does not implement a valid hyperparameters() method.

This happens if you start the optimization mode with a strategy that doesn't have the necessary hyperparameters() method. See here how you should add it.

Invalid filter format. You need to pass filter methods WITHOUT calling them

This means you have added parentheses () where none should be. See here for a detailed explanation. This can also happen if you added the @property decorator to the filter function you added to filters. Remove the decorator.

... must be below / above ... price in a long/short position

This means you gave Jesse prices that don't make sense together. For example, your entry price for a long position is 100$ and you set a take profit price at 90$. If both orders were submitted (and the exchange doesn't check for logic) you would instantly lose money.

  • To solve this the first step is to check if you accidentally mixed up stuff for example stop-loss with take-profit.
  • Then the next step is to check if your stop loss / take profit methods actually, under certain conditions, return a price that doesn't make sense. Depending on your entry rules there might be a situation where your indicators/calculations return prices that you didn't expect. For example, if you use a moving average, but you don't make sure it's above or below the entry price. Here the solution is to adjust the entry conditions or add fallback conditions that use another stop or take profit method in situations those illogical prices occur. See here for tips on how to debug those situations.

You cannot access ...

These are related to the average functions. They are only available after go_long() or go_short() was executed. Hence, they are only supposed to be used in either filter functions or when the position is open. In other words, you cannot use it inside should_long() and should_short().

Last updated: 2 years ago