refactor of ticker logic #304

Merged
scionaltera merged 2 commits from ticker-refactor into master 2021-01-02 23:15:11 -08:00
scionaltera commented 2021-01-02 02:50:20 -08:00 (Migrated from github.com)

The main purpose of this PR is to strengthen the separation between the code that fetches price data and the code that analyzes the market for trade opportunities. The idea was always that we would maintain the allTickers map with the most up-to-date view of market prices that we know, so that the rest of the code didn't have to worry about calling APIs and could focus on just crunching the numbers. Because I had avoided adding a lot of concurrency to the bot in the past, the two processes were tied together and happening sequentially. As we moved forward we started to introduce some events and event listeners, and this PR fully separates things. All ticker fetching happens the same way: use a TickerStrategy to get some prices, put them in allTickers and publish an event about the change. Each event received triggers an analysis to determine whether or not to trade, but now the ticker updating and market analyzing happen independently of one another in entirely separate thread pools.

  • version bump - this got bigger than I was expecting
  • adjust thread pool settings to enable a lot more concurrency
  • filter down ticker event listener to a minimal amount of work
  • debug logging in ticker event publisher
  • toString() implementation in Spread
  • adjust information included in TickerEvent
  • PaperTradeService uses TickerService - tickers are refreshed in different threads now
  • all TickerStrategy implementations publish ticker events
  • ParallelTickerStrategy no longer delays the first batch
  • Renamed StreamingTickerEvent* to just TickerEvent*
  • TradeCombinations are not grouped by streaming/polling anymore
  • Streamlined the initialization sequence
  • We no longer clear allTickers every tick and instead just update it
  • Refactored startTradingProcess() out
  • trade() is now synchronized to prevent multiple threads attempting the same trade
The main purpose of this PR is to strengthen the separation between the code that fetches price data and the code that analyzes the market for trade opportunities. The idea was always that we would maintain the `allTickers` map with the most up-to-date view of market prices that we know, so that the rest of the code didn't have to worry about calling APIs and could focus on just crunching the numbers. Because I had avoided adding a lot of concurrency to the bot in the past, the two processes were tied together and happening sequentially. As we moved forward we started to introduce some events and event listeners, and this PR fully separates things. All ticker fetching happens the same way: use a `TickerStrategy` to get some prices, put them in `allTickers` and publish an event about the change. Each event received triggers an analysis to determine whether or not to trade, but now the ticker updating and market analyzing happen independently of one another in entirely separate thread pools. * version bump - this got bigger than I was expecting * adjust thread pool settings to enable a lot more concurrency * filter down ticker event listener to a minimal amount of work * debug logging in ticker event publisher * toString() implementation in Spread * adjust information included in TickerEvent * PaperTradeService uses TickerService - tickers are refreshed in different threads now * all TickerStrategy implementations publish ticker events * ParallelTickerStrategy no longer delays the first batch * Renamed StreamingTickerEvent* to just TickerEvent* * TradeCombinations are not grouped by streaming/polling anymore * Streamlined the initialization sequence * We no longer clear allTickers every tick and instead just update it * Refactored startTradingProcess() out * trade() is now synchronized to prevent multiple threads attempting the same trade
Commenting is not possible because the repository is archived.
No description provided.