Re: [R-SIG-Finance] Generating a front month only Time Series for Futures Prices

2012-05-04 Thread gussinsky
Hey Garrett,

I think the ContinousSeriesCreator, is probably exactly what I am looking
for. Thanks, and how did you find this function?? I will have to find out
what the impact is on the location spreads, caused by different roll dates.
But I think Gasoil and Heating Oil are expiring similarly.

The Trade Blox adjusted series, are problaby very useful for long/short
Backtesting, so thanks for this as well. 

I was trying to find cointegrated pairs of future contracts, but therefore I
need to make these series comparable. Especially in Energy, there are
various relationships around, which are worth investigating.

HO vs. Gasoil, so location spread
Power vs. Gas, Spark Spread
Power vs. Coal, Dark Spread
Gas on one location, vs Gas on another location
WTI Crude vs. Brent
etc.

Although I must admit, many of these spreads are very commercially driven,
so its usually the smart money moving these spreads.

That's what I am trying to investigate a bit further.

Thanks Garrett!


Best


Sven



--
View this message in context: 
http://r.789695.n4.nabble.com/Generating-a-front-month-only-Time-Series-for-Futures-Prices-tp4606794p4608088.html
Sent from the Rmetrics mailing list archive at Nabble.com.

___
R-SIG-Finance@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.


Re: [R-SIG-Finance] Generating a front month only Time Series

2012-05-04 Thread Edouard Tallent
i wish there was a finite answer to this question. :-)

as regards automating the wheat-corn spread, you've to fully realize that these 
are agricultural commodities.
crop calendars are different, both cultivations respond differently to weather 
conditions, US wheat prices move with international commercial activity, 
ethanol market is a main driver of US corn prices, and so on ... and forces in 
actions are likely to vary from one year to the next.
i'm not saying i know much more than you do. no way. just a kind warning if you 
come from equities or forex.

good luck in your endeavors.

best
édouard

http://quantcorner.wordpress.com

===

Message: 10
Date: Thu, 3 May 2012 13:07:11 -0700 (PDT)
From: gussinsky sd...@hotmail.com
To: r-sig-finance@r-project.org
Subject: Re: [R-SIG-Finance] Generating a front month only Time Series
for Futures Prices
Message-ID: 1336075631561-4606979.p...@n4.nabble.com
Content-Type: text/plain; charset=us-ascii

Hey Garrett, 

thank you for this, I had a read through this page in the book you
referenced. And looking at Agricultural Commodities this makes a lot of
sense. And if you look at Wheat and Corn on the CBOT, I think you only have
5 deliveries per year, hence the massive gaps when each contract rolls off.
So here the interpolation makes sense, and I think one could approach this
trade as a box.

But lets consider for example heating oil again, here you have monthly
deliveries, and the seasonality is far less nowadays, in Europe even less
due to the increased Diesel consumption on the roads. 

But lets consider this:

Trading in a current month shall cease on the last business day of the
month preceding the delivery month.

This is the expiry rule for Heating Oil on the Nymex. I think this is
codeable without minefields isn't it. It would be terrific if anyone could
point me in the right direction on how to approach this.

I think it wont be possible to download this with one simple function. I
suspect one would have to store individual files for the respective expiry
contracts, and perhaps index the file names. And then perhaps through a loop
function could read out the corresponding 1:n values for each month, store
them in an array, and then run the next month with the same rule, and store
them again, etcIn the end one needs to connect all those arrays into one
big time series.

And here is my problem, I dont know how to code this, I know what I want

Many thanks for the advice so far


Best


Gussinsky


PS: Garrett, it is your Pair Trading code that brought this up my mind again
:-)

___
R-SIG-Finance@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.

Re: [R-SIG-Finance] Generating a front month only Time Series for Futures Prices

2012-05-04 Thread G See
On Fri, May 4, 2012 at 3:27 AM, gussinsky sd...@hotmail.com wrote:
 Hey Garrett,

 I think the ContinousSeriesCreator, is probably exactly what I am looking
 for. Thanks, and how did you find this function??

