473,399 Members | 3,401 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

find consecutive events and see what happens later

Hi All,

I want to look at what happens to stock prices after a certain number
of consecutive up or down days. Let's say, for instance, I'd like to
see where a stock's price is 5 days after a run of 5 consecutive up
days.

I can't even begin to figure out the queries needed to accomplish
this. Maybe somebody can help me.

Here are my db fields:
symbol
date
adj_open (adj stands for adjusted, i.e. adjusted for splits)
adj_close

I know how to get the calculated field (adj_close - adj_open) to
determine whether it's an up or down day. In fact, I know how to do
many types of queries based on individual records, but I have no idea
how to do queries whose results are based on other records. For
instance, consider the following:
1.) I need to determine "consecutiveness" (forgive me for
inventing words). How to do that?
2.) After getting consecutiveness, I need to jump ahead 5 days
and look at price. How to do that?

Any ideas would be greatly appreciated!

Nelson

May 18 '07 #1
3 1722
On 17 May 2007 17:42:07 -0700, Nelson <hu**********@yahoo.comwrote:

This very hard to do in SQL, because it is a set-based language, not a
procedural one. Processing records sequentially is not one of its
strong suits.
Come to the rescue: VBA programming with recordsets. Once you get the
hang of it it's pretty trivial to write code that can look for these
patterns as it is looping over an ordered set of records.

-Tom.
>Hi All,

I want to look at what happens to stock prices after a certain number
of consecutive up or down days. Let's say, for instance, I'd like to
see where a stock's price is 5 days after a run of 5 consecutive up
days.

I can't even begin to figure out the queries needed to accomplish
this. Maybe somebody can help me.

Here are my db fields:
symbol
date
adj_open (adj stands for adjusted, i.e. adjusted for splits)
adj_close

I know how to get the calculated field (adj_close - adj_open) to
determine whether it's an up or down day. In fact, I know how to do
many types of queries based on individual records, but I have no idea
how to do queries whose results are based on other records. For
instance, consider the following:
1.) I need to determine "consecutiveness" (forgive me for
inventing words). How to do that?
2.) After getting consecutiveness, I need to jump ahead 5 days
and look at price. How to do that?

Any ideas would be greatly appreciated!

Nelson
May 18 '07 #2
On May 18, 11:11 am, Tom van Stiphout <no.spam.tom7...@cox.netwrote:
On 17 May 2007 17:42:07 -0700, Nelson <huskies_b...@yahoo.comwrote:

This very hard to do in SQL, because it is a set-based language, not a
procedural one. Processing records sequentially is not one of its
strong suits.
Come to the rescue: VBA programming with recordsets. Once you get the
hang of it it's pretty trivial to write code that can look for these
patterns as it is looping over an ordered set of records.

-Tom.
Hi All,
I want to look at what happens to stock prices after a certain number
of consecutive up or down days. Let's say, for instance, I'd like to
see where a stock's price is 5 days after a run of 5 consecutive up
days.
I can't even begin to figure out the queries needed to accomplish
this. Maybe somebody can help me.
Here are my db fields:
symbol
date
adj_open (adj stands for adjusted, i.e. adjusted for splits)
adj_close
I know how to get the calculated field (adj_close - adj_open) to
determine whether it's an up or down day. In fact, I know how to do
many types of queries based on individual records, but I have no idea
how to do queries whose results are based on other records. For
instance, consider the following:
1.) I need to determine "consecutiveness" (forgive me for
inventing words). How to do that?
2.) After getting consecutiveness, I need to jump ahead 5 days
and look at price. How to do that?
Any ideas would be greatly appreciated!
Nelson- Hide quoted text -

- Show quoted text -
Thanks Tom!

Just knowing the right terminology to pursue the issue further is
worth its weight in gold. Although, when you think about it, words on
a computer screen don't weigh a helluva lot, do they? But I
digress...

I'll be sure to check out recordsets, and VBA in general.

Cheers.
Nelson

May 18 '07 #3
On 18 May 2007 06:13:57 -0700, Nelson <hu**********@yahoo.comwrote:

Good for you!
Keywords include: OpenRecordset, MoveNext, While Not rs.EOF, and
beyond that it's mostly a matter of keeping track of sequential days
of Up or Down using booleans or integer counters.

-Tom.

>On May 18, 11:11 am, Tom van Stiphout <no.spam.tom7...@cox.netwrote:
>On 17 May 2007 17:42:07 -0700, Nelson <huskies_b...@yahoo.comwrote:

This very hard to do in SQL, because it is a set-based language, not a
procedural one. Processing records sequentially is not one of its
strong suits.
Come to the rescue: VBA programming with recordsets. Once you get the
hang of it it's pretty trivial to write code that can look for these
patterns as it is looping over an ordered set of records.

-Tom.
>Hi All,
>I want to look at what happens to stock prices after a certain number
of consecutive up or down days. Let's say, for instance, I'd like to
see where a stock's price is 5 days after a run of 5 consecutive up
days.
>I can't even begin to figure out the queries needed to accomplish
this. Maybe somebody can help me.
>Here are my db fields:
symbol
date
adj_open (adj stands for adjusted, i.e. adjusted for splits)
adj_close
>I know how to get the calculated field (adj_close - adj_open) to
determine whether it's an up or down day. In fact, I know how to do
many types of queries based on individual records, but I have no idea
how to do queries whose results are based on other records. For
instance, consider the following:
1.) I need to determine "consecutiveness" (forgive me for
inventing words). How to do that?
2.) After getting consecutiveness, I need to jump ahead 5 days
and look at price. How to do that?
>Any ideas would be greatly appreciated!
>Nelson- Hide quoted text -

- Show quoted text -

Thanks Tom!

Just knowing the right terminology to pursue the issue further is
worth its weight in gold. Although, when you think about it, words on
a computer screen don't weigh a helluva lot, do they? But I
digress...

I'll be sure to check out recordsets, and VBA in general.

Cheers.
Nelson
May 18 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: V | last post by:
I have found that when I have a composite control that uses the CreateChildControls method, on a regular page load, Page_Load executes before CreateChildControls, but on a postback it is the...
6
by: allyn44 | last post by:
HI--what I am trying to do is 2 things: 1. Open a form in either data entry mode or edit mode depending on what task the user is performing 2. Cancel events tied to fields on the form if I am in...
4
by: Vishal | last post by:
I need a simple method to find whether there are any instances of consecutive commas (more than 1) in a given string without parsing each character of the string. I tried with strtok() with comma...
1
by: Jim Heavey | last post by:
First time trying to use the Datalist and I can not seem to get the events to fire. I set up my Data List control and I identify the event for the "OnEditCommand". I also set up an...
6
by: rcamarda | last post by:
Hello, I need to find students that have 4 consecutive absences. When a student is absent 4 times in a row, they can be dropped from the class. My class attendance file contains each attendance...
3
by: JohnM | last post by:
Hi there, Are there any specific rules or best-practices I should be aware regarding events and the threads they're fired on. Object 1 can be created on thread 1 for instance and an event then...
8
by: gigonomics | last post by:
Hi all, I hope someone can help me out. I need to return the best available seats subject to the constraint that the seats are side by side (or return X consecutive records from a table column...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.