From 501f2d49e1f19b051dca6bb204490cf1908458be Mon Sep 17 00:00:00 2001 From: Jasen Mackie Date: Fri, 13 Mar 2020 01:56:39 +0000 Subject: [PATCH] Update test for stoptrailing trade price assertions Thanks @kvekka for testing --- tests/testthat/test_demo_maCross_stoptrailing.R | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/testthat/test_demo_maCross_stoptrailing.R b/tests/testthat/test_demo_maCross_stoptrailing.R index 1c496a9..639bf65 100644 --- a/tests/testthat/test_demo_maCross_stoptrailing.R +++ b/tests/testthat/test_demo_maCross_stoptrailing.R @@ -22,10 +22,22 @@ test_that("num orders equals 17", { }) test_that("sum closed order prices equals sum txn prices", { - expect_equal(sum(as.numeric(getOrderBook("Port.Luxor")$Port.Luxor$AAPL$Order.Price[which(getOrderBook("Port.Luxor")$Port.Luxor$AAPL$Order.Status == "closed")])), + expect_equal(sum(as.numeric(getOrderBook("Port.Luxor")$Port.Luxor$AAPL$Order.Price[which(getOrderBook("Port.Luxor")$Port.Luxor$AAPL$Order.Status == "closed")])), sum(getTxns("Port.Luxor","AAPL")$Txn.Price)) }) +test_that("stoptrailing trade prices equal 150.7013, 151.2416, 163.0308, 164.8702, 168.1434", { + expect_equal(round(as.numeric(getOrderBook("Port.Luxor")$Port.Luxor$AAPL$Order.Price[which(getOrderBook("Port.Luxor")$Port.Luxor$AAPL$Order.Status == "closed" & getOrderBook("Port.Luxor")$Port.Luxor$AAPL$Order.Type == "stoptrailing")]$Order.Price), 4), + + # 2017-08-02 00:00:00.00001 "150.70126151877" + # 2017-10-17 00:00:00.00001 "151.241571914452" + # 2018-03-22 00:00:00.00009 "163.030760854114" + # 2018-04-19 00:00:00.00009 "164.870181860637" + # 2018-11-23 00:00:00.00009 "168.14344619348" + + c(150.7013, 151.2416, 163.0308, 164.8702, 168.1434)) +}) + # Commands for running this test file from the console if required: # # require(testthat)