SQL for this query ?

Discussion in 'App Development' started by syswizard, Apr 3, 2016.

  1. Surgo

    Surgo

    Assuming you mean figure 3, that depends on how exactly you define "10% correction". How would you define it?
     
    Last edited: Apr 3, 2016
  2. So the S&P 500 is at 2000 on Jan 1st, it then goes down to 1800 on April 1st.
    So (2000-1800)/2000 is 10%. Now we have a potential event for the chart.
    Then we count the number of trading days between the two dates.
    The important issue is that the 1800 represents the bottom before the next 10%+ correction occurs. That's the tricky part. We won't know that till the next correction.
    Remember, it's not 10% exactly, but 10%+.
     
  3. Surgo

    Surgo

    Hi syswizard, the problem you posed is still ill-defined. Does the 2000 represent a peak (ie the prior day is < 2000), or is it entirely arbitrary (ie the prior day could be > 2000)?
     
  4. No it isn't. All you need is the close price data and a starting date. That's it. It could be 1/1/2000 or 10/1/2010.
    It's not straightforward, that's for sure. It may require a cursor, not sure. Still thinking about it.
     
  5. dartmus

    dartmus

    You linked to a source without indicating precisely what u wanted to create. It's often better to descrbe what u want, even going as far as explaining the parts that aren't clear. That way at least the parts that are know will be readily available to anyone, like me, who has an interest without us having to read thru the article. Ideally u would understand exactly what u want and describe it in detail. That said, I don't have time for this except occassionally so don't count on my participation.

    but it's always interesting to read a summary or specification of tools that can be used to create new strategies, so please carry on ....and pick up the pace! :)
     
  6. dartmus

    dartmus

    Yes, we have a close price. What do u want to do with it next?
     
  7. Dude - you are just not "getting it"...or what ?
    Did you not read the caption of the chart that was linked ?
    It's a count of the number of downturns for a given symbol where there was a 10% percent or greater drop from the prior high point.
    GET IT ?
    This is a really interesting market stat - as I've never heard of it before.
    I guess also apply in reverse....to count the number of "upturns" as well.
     
  8. dartmus

    dartmus

    I get it. What part do u need help with?
     
  9. "Show me the code".
    Either T-SQL or PL/SQL would do fine.
    Cursorless would be preferred, but I am not sure it's possible.
     
    #10     Apr 5, 2016