-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
30 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6a1c379
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Independent Use of ThreadPoolExecutor: Each function, scout and bridge_scout, now utilizes its own instance of ThreadPoolExecutor. This allows each function to manage its tasks in isolation, avoiding interference between each other's operations.
Asynchronous Price Handling in scout: In the scout function, the process of fetching the current coin price is handled asynchronously. We use executor.submit to launch the task of getting the price, and then future.result() to wait for the outcome. This allows the method to continue executing other codes while waiting, optimizing response time.
Improved Flow Control: Both functions use executor.submit for tasks that might require waiting, such as database operations and API calls to fetch prices. This is particularly useful in real-time trading environments, where speed and efficiency in task execution can directly impact trading performance.
Code Improvements:
Operation Isolation: By running scout and bridge_scout independently, the risks of deadlocks and errors from race conditions between these two functions are minimized.
Performance Optimization: Asynchronous handling of heavy tasks allows the system to respond more quickly to market changes. This is crucial in automated trading, where opportunities can vanish in seconds.
Resource Management Efficiency: By using multiple executors, the code can more efficiently manage resources, allocating threads only when and where needed, potentially reducing system resource usage.