Before you continue reading take a look at the flowchart of Jesse and the explanation about the "live" price.
Question already answered? No? No problem. Let's dive into it.

Jesse starts its workflow after a fully formed candle, like seen in the flow chart. In that sense, you can't do something "immediately". There is only the most recent candle. The whole candle concept in trading and the whole concept of trading strategies are based on aggregated prices in form of timeframes (1m, 5m, 15m...) and therefore the term "live" is misleading.

"But I need the live price to open/close a position immediately!" If you understood the above and are certain of what you are doing then let's take a look at how close we can get to immediately. Let's say for a reason you want to use indicators on a 1h timeframe to decide whether to enter a position, but your exit should react live (we learned this just means using a smaller timeframe / or the smallest possible), you could use 1m candles for the exit.
Think about the flowchart. Jesse starts after a new candle formed. If you now set the routes timeframe to 1h you can't do anything until the next 1h is formed. So instead you would have to select the 1m timeframe in the routes and you can use get_candles() to get the 1h candles. As an alternative, you can use self.index to find the moment, where your 1h formed. The open of the first 1m candle is the same open as the bigger 1h candle and the close of the last 1m candles within this 1h is the same as the 1h close. An hour has 60 minutes so with pythons modulo operator %, which returns the remainder of a division, you could do this to know whenever a 1h candle has formed: self.index % 60 == 0.
Was this article helpful?
Cancel
Thank you!