Note that there are some explanatory texts on larger screens.

plurals
  1. POGoing from Observable to Enumerable/Value without Blocking
    primarykey
    data
    text
    <p>I'm having some blocking problems. I am trying to go from push to pull. i.e. I would like to access my data here which in this case is an array after it has been processed through my Observable.</p> <pre class="lang-ml prettyprint-override"><code>type HistoryBar = {Open: decimal; High: decimal; Low: decimal; Close: decimal; Time: DateTime; Volume: int; RequestId: int; Index: int; Total: int} let transformBar = client.HistoricalData |&gt; Observable.map(fun args -&gt; { Open = args.Open High = args.High Low = args.Low Close = args.Close Time = args.Date Volume = args.Volume RequestId = args.RequestId Index = args.RecordNumber Total = args.RecordTotal } ) let groupByRequest (obs:IObservable&lt;HistoryBar&gt;) = let bars = obs.GroupByUntil((fun x -&gt; x.RequestId), (fun x -&gt; x.Where(fun y -&gt; y.Index = y.Total - 1))) bars.SelectMany(fun (x:IGroupedObservable&lt;int, HistoryBar&gt;) -&gt; x.ToArray()) let obs = transformBar |&gt; groupByRequest client.RequestHistoricalData(1, sym, DateTime.Now, TimeSpan.FromDays(10.0), BarSize.OneDay, HistoricalDataType.Midpoint, 0) </code></pre> <p>If I subscribe to obs, than as soon as I make a call to <code>client.RequestHistoricalData</code> everything works fine. What I would like to do is convert obs to the underlying type which in this case is <code>HistoryBar []</code>. I have tried using <code>wait</code>, <code>ToEnumberable</code> with no luck. What is the proper approach here to pull out my last created piece of data?</p> <p>Edit, adding contrived C# example code to show how the library normally works. What I am really trying to understand here is how one can go from observable to a standard list or array. What I am not certain of is if I required a mutable structure in order to do so. If I had to guess I would say no.</p> <pre><code>static void Main(string[] args) { ... client.HistoricalData += client_HistoricalData; client.RequestHistoricalData(1, sym, DateTime.Today, TimeSpan.FromDays(10), BarSize.OneDay, HistoricalDataType.Midpoint, 0); .... } static void client_HistoricalData(object sender, HistoricalDataEventArgs e) { Console.WriteLine("Open: {0}, High: {1}, Low: {2}, Close: {3}, Date: {4}, RecordId: {5}, RecordIndex: {6}", e.Open, e.High, e.Low, e.Close, e.Date, e.RequestId, e.RecordNumber); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload