Best design for a Java Bot

Hi Community,

I am in the process of writing a JAVA trading Bot. At the moment I have completed the strategy code that determines what coin to buy for the next trading period. FYI - I havent written production level java code for a good few years. Hence why I am here seeking advice.

Where I need help or guidance is what is the best way to do the following:

  1. My strategy needs to be executed on the close of a candlestick event. My strategy needs to look at a small number of the previous candle sticks (including the one just closed) of all Tradable USDT paired coins. (Here - I was thinking here of subscribing to BTCUSD only to determine when the candle has closed using a Websocket and the onCandlestick method and on the close event of the current candle it calls my strategy to search all coins and select which coin to buy - Here I assume all Tradable Pairs have the same candle close time)
  2. My strategy will return a single coin to buy for the next trading period. The buying of the coin should use all my available binance balance. It should also set a take profit and a stop lose.
  3. Periodically whilst in trade I should receive messages(email/whatsapp something) of the current profit loss of the coin. (Here - I was thinking of a separate app that periodically checks on my trade and feedbacks the profit loss etc of the trade)
  4. At the next candlestick close event If I have a trade open I should close it.

Is there another way to determine when a candle stick closes without using Websockets - essentially I am using this event to trigger my strategy?

Is using an application to run the trading component and having a another application monitor the trade a good approach? or would it be best to have it rolled into one application?

Any guidance would be really helpful.

Kind Regards,
Matt.

I may no be helpful to your strategy, however kline sticks end at fixed time.
For example:

  • 1m kline ends at end of each minute.
  • 1h kline ends at end of each hour.
  • etc

Websocket is the best channel to receive market data from Binance server.