Living in the Moment

Few people that work in the financial world actually live in the now.

Some live at the last month end; others at 't-1'.

Only silicon, mad men and chattering Tweeters live on the edge.

Following on from the Flow and Statelessness post, I used Lazy.js, a CORS proxy and the Markit On Demand API to build a quick and dirty way to process financial data in real time in your browser.

prices('TSLA')

represents the current stream of prices for Tesla.

prices('TSLA').async(1000)

is the current stream of prices sampled at a second apart.

prices('TSLA').async(1000).take(60)

will return a minute's worth of prices sampled every second.

Perhaps you don't want to double count illiquid prices?

prices('TSLA').async(1000).take(60).uniq()

Or... 60 unique prices, however long it takes?

prices('TSLA').async(1000).uniq().take(60)

Filters, maps etc. you get the idea - dead simple.

At first I thought asynchronicity and laziness wouldn't mix.

Laziness would cause all the asynchronous calls to be executed last minute.

However I really enjoy throwing around asynchronous calls in a symbolical fashion; manipulate them and then as soon as available the data flows through.

I haven't quite straightened out the 'Lazy-Async nexus' just yet - but the end product has been satisfying so far.

Code is here.