Closed brianleect closed 3 years ago
Hi @brianleect,
I have seen and tested several Bots that analyze the market and most of them use the method of sending to sleep. I guess it is the most efficient system to manage hardware resources.
The system is more or less as follows:
Worker 1 analyzes the first 10 or 20 pairs, makes the respective notification and after that goes to sleep for X amount of time. Then worker 2 analyzes the next 10 or 20 pairs, makes the respective notification and then goes to sleep for X amount of time. And so on until the entire market is analyzed. Once all the available pairs are analyzed, worker 1 starts again with the same pairs he already analyzed at the beginning of the cycle. And so the cycle is left running 24 hours a day.
The user decides how many pairs each worker will analyze. The total time will depend on the power of the hardware and the speed of the Internet connection.
Perhaps with this method of analysis some pumping may be lost, but it allows the user to decide the number of pairs to analyze based on his need and the capacity of his hardware.
This could be an example:
Suppose the Top 300 (volume) of coins versus USDT will be analyzed.
If each worker analyzes 20 pairs, there would be 15 workers (15 analysis intervals).
In this case worker 1 starts analyzing 20 pairs and then is sent to sleep. Then worker 2 begins his analysis with the next 20 pairs, and so on until the cycle of 300 pairs is completed. Once the cycle is completed, worker 1 starts his analysis again with the same 20 pairs he analyzed at the beginning and so on.
Of course the ideal would be to analyze the entire market, not just a top 300, but it could be an interesting configuration option for the user
Thanks @Juanjacinto123 for your input, it appears that the main reason for my high CPU consumption was because sleep was not used.
I have updated the program to utilize sleep instead. 75% utilization -> 2% utilization
Should not have much issues even when looking at all pairs at once for binance.
Perhaps I should limit to only USDT pairs to see if CPU consumption is reduced. Possibly use sleep instead of while loop check time?
Inefficient method of storage with arrays might be be a cause as well