<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Lab49 Blog &#187; Reactive Extensions for .NET</title>
	<atom:link href="http://blog.lab49.com/archives/category/net/reactive-extensions-for-net/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.lab49.com</link>
	<description>Technology and industry insights from Lab49.</description>
	<lastBuildDate>Thu, 09 Sep 2010 14:00:25 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>RX Sandbox</title>
		<link>http://blog.lab49.com/archives/4850</link>
		<comments>http://blog.lab49.com/archives/4850#comments</comments>
		<pubDate>Tue, 31 Aug 2010 21:19:18 +0000</pubDate>
		<dc:creator>David Barnhill</dc:creator>
				<category><![CDATA[4.0]]></category>
		<category><![CDATA[Reactive Extensions for .NET]]></category>
		<category><![CDATA[.Net]]></category>
		<category><![CDATA[RX]]></category>

		<guid isPermaLink="false">http://blog.lab49.com/?p=4850</guid>
		<description><![CDATA[If you are learning the Reactive Extensions for .Net, a great learning tool is RX Sandbox.  It allows you to easily visualize the results of most of the standard RX operators.
]]></description>
			<content:encoded><![CDATA[<p>If you are learning the Reactive Extensions for .Net, a great learning tool is <a href="http://mnajder.blogspot.com/2010/03/rxsandbox-v1.html">RX Sandbox</a>.  It allows you to easily visualize the results of most of the standard RX operators.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lab49.com/archives/4850/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Detecting Running High/Low Prices Using Reactive Framework &#8211; Follow-up</title>
		<link>http://blog.lab49.com/archives/3935</link>
		<comments>http://blog.lab49.com/archives/3935#comments</comments>
		<pubDate>Fri, 01 Jan 2010 14:09:53 +0000</pubDate>
		<dc:creator>Eugene Prystupa</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Reactive Extensions for .NET]]></category>
		<category><![CDATA[Reactive Framework]]></category>

		<guid isPermaLink="false">http://blog.lab49.com/archives/3935</guid>
		<description><![CDATA[This article shows some improvements to the original code presented in my previous post. Improvements are based on the feedback I received from Erik Meijer and his team and mainly focus on some built-in opportunities in Rx framework that I missed. Here is an extract from the original implementation of the running low feed:
// Daily [...]]]></description>
			<content:encoded><![CDATA[<p>This article shows some improvements to the original code presented in my <a href="http://eprystupa.wordpress.com/2009/12/18/detecting-running-highlow-prices-using-reactive-extensions-for-net/">previous post</a>. Improvements are based on the feedback I received from Erik Meijer and his team and mainly focus on some built-in opportunities in Rx framework that I missed. Here is an extract from the original implementation of the running low feed:</p>
<pre class="code"><span style="color: green">// Daily low price feed
</span><span style="color: blue">double </span>min = <span style="color: blue">double</span>.MaxValue;
<span style="color: blue">var </span>feedLo = feed
    .Where(p =&gt; p &lt; min)
    .Do(p =&gt; min = <span style="color: #2b91af">Math</span>.Min(min, p))
    .Select(p =&gt; <span style="color: #a31515">&quot;New LO: &quot; </span>+ p);</pre>
<p><a href="http://11011.net/software/vspaste"></a>This implementation depends on the external (to the framework) state (current low value stored in “min” local variable), “Do” combinator to continuously update this state with every price tick, and a “Where” combinator to suppress the ticks that do not represent running low value. Turns out, there is a better, more elegant and framework friendly way to implement this. It relies on the built-in “Scan” and “HoldUntilChanged” combinators:</p>
<pre class="code"><span style="color: green">// Daily low price feed
</span><span style="color: blue">var </span>feedLo = feed
    .Scan(<span style="color: #2b91af">Math</span>.Min)
    .HoldUntilChanged()
    .Select(p =&gt; <span style="color: #a31515">&quot;New LO: &quot; </span>+ p);</pre>
<p><a href="http://11011.net/software/vspaste"></a>The code above is functionally equivalent to the original one but is cleaner, more compact, and easier to read. This is how it works:</p>
<ul>
<li>“Scan” operator is used to accumulate the running min value. “Scan” is similar to “Aggregate” in the LINQ-to-Objects world but, instead of collapsing the sequence to a single accumulated value, it keeps outputting the current accumulated value with every tick. As a result “Math.Min” function is continuously applied with every new tick with accumulated min value and new price as arguments and its result is “ticked out”. This produces a stream where every successive number is either less than or equal to the previous one. Close to what we need except we want to suppress duplicates. </li>
<li>“HoldUntilChanged” is another built-in combinator that wraps an underlying stream and only repeats a value from it if this value differs from the previous one. Perfect for removing successive duplicates (please, note, it will NOT remove ALL the duplicates, only successive ones, so it is not a proper substitute to Distinct, when such a combinator exists) . We use “HoldUntilChanged” instead of original “Where” clause. </li>
</ul>
<p><span id="more-3935"></span></p>
<p>Here is the full code:</p>
<pre class="code"><span style="color: green">// simulate market data
</span><span style="color: blue">var </span>rnd = <span style="color: blue">new </span><span style="color: #2b91af">Random</span>();
<span style="color: blue">var </span>feed = <span style="color: #2b91af">Observable</span>.Defer(() =&gt;
    <span style="color: #2b91af">Observable</span>.Return(<span style="color: #2b91af">Math</span>.Round(<span style="color: brown">30.0 </span>+ rnd.NextDouble(), <span style="color: brown">2</span>))
    .Delay(<span style="color: #2b91af">TimeSpan</span>.FromSeconds(<span style="color: brown">1 </span>* rnd.NextDouble())))
    .Repeat();

<span style="color: green">// Daily low price feed
</span><span style="color: blue">var </span>feedLo = feed
    .Scan(<span style="color: #2b91af">Math</span>.Min)
    .HoldUntilChanged()
    .Select(p =&gt; <span style="color: #a31515">&quot;New LO: &quot; </span>+ p);

<span style="color: green">// Daily high price feed
</span><span style="color: blue">var </span>feedHi = feed
    .Scan(<span style="color: #2b91af">Math</span>.Max)
    .HoldUntilChanged()
    .Select(p =&gt; <span style="color: #a31515">&quot;New HI: &quot; </span>+ p);

<span style="color: green">// Combine hi and lo in one feed and subscribe to it
</span>feedLo.Merge(feedHi).Subscribe(<span style="color: #2b91af">Console</span>.WriteLine);

<span style="color: #2b91af">Console</span>.ReadKey(<span style="color: blue">true</span>);</pre>
<p><a href="http://11011.net/software/vspaste"></a>Happy holidays!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lab49.com/archives/3935/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Processing Financial Data with Microsoft Reactive Framework (Reactive Extensions for .NET)</title>
		<link>http://blog.lab49.com/archives/3904</link>
		<comments>http://blog.lab49.com/archives/3904#comments</comments>
		<pubDate>Mon, 21 Dec 2009 04:46:39 +0000</pubDate>
		<dc:creator>Eugene Prystupa</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Reactive Extensions for .NET]]></category>
		<category><![CDATA[Reactive Framework]]></category>

		<guid isPermaLink="false">http://blog.lab49.com/?p=3904</guid>
		<description><![CDATA[Reactive Framework Labs
I have recently discovered Microsoft Reactive Framework (thanks to spontaneous introduction at New York .Net Meetup Group) and have been playing with it a lot trying to apply it to many financial problems I’ve coded over the last years. I am truly amazed with the technology and the power it unleashes for processing [...]]]></description>
			<content:encoded><![CDATA[<h6>Reactive Framework Labs</h6>
<p>I have recently discovered <a href="http://msdn.microsoft.com/en-us/devlabs/ee794896.aspx" target="_blank">Microsoft Reactive Framework</a> (thanks to spontaneous introduction at <a href="http://www.meetup.com/NY-Dotnet/" target="_blank">New York .Net Meetup Group</a>) and have been playing with it a lot trying to apply it to many financial problems I’ve coded over the last years. I am truly amazed with the technology and the power it unleashes for processing and analyzing streaming financial data (like quotes, market data feeds, trade executions, etc.). Seamless integration with LINQ combined with very powerful support for composition makes self coded CEP in .Net a low hanging fruit. In the following series of articles I am going to demonstrate sample Rx-based implementations for some commonly occurring tasks in finance, including:</p>
<ul>
<li><a href="http://eprystupa.wordpress.com/?p=140">Detecting daily Hi/Lo prices</a> </li>
<li><a href="http://eprystupa.wordpress.com/?p=143">Throttling high-frequency data feed</a> </li>
<li><a href="http://eprystupa.wordpress.com/?p=144">Data feed failover</a> </li>
<li><a href="http://eprystupa.wordpress.com/?p=149">Running VWAP calculation</a> </li>
</ul>
<p>Visual Studio 2008 solution containing full source code for all examples can be downloaded <a href="http://cid-fd7bfb078a7a66be.skydrive.live.com/self.aspx/Public/RxLabs.zip">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lab49.com/archives/3904/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
