stellar-deprecated / kelp

Kelp is a free and open-source trading bot for the Stellar DEX and 100+ centralized exchanges
https://kelpbot.io
Other
1.1k stars 263 forks source link

% off last trade order price protection #613

Open antb123 opened 3 years ago

antb123 commented 3 years ago

Desired Behavior

% off last trade order price protection

For example... so if xlm/token trades at 1 to 10 in trade history from horizon the next trade could not be at 100 to 10 (10000% more). I would be able to configure it to be 5% gap. Then I could only trade at 1.05 to 10.

Stock markets typically have these circuit-breakers built into them. The Stellar DEX could add this feature in the future.

IMPACT/Value

This feature would protect users from losing money and causing unexpected market movements 1) Trading illiquid markets with the bot 2) if someone suddenly pulls all their offers on an illiquid market and suddenly the market is one sided or thin (this happens quite a bit)

Considerations

History

a) No history b) No recent history

If the order book is empty perhaps it should error and say there is no trade history to go from in xxx hours / days . One solution might be the trader could add a midpoint to trade from or you might want to just force them to create a trade manually (less good)

What should happen to the bot when this occurs? Should it wait? or Error?

Override

if markets get crazy the person may need to over ride this value

reference

https://www.tsx.com/resource/en/1078 https://www.sec.gov/oiea/investor-alerts-bulletins/investor-alerts-circuitbreakershtm.html single stock circuit breakers. This means that a five-minute halt of trading in a security will now automatically trigger across all Canadian marketplaces if the price of the security swings 10% or more within a five-minute period.

nikhilsaraf commented 3 years ago

@antb123 we currently have min and max price filters (example). That should help to some degree right now and probably get you 95% of the way there.

With that, would you still need percentage based filters? that's a little harder to implement for various reasons but I can prioritize accordingly. I would eventually want to add circuit breakers including something like "if the bot has lost more than x% or $y in the past __ time then stop the bot and delete all offers"

re: the trades history, I don't anticipate adding something like that anytime soon because people have access to the frontend exchange and the expectation is that they open that exchange first before using Kelp and if they see a thin market or no trades then they are wary of trading in that market to begin with. Long-term this is of course a good feature to have inside Kelp itself.

antb123 commented 3 years ago

min and max could work - if I modify them now and then... or have a setup script that checks the bid/offer and sets it.