The expected bot flow looks as follow:
- Connect and register for price event
- Wait for the expected price and then buy the product
- Sell the product when price is less or greater than given boundaries
- Stop the bot
- Taking into account that all the logic is based on event processing, I decided to use actors. The most known one I heard but never use was Akka.
- All the messages that come from/to actros should be immutable. Google's Autovalue allows us to create such object with less code.
- Jackson for serialization/deserialization - pretty obvious choice.
- Retrofit fot http calls
- async-http-client for websockets
The bot accepts several params all of which are required for successful start.
- -i,--id The product id
- -p,--price The buy price
- -l,--lower The lower limit sell price this the price you want are willing to close a position at and make a loss.
- -u,--upper The upper limit sell price this is the price you are willing to close a position and make a profit.
java -jar bux-bot-1.0-jar-with-dependencies.jar -i sb26493 -p 13222 -l 13220 -u 13225
- Error handling.
- Test coverage.
- Don't stop trading after the first sell.