From noreply at r-forge.r-project.org Fri Aug 1 18:04:05 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 1 Aug 2014 18:04:05 +0200 (CEST) Subject: [Blotter-commits] r1627 - in pkg/blotter: R man Message-ID: <20140801160405.351E0187628@r-forge.r-project.org> Author: efmrforge Date: 2014-08-01 18:04:04 +0200 (Fri, 01 Aug 2014) New Revision: 1627 Modified: pkg/blotter/R/tradeStats.R pkg/blotter/man/tradeStats.Rd Log: Fixed spelling error Modified: pkg/blotter/R/tradeStats.R =================================================================== --- pkg/blotter/R/tradeStats.R 2014-07-27 08:31:43 UTC (rev 1626) +++ pkg/blotter/R/tradeStats.R 2014-08-01 16:04:04 UTC (rev 1627) @@ -68,7 +68,7 @@ #' \item{Percent.Positive}{ percent of trades that end positive } #' \item{Percent.Negative}{ percent of trades that end negative } #' \item{Profit.Factor}{ absolute value ratio of gross profits over gross losses } -#' \item{Avg.Win.Trade}{ mean P&L of profitabloe trades } +#' \item{Avg.Win.Trade}{ mean P&L of profitable trades } #' \item{Med.Win.Trade}{ median P&L of profitable trades } #' \item{Avg.Losing.Trade}{ mean P&L of losing trades } #' \item{Med.Losing.Trade}{ median P&L of losing trades } Modified: pkg/blotter/man/tradeStats.Rd =================================================================== --- pkg/blotter/man/tradeStats.Rd 2014-07-27 08:31:43 UTC (rev 1626) +++ pkg/blotter/man/tradeStats.Rd 2014-08-01 16:04:04 UTC (rev 1627) @@ -44,7 +44,7 @@ positive } \item{Percent.Negative}{ percent of trades that end negative } \item{Profit.Factor}{ absolute value ratio of gross profits over gross losses } \item{Avg.Win.Trade}{ -mean P&L of profitabloe trades } \item{Med.Win.Trade}{ +mean P&L of profitable trades } \item{Med.Win.Trade}{ median P&L of profitable trades } \item{Avg.Losing.Trade}{ mean P&L of losing trades } \item{Med.Losing.Trade}{ median P&L of losing trades } \item{Avg.Daily.PL}{mean daily From noreply at r-forge.r-project.org Sat Aug 2 15:13:46 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 2 Aug 2014 15:13:46 +0200 (CEST) Subject: [Blotter-commits] r1628 - pkg/quantstrat/R Message-ID: <20140802131346.8F4EA186F81@r-forge.r-project.org> Author: bodanker Date: 2014-08-02 15:13:46 +0200 (Sat, 02 Aug 2014) New Revision: 1628 Modified: pkg/quantstrat/R/rules.R Log: - Fix bug 5802 in applyRules; thanks to Jonathan Owen for the report Modified: pkg/quantstrat/R/rules.R =================================================================== --- pkg/quantstrat/R/rules.R 2014-08-01 16:04:04 UTC (rev 1627) +++ pkg/quantstrat/R/rules.R 2014-08-02 13:13:46 UTC (rev 1628) @@ -492,8 +492,15 @@ holdtill=first(time(Dates))-1 # TODO FIXME make holdtill default more robust? mktinstr<-getInstrument(symbol) curIndex<-1 - if(nrow(mktdata)>1) freq <- periodicity(mktdata) # run once and pass to ruleOrderProc - else if (indexClass(mktdata) == 'Date') freq='daily' + if(nrow(mktdata)>1) + freq <- periodicity(mktdata) # run once and pass to ruleOrderProc + else { + # For applyStrategy.rebalancing, which could run on a 1-row subset of mktdata + # This should work for all index classes in ruleOrderProc's default switch expression + freq <- structure(list(difftime = structure(NA, units="secs", class="difftime"), + frequency=1, start=start(mktdata), end=end(mktdata), units="secs", + scale="seconds", label="second"), class="periodicity") + } # do order price subsetting outside of nextIndex and curIndex loop # this avoids repeated [.xts calls; and mktPrices is never altered, so copies aren't made From noreply at r-forge.r-project.org Sun Aug 3 03:04:52 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 3 Aug 2014 03:04:52 +0200 (CEST) Subject: [Blotter-commits] r1629 - pkg/quantstrat/R Message-ID: <20140803010452.61D131874EB@r-forge.r-project.org> Author: bodanker Date: 2014-08-03 03:04:51 +0200 (Sun, 03 Aug 2014) New Revision: 1629 Modified: pkg/quantstrat/R/ruleOrderProc.R Log: - Fix bug 5784 in ruleOrderProc; thanks to Claymore Marshall for the report Modified: pkg/quantstrat/R/ruleOrderProc.R =================================================================== --- pkg/quantstrat/R/ruleOrderProc.R 2014-08-02 13:13:46 UTC (rev 1628) +++ pkg/quantstrat/R/ruleOrderProc.R 2014-08-03 01:04:51 UTC (rev 1629) @@ -193,18 +193,18 @@ # check to see if price moved through the limit if((orderQty > 0 && orderType != 'stoplimit') || (orderQty < 0 && (orderType=='stoplimit'))) { # buy limit, or sell stoplimit - if( (has.Lo(mktdata) && orderPrice > as.numeric(Lo(mktdataTimestamp))) || + if( (has.Lo(mktdata) && orderPrice > as.numeric(Lo(mktdataTimestamp)[,1])) || (!has.Lo(mktdata) && orderPrice > as.numeric(getPrice(mktdataTimestamp, prefer=prefer)[,1]))) { - txnprice = min(orderPrice, Hi(mktdataTimestamp)) + txnprice = min(orderPrice, Hi(mktdataTimestamp)[,1]) txntime = timestamp } else next() # price did not move through my order, should go to next order } else if((orderQty < 0 && orderType != 'stoplimit') || (orderQty > 0 && (orderType=='stoplimit'))) { # sell limit or buy stoplimit - if ( (has.Hi(mktdata) && orderPrice < as.numeric(Hi(mktdataTimestamp))) || + if ( (has.Hi(mktdata) && orderPrice < as.numeric(Hi(mktdataTimestamp)[,1])) || (!has.Hi(mktdata) && orderPrice < as.numeric(getPrice(mktdataTimestamp,prefer=prefer)[,1])) ) { - txnprice = max(orderPrice, Lo(mktdataTimestamp)) + txnprice = max(orderPrice, Lo(mktdataTimestamp)[,1]) txntime = timestamp } else next() # price did not move through my order, should go to next order } else { @@ -344,8 +344,8 @@ order.side <- ordersubset[ii, "Order.Side"] - if(order.side == 'long' && as.numeric(Lo(mktdataTimestamp)) < orderPrice - || order.side == 'short' && as.numeric(Hi(mktdataTimestamp)) > orderPrice) + if(order.side == 'long' && as.numeric(Lo(mktdataTimestamp)[,1]) < orderPrice + || order.side == 'short' && as.numeric(Hi(mktdataTimestamp)[,1]) > orderPrice) { txnprice <- orderPrice txntime <- timestamp @@ -357,9 +357,9 @@ order.threshold <- as.numeric(ordersubset[ii, "Order.Threshold"]) if(order.side == 'long') - new.order.price <- max(orderPrice, as.numeric(Hi(mktdataTimestamp)) + order.threshold) + new.order.price <- max(orderPrice, as.numeric(Hi(mktdataTimestamp)[,1]) + order.threshold) if(order.side == 'short') - new.order.price <- min(orderPrice, as.numeric(Lo(mktdataTimestamp)) + order.threshold) + new.order.price <- min(orderPrice, as.numeric(Lo(mktdataTimestamp)[,1]) + order.threshold) if(new.order.price != orderPrice) {