Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4085082
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:31:30+00:00 2026-05-20T18:31:30+00:00

I have recorded real-time stock quotes in an SQL database with fields Id ,

  • 0

I have recorded real-time stock quotes in an SQL database with fields Id, Last, and TimeStamp. Last being the current stock price (as a double), and TimeStamp is the DateTime when the price change was recorded.

I would like to replay this stream in the same way it came in, meaning if a price change was originally 12 seconds apart then the price change event firing (or something similar) should be 12 seconds apart.

In C# I might create a collection, sort it by the DateTime then fire an event using the difference in time to know when to fire off the next price change. I realize F# has a whole lot of cool new stuff relating to events, but I don’t know how I would even begin this in F#. Any thoughts/code snippets/helpful links on how I might proceed with this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T18:31:31+00:00Added an answer on May 20, 2026 at 6:31 pm

    I think you’ll love the F# solution :-).

    To keep the example simple, I’m storing the price and timestamps in a list containing tuples (the first element is the delay from the last update an the second element is the price). It shouldn’t be too difficult to turn your input data into this format. For example:

    let prices = [ (0, 10.0); (1000, 10.5); (500, 9.5); (2500, 8.5) ]
    

    Now we can create a new event that will be used to replay the process. After creating it, we immediatelly attach some handler that will print the price updates:

    let evt = new Event<float>()
    evt.Publish.Add(printfn "Price updated: %f")
    

    The last step is to implement the replay – this can be done using asynchronous workflow that loops over the values, asynchronously waits for the specified time and then triggers the event:

    async { for delay, price in prices do
              do! Async.Sleep(delay)
              evt.Trigger(price) }
    |> Async.StartImmediate
    

    I’m starting the workflow using StartImmediate which means that it will run on the current thread (the waiting is asynchronous, so it doesn’t block the thread). Keeping everything single-threaded makes it a bit simpler (e.g. you can safely access GUI controls).

    EDIT To wrap the functionality in some component that could be used from other parts of the application, you could define a type like this:

    type ReplyDataStream(prices) =
      let evt = new Event<float>()
      member x.Reply() = 
        // Start the asynchronous workflow here
      member x.PriceChanged = 
        evt.Publish
    

    The users can then create an instance of the type, attach their event handlers using stream.PriceChanged.Add(...) and then start the replaying the recorded changes using Reply()

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this recorded in SQL Server: 1- startTime (datetime): 5/2/2009 08:30 (brazilian time
I want to check my database for records that I already have recorded before
I have a table of events with a recorded start and end time as
Do all voice-to-text algorithms of current technology operate in real-time? I don't mean with
I have recorded a very simple test case Using the Selenium IDE integrated with
I have a file with a bunch of lines. I have recorded a macro
I have made Iphone applicatio. In my application whatever data i have recorded; all
A few test scenarios have been recorded using CodedUI test template for my web
I have a number of tracks recorded by a GPS, which more formally can
I have a site where i'm showing 2 tutorial videos recorded with Camtasia. They

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.