I do not manage to get processTradeCompleted event working, can you please help?
#1
Hello,

I now study Gekko for 2 weeks and have written my first strategy.
It is working in general but I would like to monitor processTradeCompleted event to make  sure that my strategy can react properly in case of error (e.g. trade cancelled, errored).

I have to say that I'm not a javaScript specialist, so, I probably did not code the implementation properly.

When my code runs I do not have exceptions but also I do not get the processTradeCompleted event,

Here attached I have attached my strategy. There are lots of comment in it and I hope it is easy to understand.
Could someone help me to solve my problem? This should not be a big issue. So far you could take a look at the "Plugin.prototype.processTradeCompleted" in the attached strategy.

Thanks in advance for your support and thanks again GEKKO Smile


Attached Files
.zip   myStrategy.zip (Size: 10.77 KB / Downloads: 5)
  Reply
#2
Wow. You spent a lot of time writing this strategy. Nice to see the effort you're putting in for your own strategy.

The reason why processTradeCompleted is not working is probably that it is already declared in tradingAdvisor. TradingAdvisor works with baseTradingMethod and your strategy to participate in the event system that Gekko uses to pass information between all the various components.

This video should help explain this process.
https://www.youtube.com/watch?v=lc21W9_zdME
If it isn't crypto, it isn't worth mining, it isn't worth speculating.
https://www.youtube.com/c/crypto49er
  Reply
#3
Hello Crypto49er,

Thanks for your answer. Smile
Actually it took me 6 days working 2 hours per day on it in the evening. It is not yet finished but I already start playing with it in paper trading mode.

I saw your video already before and it was very helpfull. I'm now using onTrade event and this is working but the only problem with it is that I'm not able to differentiate if the order was placed or not.
Or at least, so far, I could not simulate a case where the order did not got through and generates an error. I would like to do that to see if the onTrade event will also be raised or not, and if so, with which content.

Did you ever receive a onTrade event for the failing order?

A the end, what I want to make sure, is that my bot will stop if anything goes wrong instead of emptying my account bny generating errors and bad trades  Big Grin
  Reply
#4
No. OnTrade is only called when the processTradeCompleted event occurs.

I ended up creating the onTerminatedTrades method in my smart strategy template (also modified baseTradingMethod & tradingAdvisor to get that to work) to get alerted when trades abort or error out.

You might have seen the video about that, but if you haven't, it's here.

https://www.youtube.com/watch?v=xwfYkgOjTFE
If it isn't crypto, it isn't worth mining, it isn't worth speculating.
https://www.youtube.com/c/crypto49er
  Reply
#5
Thumbs Up 
Just had a look at it. Thanks a lot. This is a great video. THANKS THANKS THANKS  Smile
  Reply


Forum Jump:


Users browsing this thread: