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 923329
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T19:10:29+00:00 2026-05-15T19:10:29+00:00

I am writing a program to try and derive value from a timeseries set

  • 0

I am writing a program to try and derive value from a timeseries set of stock-trade ideas. They are in a an array of quotedTrade objects below (using JSONSerializer to get the data off of disk) sorted by the startOn date field:

    [<DataContract>] 
    type trade = {
        [<field: DataMember(Name="tradeId") >] 
        tradeId : int ;
        [<field: DataMember(Name="analystId") >] 
        analystId: int
        [<field: DataMember(Name="startOn") >] 
        startOn : System.DateTime ;
        [<field: DataMember(Name="endOn") >] 
        endOn : System.DateTime option ;
        [<field: DataMember(Name="tradeType") >] 
        tradeType : string ;
        [<field: DataMember(Name="securityId") >] 
        securityId : int ;
        [<field: DataMember(Name="ricCode") >] 
        ricCode : string ;
        [<field: DataMember(Name="yahooSymbol") >] 
        yahooSymbol : string ;
        [<field: DataMember(Name="initialPrice") >] 
        initialPrice : float ;
    }

    [<DataContract>] 
    type quotedTrade = {
        [<field: DataMember(Name="trade") >] 
        trade : trade ;
        [<field: DataMember(Name="q7") >] 
        q7: float
        [<field: DataMember(Name="q14") >] 
        q14: float
        [<field: DataMember(Name="q21") >] 
        q21: float
    }

I would like to

  • break view the data two ways

    • by analystId
    • by ticker (either ric or yahoo symbols)
  • then iterate over the views with windows of days

perhaps introducing records:

    type byAnalyst = {
        analystId: int
        trades: quotedTrade array
    }

    type byTicker = {
        symbol: string
        trades: quotedTrade array
    }

and then filter them somehow (sliceByAnalyst, sliceByTicker to be provided later – though sugegstions on a clean solution would be appreciated I am considering the use of Array.Map, Array.Filter functions)

let quotedTrades : quotedTrade array = getTradesFromDisk()
let tradesByAnalyst : byAnalyst array = sliceByAnalyst quotedTrades
let tradesByTicker : byTicker array = sliceByTicker quotedTrades

The main question is around applying a sliding window:

// iterate over each analyst
for tradeByAnalyst in tradesByAnalyst do
    // look at trades on a per analyst basis
    let mySeries : quotedTrade array= tradeByAnalyst.trades
    // each window is an array of trades that occured in a seven day period
    let sevenDayWindowsByAnalyst : quotedTrade array = sliceByDays 7 mySeries
    // I want to evaluate the seven day window, per this analsyt independently
    for sevenDayWindowByAnalyst in sevenDayWindowsByAnalyst do
        let someResult = doSomethingWithTradesInWindow sevenDayWindowByAnalyst

The crux is I have a dataset per analyst where a single trade at day 0 is represented as: T0 and a single trade at day 1 is: T1; my orignal set contains 3 trades at day 0, and individual trades on the 1, 3, 5, 8, 10 periords after:

[ T0 T0 T0 T1 T3 T5 T8 T10 ]

returns

[
  [ T0 T0 T0 T1 T3 T5 ] // incudes T0 -> T6
  [ T1 T3 T5 ] // incudes T1 -> T7
  [ T3 T5 T8 ] // incudes T2 -> T8
  [ T3 T5 T8 ] // incudes T3 -> T9
  [ T5 T8 T10 ] // incudes T4 -> T10
  [ T5 T8 T10 ] // incudes T5 -> T11
  [ T8 T10 ] // incudes T6 -> T12
  [ T8 T10 ] // incudes T7 -> T13
  [ T8 T10 ] // incudes T8 -> T14
  [ T10 ] // incudes T9 -> T15
  [ T10 ] // incudes T10 -> T16
]

Any ideas on the best way to accomplish this would be highly appreciate.

  • 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-15T19:10:30+00:00Added an answer on May 15, 2026 at 7:10 pm

    I think you can probably do something like this to get the trades you care about:

    let sliceByDays n (qts : quotedTrade seq) =
      let dates = qts |> Seq.map (fun qt -> qt.trade.startOn)
      let min = dates |> Seq.min
      let max = dates |> Seq.max
      let days = min |> Seq.unfold (fun d -> if d > max then None else Some(d, d.AddDays(1.)))
      [for d in days do
         let tradesInRange =
           qts
           |> Seq.filter (fun qt -> qt.trade.startOn >= d && qt.trade.startOn < d.AddDays(float n))
         yield tradesInRange]
    

    This gives you a list of sequences of trades, one sequence per day.

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

Sidebar

Related Questions

I'm writing a program that's parsing an XML file to java objects using smooks.
Hi I am trying to serialize an array of objects which are derived from
I am writing a program to try to solve a math problem. I need
I am writing a program to read lines of text from 5 files and
i was writing a program and using double.Try Parse to check if a string
I'm busy writing a Program that Transmits GPS Coordinates to a Server from a
I'm writing a program that checks processes (when they start), and kills any processes
I am writing a program that reads some IDs from a list, figures out
I am writing a pretty basic C program to try to better understand how
I'm writing a program (in C) in which I try to calculate powers of

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.