I highly recommend looking at the logic I use in my trading bot at https://github.com/pontifier/rebalancer
It trades using the idea of balancing the trades on either side of the market based on the amount in it's account. The more money it has, the tighter the spread. It is basically guaranteed to not loose money, or make bad trades unless the price crashes to nothing... IE it is always better off after a price change that returns to the current value.
I'm just afraid this is the absolute top, and I would never deploy it here.
The version in the public repo is old and I've made several improvements since then when I ported it to coinbase exchange.
RE: [ANN - automated market maker deployed ---> 0.777 volume at adjusted implied price for SBD, 0.1% spread]