I have a function with the follow signare:
apply.strategy(instr, strat)
where instr and strat are both objects of classes instrument and strategy
respectively.
I want to apply this function to a list that holds objects of the class
instrument.
Currently I am doing this by explicit looping:
I have two vectors: both have possible values of 1,-1, or 0
trend1 - c(1,1,1,1,1,1,-1,-1,-1,-1,-1,-1)
trend2 - c(1,1,1,1,1,1,1,1,1,1,1,1,1,1,)
i want to create a third vector that is conditional upon these two vectors:
if (trend2 == 1 trend1 == 1) {position - 1}
elseif (trend2 == -1 trend1==
- c(1,1,1,1,1,1,1,1,1,1,1,-1)
position - as.numeric((trend1 == 1 trend2 == 1) | (trend1 == -1
trend2 == -1))
position
I hope it helps.
Best,
Dimitris
How about (trend1 * trend2 + 1)/2
Jim
On 2/24/2011 9:41 AM, Kushan Thakkar wrote:
I have two vectors: both have possible values
I am using getSymbols function from quantmod package to get price data from
internet.
Currently I have:
my.ticker - IBM
getSymbols(my.ticker,src=google)
This creates an xts object named my.ticker which contains historical price
data for IBM.
How can I call and manipulating this xts object
:
On Feb 23, 2011, at 8:55 AM, Kushan Thakkar wrote:
I am using getSymbols function from quantmod package to get price data
from
internet.
Currently I have:
my.ticker - IBM
getSymbols(my.ticker,src=google)
This creates an xts object named my.ticker which contains historical
price
data
I have a data frame with the following columns:
Date Price Buy Sell
The Buy and Sell variables are binary. They are either zero or 1.
Additionally, they are mutually exclusive. Either Buy is 1, Sell is 1 or
they are both 0. But they are never both 1 for a given observation.
I want to see
I have an object type my.object. One of its slots contains a data frame
(i.e. my.obj...@my.data.frame) .. I want to check if one of the variables
exists in this data frame (i.e. my.obj...@my.data.frame$my.var)
I am trying to use the exists function but can't figure out how the
arguments work.
7 matches
Mail list logo