Quantcast
Channel: VBForums - Java
Viewing all articles
Browse latest Browse all 41

stream pipeline with I/O channel as source?

$
0
0
Java 8 has a new Stream interface and the docs say, "To perform a computation, stream operations are composed into a stream pipeline. A stream pipeline consists of a source (which might be an array, a collection, a generator function, an I/O channel, etc),..."

1) Can anyone show me a minimally simple example using an I/O channel as a source?

2) I intend to use this url:
http://stream-sandbox.oanda.com/v1/p..._CAD%2CAUD_CHF
If you visit this url in a browser, you should see a stream of ticks and heartbeats (Late Sunday through Friday, Eastern Time).

As a less simple example than question 1) above, can you provide an example using the sandbox url in 2) above and say compute the 10 period simple moving average for each instrument, taking the midpoint or average of the bid and ask? So for an example tick:
{"tick":{"instrument":"AUD_CAD","time":"2015-10-28T20:34:19.075980Z","bid":0.93759,"ask":0.93909}}
The midpoint of the bid and ask is (0.93759 + 0.93909) / 2 = 0.93834
Only consider the most recent 10 midpoints for AUD_CAD, and the output is the average of 10 such midpoints.

Do the same for instrument AUD_CHF.

So first, I would like to understand how to use an I/O channel as the source of a stream pipeline, then next I assume it will filter on ticks (excluding heartbeats), then filter or group only the same instruments, and then only the most recent 10 midpoints, and the output would be 2 floats; 1 float for AUD_CAD and another for AUD_CHF.

Thanks.

Viewing all articles
Browse latest Browse all 41

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>