[R-SIG-Finance] Handling half hourly data from electricity markets
Adrian Ladaniwskyj
Adrian.Ladaniwskyj at hydro.com.au
Wed Jun 22 08:08:32 CEST 2011
Hi all;
I am attempting to conduct analysis on half hourly Australian NEM
electricity market wholesale price data.
I need a way to parse a half hourly dataset, and generate Yearly,
Quarterly, and Monthly peak/offpeak average prices, in line with the
form of quoted pricing for typical OTC and futures market energy swap
products.
Peak is defined between 7am and 10pm market time, offpeak 10pm-7am.
(For example , to get the average peak price for jan, 2011, I need to be
able to select ONLY price data from jan 2011, that occurred between 7am
and 10pm, sum the prices, then divide them by the number of instances
for the desired result)
I cannot seem to find an adequate coded example of how to achieve this
as yet.
An example of the data I am working with is set out below:
Iteration Time $/MWh $/MWh $/MWh
2 1 2011-01-01 00:30 22.00 16.37 23.64
3 1 2011-01-01 01:00 17.69 16.53 15.49
4 1 2011-01-01 01:30 16.49 15.00 15.09
5 1 2011-01-01 02:00 12.17 11.73 10.96
6 1 2011-01-01 02:30 7.38 7.20 6.73
7 1 2011-01-01 03:00 6.10 6.24 5.36
8 1 2011-01-01 03:30 5.80 6.24 4.91
9 1 2011-01-01 04:00 4.98 5.40 4.10
10 1 2011-01-01 04:30 5.72 6.24 4.72
If anyone can assist me in this, it would be greatly appreciated.
Cheers;
Adrian Ladaniwskyj | Market Analyst, Spot Tactics
B.Bus, B.Ec(Hons), Dip.FS
logo p +61 3 6230 5495 | f +61 3 6230 5416 | m +61 431 121 711
e adrian.ladaniwskyj at hydro.com.au
w www.hydro.com.au
Level 9, 4 Elizabeth Street, Hobart TAS 7000
Please consider the environment before printing my email
This e-mail and any attachments may contain confidential, proprietary or
legally privileged information. If you are not the intended recipient,
you must not keep, forward, disclose, adapt or copy the material and any
such action is unauthorised and prohibited. If you have received this
e-mail in error, please immediately advise the sender by return email
and delete this e-mail and any attachments from your system.
-----Original Message-----
From: r-sig-finance-bounces at r-project.org
[mailto:r-sig-finance-bounces at r-project.org] On Behalf Of
r-sig-finance-request at r-project.org
Sent: Tuesday, 21 June 2011 8:00 PM
To: r-sig-finance at r-project.org
Subject: R-SIG-Finance Digest, Vol 85, Issue 20
Send R-SIG-Finance mailing list submissions to
r-sig-finance at r-project.org
To subscribe or unsubscribe via the World Wide Web, visit
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
or, via email, send a message with subject or body 'help' to
r-sig-finance-request at r-project.org
You can reach the person managing the list at
r-sig-finance-owner at r-project.org
When replying, please edit your Subject line so it is more specific
than "Re: Contents of R-SIG-Finance digest..."
Today's Topics:
1. fix yahooKeystats (J Toll)
2. Re: New to R and Finance, backtest etc. (David St John)
3. Offset a vector by 1 to k months (Ira Sharenow)
4. Re: New to R and Finance, backtest etc. (me at censix.com)
----------------------------------------------------------------------
Message: 1
Date: Mon, 20 Jun 2011 14:28:45 -0500
From: J Toll <jctoll at gmail.com>
To: r-sig-finance at r-project.org
Subject: [R-SIG-Finance] fix yahooKeystats
Message-ID: <BANLkTikh4h9GVwrzdbuPtjqWwbtG2k=P=Q at mail.gmail.com>
Content-Type: text/plain; charset=UTF-8
Hi,
I wanted to get some input from the more experienced R users regarding
the yahooKeystats function in the fImport package. I believe that the
function is currently broken (Version: 2110.79). It appears that
Yahoo changed their HTML slightly which has caused the function to
break. Several months ago, I managed to get it working and posted
those changes to this list in case anyone else was interested.
https://stat.ethz.ch/pipermail/r-sig-finance/2011q1/007250.html
Since then, I rewrote the yahooKeystats function using the XML
package. I tried contacting the Rmetrics Core Team to offer up this
working code as a possible alternative but haven't gotten a response.
What should I do? It seems like it would be a good idea to
fix/replace the current function with something that works. Or should
I just leave it be and not worry about it. Thanks.
James
------------------------------
Message: 2
Date: Mon, 20 Jun 2011 23:19:23 -0500
From: David St John <dstjohn at math.uic.edu>
To: <r-sig-finance at stat.math.ethz.ch>
Subject: Re: [R-SIG-Finance] New to R and Finance, backtest etc.
Message-ID: <BANLkTikSjtNrW5rAk3Q42bXi9hdBbbRwRg at mail.gmail.com>
Content-Type: text/plain
Another 'shameless' plug...if you're back-testing moving average
strategies,
consider a large family of parameter choices and the possibility of
data-snooping. Also consider persistence across smaller sub-periods.
The
ttrTests package has some good references to papers on the subject, and
a
very limited implementation of the tests in the literature.
Perhaps the developers of quantstrat are interested in including data
snooping tests and tests for persistence from period to period? I would
be
very happy to see the ttrTests package obsolete. As much as I would
love to
make it look and behave more like the quant* packages, I won't have time
to
develop improvements any time soon.
-David
[[alternative HTML version deleted]]
------------------------------
Message: 3
Date: Mon, 20 Jun 2011 22:03:15 -0700
From: "Ira Sharenow" <irasharenow100 at yahoo.com>
To: <r-sig-finance at r-project.org>
Subject: [R-SIG-Finance] Offset a vector by 1 to k months
Message-ID: <004c01cc2fd0$8823eaa0$4401a8c0 at IraHP>
Content-Type: text/plain
I am new to financial time series, zoo, and xts.
I have a length n vector (vDates) of dates. I have an n by k matrix
(mDates). In row i and column j of the matrix, I would like the value to
be the row i value of the vector + j months.
mDates[i,j] = vDates[i] + j months.
I would like to do this without loops.
I solved the problem with just numbers.
v1 = 11:15
m1 = matrix(rep(0,20), nrow = 5)
m1 = v1 + col(m1)
I do not know how to add months in zoo or xts, so I tried lubridate.
library(lubridate)
vDate = as.Date(c("2011-06-01", "2011-06-02", "2011-06-03"), "%Y-%m-%d")
mDate2 = vDate + months(1) this works fine
But I do not know how to solve the problem for a matrix.
library(xts)
charvec = paste("2011-0", 1:2, "-01", sep = "")
theData = matrix(rep(0,6),nrow = 2)
z1 = xts(theData, as.Date(charvec))
I want the rows of z1 data to be
2011-02-01 2011-03-01 2011-04-01
2011-03-01 2011-04-01 2011-05-01
Thanks.
Ira
[[alternative HTML version deleted]]
------------------------------
Message: 4
Date: Tue, 21 Jun 2011 07:48:32 +0200 (CEST)
From: me at censix.com
To: "Ulrich Staudinger" <ustaudinger at gmail.com>
Cc: me at censix.com, r-sig-finance at r-project.org
Subject: Re: [R-SIG-Finance] New to R and Finance, backtest etc.
Message-ID: <57357.78.234.67.201.1308635312.squirrel at censix.com>
Content-Type: text/plain;charset=iso-8859-1
Hi
well, I am currently testing an intraday version of the 'qsiblive'
function collection. For now everything above the 30sec bars seems to be
working fine (looking at realTimeBars only). One has to be mindful of
indicator and signal calculations though. If these slow things down to
much, using longer bars may be the only option, aside from optimizing
the
indicator/signal processing (which certainly needs to be done at some
point in the future)
Soren
> Hey guys,
>
> has anyone ever checked runtime statistics, in the sense of processing
> speed, etc. of R in live trading?
> Obviously, it is possible to also implement C equations, but I am
> wondering
> if R etc are used in real intraday trading and about the performance
> characteristics observed.
>
> Thanks
> Ulrich
>
>
>
>
> On Sun, Jun 19, 2011 at 3:08 PM, <me at censix.com> wrote:
>
>> Alex
>>
>> once you have developed a strategy in 'quantstrat' and if you feel
>> adventurous and want to use it for live trading, I can (shamelessly)
>> recommend that you have a look at my 'qsiblive' download here.
>>
>> http://censix.com
>>
>> It may be of interest.
>>
>> regards
>>
>> Soren
>>
>>
>>
>> > Hi there,
>> >
>> > I am new to R and want to perform a few experiments with trading
>> > strategies
>> > with R.
>> >
>> > However, I have experience in programming, but not in R (it's very
>> similar
>> > to what a programmer would expect).
>> >
>> > For now, I've parsed some data (Open, High, Low, Close) of a
security
>> via
>> > read.table, which works fine.
>> > What I want to do now, is to perform a backtest of a simple trading
>> > strategy
>> > with R. Say, for example "buy on cross of MA(200) and MA(100)". Of
>> course
>> > I
>> > could write the backtest routine by myself, but I saw a package
called
>> > backtest. However, I do not really get the point how this may work.
>> How
>> > could I use backtest package to analyse a simple strategy as above?
>> >
>> > Additionally, I would like to know, if there are some websites,
wikis
>> etc.
>> > which give a basic introduction to R in Finance "for dummies"?
>> Anything
>> > I've
>> > seen so far was more or less for professionals.
>> >
>> >
>> > Thank you in advance
>> > Alex
>> >
>> > [[alternative HTML version deleted]]
>> >
>> > _______________________________________________
>> > R-SIG-Finance at r-project.org mailing list
>> > https://stat.ethz.ch/mailman/listinfo/r-sig-finance
>> > -- Subscriber-posting only. If you want to post, subscribe first.
>> > -- Also note that this is not the r-help list where general R
>> questions
>> > should go.
>> >
>>
>>
>> --
>> http://censix.com
>>
>> _______________________________________________
>> R-SIG-Finance at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
>> -- Subscriber-posting only. If you want to post, subscribe first.
>> -- Also note that this is not the r-help list where general R
questions
>> should go.
>>
>
>
>
> --
> Ulrich Staudinger
>
> http://www.activequant.org
> Connect online: https://www.xing.com/profile/Ulrich_Staudinger
>
--
http://censix.com
------------------------------
_______________________________________________
R-SIG-Finance mailing list
R-SIG-Finance at r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
End of R-SIG-Finance Digest, Vol 85, Issue 20
More information about the R-SIG-Finance
mailing list