Dear Joshua,
Sequel to your response below, what package can other nationals whose data are 
not in R use to do analysis and manage assets? Thank You and Best Regards, 
EmekaIntegrity is work your talk don't talk your work

      From: Joshua Ulrich <josh.m.ulr...@gmail.com>
 To: golam sakline <golam.sakl...@gmail.com> 
Cc: r-sig-finance <r-sig-finance@r-project.org>
 Sent: Monday, 8 August 2016, 13:58
 Subject: Re: [R-SIG-Finance] Multi Asset portfolio failing at applyStrategy 
with 'data' must be of a vector type, was 'NULL'
   
On Mon, Aug 8, 2016 at 7:48 AM, golam sakline <golam.sakl...@gmail.com> wrote:
> Hi All,
>
> I have an error at applyStrategy that is failing with "Error in array(x,
> c(length(x), 1L), if (!is.null(names(x))) list(names(x),  : 'data' must be
> of a vector type, was 'NULL'" .
> I believe the problem is occurring at add.indicator function "RT" that
> takes in OHLC(mktdata) data and outputs an univariate series.
> This error doesn't occur when I replace RT with MACD function that takes in
> Cl(mktdata) rather than OHLC.
> This error doesn't occur when I am using RT function with a single asset in
> the symbol i.e. the length(symbol) = 1.
>
> What am I doing wrong or missing here?
>
It is nearly impossible for anyone to help you because your example
uses data (CSVs on your local hard drive) and functions (in
functions.R) that no one else has access to.  And you suspect the
error is related to one of those functions...

> Thanks in advance. Much appreciated.
>
> G
>
> ##########################################################################
> rm(list = ls(all = TRUE))
> setwd("/Users/mm/Documents/R")
> library(lattice)
> library(timeSeries)
> library(timeDate)
> library(PerformanceAnalytics)
> library(quantmod)
> library(xts)
> library(blotter)
> library(TTR)
> library(quantstrat)
> library(FinancialInstrument)
> source("functions.R")
>
> setwd("/Users/mm/Documents/R/UAE")
> options("getSymbols.warning4.0" = FALSE)
> #sessionInfo()
>
> startDate = "2015-07-01"
> symbols <- c("DFMC", "ARTC", "EMAARMALLS", "DUBAIPARKS")
> Sys.setenv(TZ="UTC")
>
> getSymbols("DFM", src="csv",
> col.names=c("Open","High","Low","Close","Volume"))
> getSymbols(symbols, src="csv",
> col.names=c("Open","High","Low","Close","Volume"))
>
>
> initDate <- "2015-07-01"
> initEq <- 100000
> tradeSize <- initEq/length(symbols)
> currency("USD")
> stock(symbols, currency="USD",multiplier=1)
>
> myTheme<-chart_theme()
> myTheme$col$dn.col<- 'lightblue'
> myTheme$col$dn.border <-  'lightgray'
> myTheme$col$up.border <-  'lightgray'
>
>
> par(mfrow=c(2,2))
> for(symbol in symbols)
> {
>  plot(chart_Series(get(symbol),name=symbol))
> }
> par(mfrow=c(1,1))
>
>
> if(exists('.strategy')) rm.strat(qs.strategy)
> if(!exists('.blotter')) .blotter <- new.env()
> if(!exists('.strategy')) .strategy <- new.env()
>
> qs.strategy <- "AD26"
> initPortf(qs.strategy, symbols, initDate=initDate)
> initAcct(qs.strategy,portfolios=qs.strategy, initDate=initDate,
> initEq=initEq)
> initOrders(portfolio=qs.strategy,initDate=initDate)
> strategy(qs.strategy,store=TRUE)
>
> add.indicator("AD26", name = "RT",
>              arguments = list(x=quote(OHLC(mktdata))),label= "RT")
>
> summary(getStrategy(qs.strategy))
>
> #########################################################################
>
> add.signal(qs.strategy, name="sigCrossover",
> arguments=list(columns=c("Close", "RT"), relationship="gte"), label="Buy")
>
> add.signal(qs.strategy, name="sigCrossover",
> arguments=list(columns=c("Close", "RT"), relationship="lt"), label="Sell")
>
> #########################################################################
>
> summary(getStrategy(qs.strategy))
>
> #########################################################################
>
> add.rule(qs.strategy, name='ruleSignal',
>          arguments = list(sigcol="Buy", sigval=TRUE,
>                          prefer ="open",
>                          replace = FALSE,
>                          orderqty = 10,
>                          osFUN = "osFixedDollar",
>                          ordertype='market',
>                          orderside='long',
>                          TxnFees=-5,
>                          orderset ="ocolong"
>          ),
>          type='enter',
>          label = 'LE'
> )
>
> add.rule(qs.strategy, name='ruleSignal',
>          arguments = list(sigcol="Sell", sigval=TRUE,
>                          replace = TRUE,
>                          prefer ="open",
>                          orderqty="all",
>                          ordertype='market',
>                          orderside='long',
>                          TxnFees=-5,
>                          orderset = "ocolong"
>          ),
>          type='exit',
>          label = "LX"
> )
>
> add.rule(qs.strategy, name='ruleSignal',
>          arguments = list(sigcol="Buy", sigval=TRUE,
>                          replace =FALSE,
>                          orderqty="all",
>                          ordertype='stoplimit',
>                          orderside='long',
>                          tmult = TRUE,
>                          threshold = quote(stopLossPercent),
>                          TxnFees=-5,
>                          orderset = "ocolong"
>          ),
>          type='chain',
>          parent = "LE",
>          label = "StopLossLong",
>          enabled = FALSE
> )
>
> summary(getStrategy(qs.strategy))
>
> #enable.rule(qs.strategy, type="chain", label ="StopLoss")
>
> applyStrategy(strategy=qs.strategy , portfolios=qs.strategy, verbose=TRUE)
>
> updatePortf(qs.strategy)
> updateAcct(qs.strategy)
> updateEndEq(qs.strategy)
>
> checkBlotterUpdate("AD26", "AD26")
>
> ##################################################################
>
> OUTPUT:
>
<snip>
>> applyStrategy(strategy=qs.strategy , portfolios=qs.strategy, verbose=TRUE)
> *Error in array(x, c(length(x), 1L), if (!is.null(names(x))) list(names(x),
>  : *
> *  'data' must be of a vector type, was 'NULL'*
> *In addition: Warning messages:*
> *1: In min(j, na.rm = TRUE) :*
> *  no non-missing arguments to min; returning Inf*
> *2: In max(j, na.rm = TRUE) :*
> *  no non-missing arguments to max; returning -Inf*
> *Called from: array(x, c(length(x), 1L), if (!is.null(names(x)))
> list(names(x), *
> *    NULL) else NULL)*
> Browse[1]>
>> updatePortf(qs.strategy)
> [1] "AD26"
>> updateAcct(qs.strategy)
> [1] "AD26"
>> updateEndEq(qs.strategy)
> [1] "AD26"
>>
>> checkBlotterUpdate("AD26", "AD26")
> [1] TRUE
>>
>> sessionInfo()
> R version 3.2.4 (2016-03-10)
> Platform: x86_64-apple-darwin13.4.0 (64-bit)
> Running under: OS X 10.11.6 (El Capitan)
>
> locale:
> [1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8
>
> attached base packages:
> [1] stats    graphics  grDevices utils    datasets  methods  base
>
> other attached packages:
>  [1] quantstrat_0.9.1739          foreach_1.4.3
> blotter_0.9.1741
>  [4] FinancialInstrument_1.2.0    quantmod_0.4-5                TTR_0.23-1
>
>  [7] PerformanceAnalytics_1.4.3541 xts_0.9-7                    zoo_1.7-13
>
> [10] timeSeries_3022.101.2        timeDate_3012.100
> lattice_0.20-33
>
> loaded via a namespace (and not attached):
> [1] rsconnect_0.4.2.2 tools_3.2.4      codetools_0.2-14  grid_3.2.4
>  iterators_1.0.8
>
>        [[alternative HTML version deleted]]
>
> _______________________________________________
> 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.



-- 
Joshua Ulrich  |  about.me/joshuaulrich
FOSS Trading  |  www.fosstrading.com
R/Finance 2016 | www.rinfinance.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.


  
        [[alternative HTML version deleted]]

_______________________________________________
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.

Reply via email to