10-07-2018, 09:46 AM
(09-06-2018, 11:13 PM)mark.sch Wrote: You need only to add a couple of lines into your strategy to get notified when the gekko event system is firing a trade completed event. It is the same way like you add the init or check function to your strategy:
strat.onTrade = function (trade) {
//catch all trades. Whether from manual buy/sell (telegram bot), a stoploss trigger or from a strategy advice
if (trade.action == 'sell') {
// do something here
}
}
From console.log(trade) output you see all properties the trade object is containing:
{ id: 'trade-7',
adviceId: 'advice-4',
action: 'buy',
cost: 1.4524059748649476,
amount: 0.07355882,
price: 13143.47,
portfolio: { asset: 0.07355882, currency: 0 },
balance: 966.8181439053999,
date: moment("2018-01-16T01:45:00.000"),
effectivePrice: 13123.754795,
feePercent: 0.15,
status: 'tradeCompleted',
trigger: { origin: 'trailingStop', trailPercentage: 2 } }
Hi there.
I tried to console.log trade within the onTrade event in my strategy on both sell and buy condition, but I couldn't see any trigger key in that object. This is what's happening at least in papermode test, not with actual trading.
I'm wondering if there is an event or a way to check if the native stopLoss has been triggered so that I can send a message to slack or telegram.
Thanks in advance for your help.
Thanks a lot Mike for this incredible work!