[Jprogramming] Adding closed dates to stock market data
bill lam
bbill.lam at gmail.com
Fri Oct 14 13:08:41 HKT 2011
I think box is very in-efficient especially for large amoutn of data. I
would use inverted column instead,
[d=. 77247 77251 77252 77253 77254 77257
77247 77251 77252 77253 77254 77257
[s=. 6 6$>:i.6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
[m=. 1 + j. <:1,~ (}.d) - (}:d)
1j3 1 1 1 1j2 1
[m#s
1 2 3 4 5 6
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
0 0 0 0 0 0
0 0 0 0 0 0
1 2 3 4 5 6
The key is to find the a suitable mask (m) for dyad #.
Чтв, 13 Окт 2011, PackRat писал(а):
> Here's some faux stock market data for July 1-11, 2011:
>
> a=. 77247;1;2;3;4;5;6
> a=. a,.(77251;1;2;3;4;5;6)
> a=. a,.(77252;1;2;3;4;5;6)
> a=. a,.(77253;1;2;3;4;5;6)
> a=. a,.(77254;1;2;3;4;5;6)
> a=. a,.(77257;1;2;3;4;5;6)
> a=. |: a
>
> a
> +-----+-+-+-+-+-+-+
> |77247|1|2|3|4|5|6|
> +-----+-+-+-+-+-+-+
> |77251|1|2|3|4|5|6|
> +-----+-+-+-+-+-+-+
> |77252|1|2|3|4|5|6|
> +-----+-+-+-+-+-+-+
> |77253|1|2|3|4|5|6|
> +-----+-+-+-+-+-+-+
> |77254|1|2|3|4|5|6|
> +-----+-+-+-+-+-+-+
> |77257|1|2|3|4|5|6|
> +-----+-+-+-+-+-+-+
>
> The above is how the data appears after reading it in from a CSV file.
>
> As you may note, there are missing dates due to market closures for
> weekends and holidays. I'd like to insert zeroed data so that every
> daynum is accounted for. Here's what I'd like the result to look like:
>
> +-----+-+-+-+-+-+-+
> |77247|1|2|3|4|5|6|
> +-----+-+-+-+-+-+-+
> |77248|0|0|0|0|0|0|
> +-----+-+-+-+-+-+-+
> |77249|0|0|0|0|0|0|
> +-----+-+-+-+-+-+-+
> |77250|0|0|0|0|0|0|
> +-----+-+-+-+-+-+-+
> |77251|1|2|3|4|5|6|
> +-----+-+-+-+-+-+-+
> |77252|1|2|3|4|5|6|
> +-----+-+-+-+-+-+-+
> |77253|1|2|3|4|5|6|
> +-----+-+-+-+-+-+-+
> |77254|1|2|3|4|5|6|
> +-----+-+-+-+-+-+-+
> |77255|0|0|0|0|0|0|
> +-----+-+-+-+-+-+-+
> |77256|0|0|0|0|0|0|
> +-----+-+-+-+-+-+-+
> |77257|1|2|3|4|5|6|
> +-----+-+-+-+-+-+-+
>
> I'm stumped as to how to fill in the missing values. Any assistance
> would be greatly appreciated!
>
>
> Harvey
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
--
regards,
====================================================
GPG key 1024D/4434BAB3 2008-08-24
gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3
More information about the Programming
mailing list