tests/unitTests/runitCalcValues.R

# Author: Peter Carl, RUnit port by Ben McCann

test.calcTxnValue <- function() {
  checkEquals(99, blotter:::.calcTxnValue(TxnQty=10, TxnPrice=10, TxnFees=1))
}

test.calcTxnAvgCost <- function() {
  checkEquals(9.9, blotter:::.calcTxnAvgCost(TxnValue=99, TxnQty=10))
}

test.calcPosAvgCost <- function() {
  checkEquals(101, blotter:::.calcPosAvgCost(PrevPosQty=10, PrevPosAvgCost=100, TxnValue=1020, PosQty=20))
}

test.calcPosAvgCost_C <- function() {
  checkEquals(101, blotter:::.calcPosAvgCost_C(PrevPosQty=10, PrevPosAvgCost=100, TxnValue=1020, PosQty=20))
}

Try the blotter package in your browser

Any scripts or data that you put into this service are public.

blotter documentation built on April 15, 2017, 9:41 a.m.