No special search skills, I just try to keep track of what code is in
packages I maintain. ;-)

___
R-SIG-Finance@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.


[R-SIG-Finance] Cant get this Quantstrat going,

2012-05-04 Thread gussinsky
Hello All,

#simple Long only Strategie basierend auf CCI Threshhold Entry und Exit

###
###
###

suppressWarnings(rm(order_book.RSI, pos=.strategy))
suppressWarnings(rm(account.RSI, portfolio.RSI, pos=.blotter))
suppressWarnings(rm(account.st, portfolio.st, stock.str, initDate,
initEq, 'start_t', 'end_t'))

require(quantstrat)

#Define Instrument

x = HO
symbol = getSymbols(x, src='tblox')
names(HO) = c(Open, High, Low, Close, Volume, OpenInterest,
Month, Else)

#Define Start Date

initDate = '2004-01-01'

#Define equity

initEq = 10


#Strategy

stratCCI = strategy(CCI)


#Portfolio

port.st = 'CCI'
initPortf(port.st, symbols=symbol, initDate=initDate)

#Account

initAcct(port.st, portfolios=port.st, initDate=initDate)

#Orders

initOrders(portfolio=port.st, initDate=initDate)

#Indicator 

stratCCI = add.indicator(strategy = stratCCI, name = CCI, arguments =
list(price = quote(getPrice(mktdata))), label=CCI)

#s
# CCI   -100, relation gt= greater than, 
stratCCI = add.signal(strategy=stratCCI, name=sigCCI, arguments =
list(threshold=-100, column=CCI, relationship=gt, cross=TRUE),
label=CCI.gt.-100)
#CCI  100, relation lt= lower than,
stratCCI = add.signal(strategy=stratCCI, name=sigCCI, arguments =
list(threshold=100, solumn=CCI, relationship=lt, cross=TRUE),
label=CCI.lt.100)

#RTrading Rules

stratCCI = add.rule(strategy=stratCCI, name='ruleSignal', arguments =
list(sigcol=CCI.gt.-100, sigval=TRUE, orderqty=1000, ordertype='market',
orderside='long', pricemethod='market', replace=FALSE), type='enter',
path.dep=TRUE)

stratCCI = add.rule(strategy=stratCCI, name='ruleSignal', arguments =
list(sigcol=CCI.lt.100, sigval=TRUE, orderqty=-1000, ordertype='market',
orderside='short', pricemethod='market', replace=FALSE), type='exit',
path.dep=TRUE)


currency(USD)

start_t = Sys.time()

out = try(applyStrategy(strategy=stratCCI, portfolios=port.st,
parameters=list(n=2)))

end_t = Sys.time()

print(end_t-start_t)

chart.Posn(Portfolio=port.st, Symbol=symbol)


this is the error i get:


out = try(applyStrategy(strategy=stratCCI, portfolios=port.st,
parameters=list(n=2)))
Error in inherits(x, xts) : argument HLC is missing, with no default
In addition: Warning message:
In applyIndicators(strategy = strategy, mktdata = mktdata, parameters =
parameters,  :
  some arguments stored for CCI do not match


What could the problem be here?

Best


Sven



--
View this message in context: 
http://r.789695.n4.nabble.com/Cant-get-this-Quantstrat-going-tp4609350.html
Sent from the Rmetrics mailing list archive at Nabble.com.

___
R-SIG-Finance@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.


Re: [R-SIG-Finance] Cant get this Quantstrat going,

2012-05-04 Thread gussinsky
Apologies for cross posting didnt see the other one going through.

Even with your adjustments I dont get it going. Ill keep trying.


Thanks



Sven

--
View this message in context: 
http://r.789695.n4.nabble.com/Cant-get-this-Quantstrat-going-tp4609350p4609466.html
Sent from the Rmetrics mailing list archive at Nabble.com.

___
R-SIG-Finance@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.