DeviaVir / zenbot

Zenbot is a command-line cryptocurrency trading bot using Node.js and MongoDB.
MIT License
8.23k stars 2.04k forks source link

Stop loss trigger granularity #1246

Open laloch opened 6 years ago

laloch commented 6 years ago

System information

Hi,

as of now (if I understand the node.js "spaghetti" right) the executeStop(...) function, which takes care about triggering all our stop orders, is being called only on the period edge. This behavior makes Zenbot unsuitable for very high volatility (cryptocurrency) markets using long periods. I wonder if it wouldn't be better to rather evaluate and trigger the stops in periods based on _c.polltrades or its multiples.

defkev commented 6 years ago

executeStop() is [sic] executed for every new trade we polled from the exchange as long as my_trades/my_prev_trades is not empty.

laloch commented 6 years ago

OK, thanks for clarification. I got confused by the fact that the executeStop(true) call is done from within the if (period_id !== s.period.period_id) { block which made me think it's triggered just for the first trade of the new period. I still don't understand the code, though. JS is a write-only language for me.

laloch commented 6 years ago

Turns out that I'm not that bad in reading JS code. Simple console.log(...) revealed that the executeStop(true) gets indeed called only for the first trade in a period. So for --period=1h the sell stop is only evaluated once per hour.

ujesh-t commented 5 years ago

Totally agree with @laloch, Stoploss is not required if it is evaluated once per hour for an hourly candle. Is there any way to tweak the existing code to make it call stop loss at poll level