First let us take a look at the strategy framework:
The entire strategy framework is actually very simple. A main function, an onTick order function, a CancelPendingOrders function, and necessary parameters.
The main process is as follows:
1. Obtain account information.
2. Get Tick data.
3. Calculate the bid-ask spread of Tick data.
4. Calculate the difference between account balance and BTC market value.
5. Calculate the buying and selling conditions, order price, and order quantity.
6. Place an order and return true.
The order cancellation module is even simpler, the steps are as follows:
1. Wait for 1 second before canceling the order. For individual exchanges, you know.
2. Continuously obtain the array of untransacted orders. If an exception is returned, continue to obtain it.
3. If the unfilled order array is empty, it will immediately return to the order cancellation state.
4. If there is an unfilled order, traverse the entire array and cancel the order based on the order number.
##External parameters
The above is the detailed content of How does Java implement a dynamic balancing strategy based on digital currency?. For more information, please follow other related articles on the PHP Chinese website!