Is it possible to call next from within a method for an outer loop:
bot.rb
while Option.daemon_active?(daemon: "bot")
.....
Trade.market_order
....
end
trade.rb
class Trade
def self.market_order
... complex code ...
response = exchange.market_sell
next if response["state"] == false # This fails. This should start new iteration of while in bot.rb
end
end
There is quite similar question, but it doesn't seem to suit me: call next on ruby loop from external method
next unless Trade.market_orderin the while block?Botshould not be controlled viaTrade, it is simply not its responsibility and increases coupling which usually should be avoided (hard to follow path of execution, hard to refactor,Trademay break ifBotchanges etc.)return falseeverywhere you need the next iteration or use @sawa’s approach withcatch.