Сообщения

Сообщения за июль, 2019

Running parallel calculation in Scala with Futures and individual sleep intervals

In this short topic, I will show have run the calculation in parallel with the same code (method) but with individual sleep intervals. Basic - https://github.com/AlexGruPerm/barcl Formulation of the problem: 1) We have a flow of tick data from Forex, Stock market or etc (flow presented as a Column Family in Cassandra database). 2) And we have a couple of dictionaries:    dictionary of tickers (symbols) (ID, NAME), like 1-EURUSD, 2-ORCL.    dictionary of BWS (Bar width seconds) (TICKER_ID, BWS)- For example: 1 - 30 1 - 600 1 - 3600 It means that for ticker with ID=1 we need to calculate bars with widths 30 sec, 1 min, 1 hour( 60 mins). We need to calculate all bars online, with minimal lag between last tick and TS_END (last bar of ticker and ts_end as unixtimestamp ) of the last bar. Also, we need to eliminate unnecessary read of the database to minimize resource consumption. First, simple and unoptimized version was the next: in loop read all for all pair (ticker+b