Advertisement
lituchy

Untitled

Feb 20th, 2020
781
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 17.36 KB | None | 0 0
  1. package com.emfxe.test
  2.  
  3. import com.bmfn.extensions.scaleUp
  4. import com.emfxe.model.position.ProfitAndInvested
  5. import com.emfxe.utils.*
  6. import org.junit.Assert
  7. import org.junit.Test
  8. import java.math.BigDecimal
  9.  
  10. class FormulasTests {
  11.  
  12.     //check maxQTY with cross = 1
  13.     @Test
  14.     fun checkMaxQTYWithIntegerPriceAndIntegerBalanceCrossEqualsOne(){
  15.         Assert.assertEquals(26.toBigDecimal(), (maxQTY(1000.toBigDecimal(), BigDecimal.ONE, 38.toBigDecimal())))
  16.     }
  17.  
  18.     @Test
  19.     fun checkMaxQTYWithFloatPriceAndIntegerBalanceCrossEqualsOne(){
  20.         Assert.assertEquals(4.toBigDecimal(), (maxQTY(1127.toBigDecimal(), BigDecimal.ONE, 257.365.toBigDecimal())))
  21.     }
  22.  
  23.     @Test
  24.     fun checkMaxQTYWithFloatBalanceAndFloatPriceCrossEqualsOne(){
  25.         Assert.assertEquals(3.toBigDecimal(), (maxQTY(5803.48.toBigDecimal(), BigDecimal.ONE, 1568.965.toBigDecimal())))
  26.     }
  27.     @Test
  28.     fun checkMaxQTYWithFloatBalanceAndFIntPriceCrossEqualsOne(){
  29.         Assert.assertEquals(796.toBigDecimal(), (maxQTY(51803.48.toBigDecimal(), BigDecimal.ONE, 65.toBigDecimal())))
  30.     }
  31.  
  32.     //check maxQTY with float cross
  33.  
  34.     @Test
  35.     fun checkMaxQTYWithIntegerPriceAndIntegerBalanceFloatCross(){
  36.         Assert.assertEquals(45.toBigDecimal(), (maxQTY(1722.toBigDecimal(), 0.9874.toBigDecimal(), 38.toBigDecimal())))
  37.     }
  38.  
  39.     @Test
  40.     fun checkMaxQTYWithFloatPriceAndIntegerBalanceFloatCross(){
  41.         Assert.assertEquals(6590.toBigDecimal(), (maxQTY(99999.toBigDecimal(), 0.05896.toBigDecimal(), 257.365.toBigDecimal())))
  42.     }
  43.     @Test
  44.     fun checkMaxQTYWithIntegerPriceAndFloatBalanceFloatCross(){
  45.         Assert.assertEquals(399.toBigDecimal(), (maxQTY(7895.36.toBigDecimal(), 1.97525.toBigDecimal(), 10.toBigDecimal())))
  46.     }
  47.     @Test
  48.     fun checkMaxQTYWithFloatPriceAndFloatBalanceFloatCross(){
  49.         Assert.assertEquals(76.toBigDecimal(), (maxQTY(81965.32.toBigDecimal(), 18.6515.toBigDecimal(), 57.36518.toBigDecimal())))
  50.     }
  51.  
  52.     //check max qty when balance < price
  53.     @Test
  54.     fun checkMaxQTYBalanceLessPriceCrossEqualsOne(){
  55.         Assert.assertEquals(0.toBigDecimal(), (maxQTY(785.toBigDecimal(), BigDecimal.ONE, 1256.toBigDecimal())))
  56.     }
  57.     @Test
  58.     fun checkMaxQtyBalanceLessPriceCrossLessOne(){
  59.         Assert.assertEquals(46.toBigDecimal(), (maxQTY(946.toBigDecimal(), 0.00256.toBigDecimal(), 7895.63.toBigDecimal())))
  60.     }
  61.     @Test
  62.     fun checkMaxQTYBalanceLessPriceCrossMOreThanOne(){
  63.         Assert.assertEquals(0.toBigDecimal(), (maxQTY(1256.toBigDecimal(), 45.23.toBigDecimal(), 11756.toBigDecimal())))
  64.     }
  65.  
  66.     //check min qty
  67.     @Test
  68.     fun checkMinQTYWithMinAmountEqualsZero(){
  69.         Assert.assertEquals(BigDecimal.ONE, (minQTY(BigDecimal.ZERO, 45.23.toBigDecimal())))
  70.     }
  71.     @Test
  72.     fun checkMinQTYWithMinAmountEqualsOne(){
  73.         Assert.assertEquals(BigDecimal.ONE, (minQTY(BigDecimal.ONE, 1.2356.toBigDecimal())))
  74.     }
  75.     @Test
  76.     fun checkMinQTYWitnMinAmountIntAndIntPrice(){
  77.         Assert.assertEquals(31.toBigDecimal(), (minQTY(17896.toBigDecimal(), 596.toBigDecimal())))
  78.     }
  79.     @Test
  80.     fun checkMinQTYWithIntMinAmountAndFloatPrice(){
  81.         Assert.assertEquals(34.toBigDecimal(), (minQTY(1896.toBigDecimal(), 56.25698.toBigDecimal())))
  82.     }
  83.     @Test
  84.     fun checkMinQTYWithFloatMinAmountAndIntPrice(){
  85.         Assert.assertEquals(723.toBigDecimal(), (minQTY(56321.89.toBigDecimal(), 78.toBigDecimal())))
  86.     }
  87.     @Test
  88.     fun checkMinQTYWithFloatMinAmountAndFloatPrice(){
  89.         Assert.assertEquals(2691.toBigDecimal(), (minQTY(9845.36.toBigDecimal(), 3.6589.toBigDecimal())))
  90.     }
  91.     @Test
  92.     fun checkMinQTYWhenMinAmountDivideByPriceLessOne(){
  93.         Assert.assertEquals(BigDecimal.ONE, (minQTY(7896.toBigDecimal(), 12896.354.toBigDecimal())))
  94.     }
  95.  
  96.     //check minQTYAccountCurrency
  97.     @Test
  98.     fun checkMinQTYAccountCurrencyWithIntMinAmountAndIntCross(){
  99.         Assert.assertEquals(425.toBigDecimal(), (minQTYAccountCurrency(5.toBigDecimal(), 85.toBigDecimal())))
  100.     }
  101.     @Test
  102.     fun checkMinQTYAccountCurrencyWithIntMinAmountAndFloatCross(){
  103.         Assert.assertEquals(1222.toBigDecimal(), (minQTYAccountCurrency(14.3659.toBigDecimal(), 85.toBigDecimal())))
  104.     }
  105.     @Test
  106.     fun checkMinQTYAccountCurrencyWithFloatMinAmountAndIntCross(){
  107.         Assert.assertEquals(1198.toBigDecimal(), (minQTYAccountCurrency(14.toBigDecimal(), 85.569.toBigDecimal())))
  108.     }
  109.     @Test
  110.     fun checkMinQTYAccountCurrencyWithFloatMinAmountAndFloatCross(){
  111.         Assert.assertEquals(1483.toBigDecimal(), (minQTYAccountCurrency(14.3659.toBigDecimal(), 103.23.toBigDecimal())))
  112.     }
  113.     @Test
  114.     fun checkMinQTYAccountCurrencyWithCrossEqualsOne(){
  115.         Assert.assertEquals(73.toBigDecimal(), (minQTYAccountCurrency(BigDecimal.ONE, 73.toBigDecimal())))
  116.     }
  117.  
  118.     @Test
  119.     fun checkMinQTYAccountCurrencyWithCrossEqualsNull(){
  120.         Assert.assertEquals(73.toBigDecimal(), (minQTYAccountCurrency(null, 73.toBigDecimal())))
  121.     }
  122.  
  123.     //check neededAmount
  124.     @Test
  125.     fun checkNeededAmountWithIntBalance(){
  126.         Assert.assertEquals(159307.toBigDecimal(),neededAmount(101256.toBigDecimal(),1589.toBigDecimal(),1.589.toBigDecimal()))
  127.     }
  128.     @Test
  129.     fun checkNeededAmountWithFloatBalance(){
  130.         Assert.assertEquals(15840.toBigDecimal(),neededAmount(10968.toBigDecimal(),1589.45.toBigDecimal(),1.589.toBigDecimal()))
  131.     }
  132.     @Test
  133.     fun checkNeededAmountWhenDifferenceMinQTYAndBalanceLessZero(){
  134.         Assert.assertEquals(BigDecimal.ONE,neededAmount(1000.toBigDecimal(),1588.22.toBigDecimal(),1.589.toBigDecimal()))
  135.     }
  136.     @Test
  137.     fun checkNeededAmountWhenBalanceMoreThenMinQTY(){
  138.         Assert.assertEquals((-7236).toBigDecimal(),neededAmount(10.toBigDecimal(),7252.15.toBigDecimal(),1.589.toBigDecimal()))
  139.     }
  140.     @Test
  141.     fun checkNeededAmountWhenBalanceEqualsMinQTY(){
  142.         Assert.assertEquals(BigDecimal.ZERO,neededAmount(18.toBigDecimal(),67.toBigDecimal(),3.685.toBigDecimal()))
  143.     }
  144.  
  145.     @Test
  146.     fun checkInvestmentValueWithIntQTYIntNavIntCross(){
  147.         Assert.assertEquals("520200.00".toBigDecimal(),investmentValue(17.toBigDecimal(), 850.toBigDecimal(), 36.toBigDecimal()))
  148.     }
  149.     @Test
  150.     fun checkInvestmentValueWithIntQTYIntNavFloatCross(){
  151.         Assert.assertEquals(772.07.toBigDecimal(),investmentValue(17.toBigDecimal(), 53.toBigDecimal(), 0.8569.toBigDecimal()).scaleUp(2))
  152.     }
  153.     @Test
  154.     fun checkInvestmentValueWithIntQTYFloatNavIntCross(){
  155.         Assert.assertEquals("5830.10".toBigDecimal(),investmentValue(17.toBigDecimal(), 9.5263.toBigDecimal(), 36.toBigDecimal()).scaleUp(2))
  156.     }
  157.     @Test
  158.     fun checkInvestmentValueWithIntQTYFloatNavFloatCross(){
  159.         Assert.assertEquals(74.27.toBigDecimal(),investmentValue(8.toBigDecimal(), 25.36954.toBigDecimal(), 0.3659.toBigDecimal()).scaleUp(2))
  160.     }
  161.     @Test
  162.     fun checkInvestmentValueWithFloatQTYIntNavIntCross(){
  163.         Assert.assertEquals(4343.06.toBigDecimal(),investmentValue(58.69.toBigDecimal(), 1.toBigDecimal(), 74.toBigDecimal()))
  164.     }
  165.     @Test
  166.     fun checkInvestmentValueWithFloatQTYIntNavFloatCross(){
  167.         Assert.assertEquals(167.95.toBigDecimal(),investmentValue(5.69.toBigDecimal(), 8.toBigDecimal(), 3.68954.toBigDecimal()).scaleUp(2))
  168.     }
  169.     @Test
  170.     fun checkInvestmentValueWithFloatQTYFloatNavIntCross(){
  171.         Assert.assertEquals(250.65.toBigDecimal(),investmentValue(3.25.toBigDecimal(), 8.569.toBigDecimal(), 9.toBigDecimal()).scaleUp(2))
  172.     }
  173.     @Test
  174.     fun checkInvestmentValueWithFloatQTYFloatNavFloatCross(){
  175.         Assert.assertEquals(4.59.toBigDecimal(),investmentValue(2.36.toBigDecimal(), 7.5698.toBigDecimal(), 0.2569.toBigDecimal()).scaleUp(2))
  176.     }
  177.     @Test
  178.     fun checkInvestmentValueWithCrossEqualsNull(){
  179.         Assert.assertEquals("14450.00".toBigDecimal(),investmentValue(17.toBigDecimal(), 850.toBigDecimal(), null))
  180.     }
  181.  
  182.     //check qty
  183.     @Test
  184.     fun checkQTYWithIntInvestIntNavIntCross(){
  185.         Assert.assertEquals(18.toBigDecimal(),qty(1500.toBigDecimal(), 17.toBigDecimal(), 5.toBigDecimal()))
  186.     }
  187.     @Test
  188.     fun checkQTYWithIntInvestIntNavFloatCross(){
  189.         Assert.assertEquals(25.toBigDecimal(),qty(1548.toBigDecimal(), 17.toBigDecimal(), 3.68974.toBigDecimal()))
  190.     }
  191.     @Test
  192.     fun checkQTYWithIntInvestFloatNavIntCross(){
  193.         Assert.assertEquals(261.toBigDecimal(),qty(754.toBigDecimal(), 0.96587.toBigDecimal(), 3.toBigDecimal()))
  194.     }
  195.     @Test
  196.     fun checkQTYWithIntInvestFloatNavFloatCross(){
  197.         Assert.assertEquals(6.toBigDecimal(),qty(65.toBigDecimal(), 1.2569.toBigDecimal(), 9.987456.toBigDecimal()))
  198.     }
  199.     @Test
  200.     fun checkQTYWithFloatInvestIntNavIntCross(){
  201.         Assert.assertEquals(106.toBigDecimal(),qty(8956.65.toBigDecimal(), 17.toBigDecimal(), 5.toBigDecimal()))
  202.     }
  203.     @Test
  204.     fun checkQTYWithFloatInvestIntNavFloatCross(){
  205.         Assert.assertEquals(2.toBigDecimal(),qty(85.36.toBigDecimal(), 8.toBigDecimal(), 9.5682.toBigDecimal()))
  206.     }
  207.     @Test
  208.     fun checkQTYWithFloatInvestFloatNavIntCross(){
  209.         Assert.assertEquals(24.toBigDecimal(),qty(853.26.toBigDecimal(), 7.2156.toBigDecimal(), 5.toBigDecimal()))
  210.     }
  211.     @Test
  212.     fun checkQTYWithFloatInvestFloatNavFloatCross(){
  213.         Assert.assertEquals(2.toBigDecimal(),qty(8753.21.toBigDecimal(), 654.25.toBigDecimal(), 11.6589.toBigDecimal()))
  214.     }
  215.     @Test
  216.     fun checkQTYWithCrossEqualsNull(){
  217.         Assert.assertEquals(59.toBigDecimal(),qty(546.toBigDecimal(), 9.256.toBigDecimal(), null))
  218.     }
  219.     @Test
  220.     fun checkQTYWithResultLessOne(){
  221.         Assert.assertEquals(1.toBigDecimal(),qty(1500.toBigDecimal(), 1726.25.toBigDecimal(), 13.2658.toBigDecimal()))
  222.     }
  223.  
  224.     //check positionValue
  225.     @Test
  226.     fun checkPositionValueWithIntQtyAndIntNav(){
  227.         Assert.assertEquals(7.toBigDecimal(),positionValue(BigDecimal.ONE, 7.toBigDecimal()))
  228.     }
  229.     @Test
  230.     fun checkPositionValueWithIntQtyAndNavLessOne(){
  231.         Assert.assertEquals( 0.03.toBigDecimal(),positionValue(BigDecimal.ONE, 0.02365.toBigDecimal()).scaleUp(2))
  232.     }
  233.     @Test
  234.     fun checkPositionValueWithIntQtyAndLargeNav() {
  235.         Assert.assertEquals(25917741340589.47.toBigDecimal(),
  236.             positionValue(10111256.toBigDecimal(), 2563256.369.toBigDecimal()).scaleUp(2))
  237.  
  238.     }
  239.  
  240.     //check position profit
  241.     @Test
  242.     fun checkPositionProfitWhenCurrentValueEqualsGetInvested(){
  243.         Assert.assertEquals(BigDecimal.ZERO.scaleUp(2), positionProfit(1.7563.toBigDecimal(), 1.7563.toBigDecimal(),17.toBigDecimal(),BigDecimal.ONE, BigDecimal.ONE))
  244.     }
  245.     @Test
  246.     fun checkPositionProfitWhenCurrentValueMoreThenGetInvested(){
  247.         Assert.assertEquals(2238.78.toBigDecimal(), positionProfit(1.7563.toBigDecimal(), 1.1123.toBigDecimal(),99.toBigDecimal(),36.852.toBigDecimal(), 36.215.toBigDecimal()))
  248.     }
  249.     @Test
  250.     fun checkPositionProfitWhenCurrentValueLessGetInvested(){
  251.         Assert.assertEquals((-37.06).toBigDecimal(), positionProfit(11.23659.toBigDecimal(), 11.9863.toBigDecimal(),17.toBigDecimal(),3.852.toBigDecimal(), 3.915.toBigDecimal()))
  252.     }
  253.  
  254.     //check getInvested
  255.     @Test
  256.     fun checkGetInvestedWithIntOpPriceIntVolumeFloatCross(){
  257.         Assert.assertEquals(691.99.toBigDecimal(),getInvested(10.toBigDecimal(),56.toBigDecimal(),1.23569.toBigDecimal()))
  258.     }
  259.     @Test
  260.     fun checkGetInvestedWithIntOpPriceIntVolumeIntCross(){
  261.         Assert.assertEquals("162.00".toBigDecimal(),getInvested(9.toBigDecimal(),6.toBigDecimal(),3.toBigDecimal()))
  262.     }
  263.     @Test
  264.     fun checkGetInvestedWithIntOpPriceFloatVolumeIntCross(){
  265.         Assert.assertEquals("2721.60".toBigDecimal(),getInvested(10.toBigDecimal(),45.36.toBigDecimal(),6.toBigDecimal()))
  266.     }
  267.     @Test
  268.     fun checkGetInvestedWithIntOpPriceFloatVolumeFloatCross(){
  269.         Assert.assertEquals(69.57.toBigDecimal(),getInvested(10.toBigDecimal(),5.63.toBigDecimal(),1.23569.toBigDecimal()))
  270.     }
  271.     @Test
  272.     fun checkGetInvestedWithFloatOpPriceIntVolumeIntCross(){
  273.         Assert.assertEquals(3934.16.toBigDecimal(),getInvested(17.5632.toBigDecimal(),56.toBigDecimal(),4.toBigDecimal()))
  274.     }
  275.     @Test
  276.     fun checkGetInvestedWithFloatOpPriceIntVolumeFloatCross(){
  277.         Assert.assertEquals(4710.96.toBigDecimal(),getInvested(17.5632.toBigDecimal(),56.toBigDecimal(),4.7898.toBigDecimal()))
  278.     }
  279.     @Test
  280.     fun checkGetInvestedWithFloatOpPriceFloatVolumeIntCross(){
  281.         Assert.assertEquals(349.92.toBigDecimal(),getInvested(1.00125.toBigDecimal(),87.3695.toBigDecimal(),4.toBigDecimal()))
  282.     }
  283.     @Test
  284.     fun checkGetInvestedWithFloatOpPriceFloatVolumeFloatCross(){
  285.         Assert.assertEquals(4.57.toBigDecimal(),getInvested(1.632.toBigDecimal(),7.5632.toBigDecimal(),0.3695.toBigDecimal()))
  286.     }
  287.     @Test
  288.     fun checkGetInvestedWhenResultLessOne(){
  289.         Assert.assertEquals(0.01.toBigDecimal(),getInvested(0.12563.toBigDecimal(),1.toBigDecimal(),0.002563.toBigDecimal()))
  290.     }
  291.  
  292.     //check currentValue
  293.     @Test
  294.     fun checkCurrentValueWithIntNavIntCross(){
  295.         Assert.assertEquals("5400.00".toBigDecimal(), currentValue(12.toBigDecimal(),6.toBigDecimal(),75.toBigDecimal()))
  296.     }
  297.     @Test
  298.     fun checkCurrentValueWithIntNavFloatCross(){
  299.         Assert.assertEquals(607.35.toBigDecimal(), currentValue(12.toBigDecimal(),6.3265.toBigDecimal(),8.toBigDecimal()))
  300.     }
  301.     @Test
  302.     fun checkCurrentValueWithFloatNavIntCross(){
  303.         Assert.assertEquals(72773.19.toBigDecimal(), currentValue(1732.695.toBigDecimal(),6.toBigDecimal(),7.toBigDecimal()))
  304.     }
  305.     @Test
  306.     fun checkCurrentValueWithFloatNavFloatCross(){
  307.         Assert.assertEquals(341.57.toBigDecimal(), currentValue(32.1695.toBigDecimal(),0.96523.toBigDecimal(),11.toBigDecimal()))
  308.     }
  309.     @Test
  310.     fun checkCurrentValueWithCrossEqualsNull(){
  311.         Assert.assertEquals(12128.87.toBigDecimal(), currentValue(1732.695.toBigDecimal(),null,7.toBigDecimal()))
  312.     }
  313.     @Test
  314.     fun checkCurrentValueWhenResultLessOne(){
  315.         Assert.assertEquals(0.01.toBigDecimal(), currentValue(0.2563.toBigDecimal(),0.02563.toBigDecimal(),1.toBigDecimal()))
  316.     }
  317.  
  318.     //check redeemCurrentValue
  319.  
  320.     @Test
  321.     fun checkRedeemCurrentValueWithIntCurrentValueIntQtyIntMaxQty(){
  322.         Assert.assertEquals(2.1875.toBigDecimal(),redeemCurrentValue(15.toBigDecimal(), 14.toBigDecimal(), 96.toBigDecimal()))
  323.     }
  324.     @Test
  325.     fun checkRedeemCurrentValueWithFloatCurrentValueIntQtyIntMaxQty(){
  326.         Assert.assertEquals(5.08.toBigDecimal(),redeemCurrentValue(7.56.toBigDecimal(), 49.toBigDecimal(), 73.toBigDecimal()).scaleUp(2))
  327.     }
  328.     @Test
  329.     fun checkRedeemCurrentValueWihenQtyEqualsMaxQty(){
  330.         Assert.assertEquals(3.56.toBigDecimal(),redeemCurrentValue(3.56.toBigDecimal(), 73.toBigDecimal(), 73.toBigDecimal()))
  331.     }
  332.     @Test
  333.     fun checkRedeemCurrentValueWithQtyAndCurrentValueEqualsOne(){
  334.         Assert.assertEquals(0.02.toBigDecimal(),redeemCurrentValue(1.toBigDecimal(), 1.toBigDecimal(), 73.toBigDecimal()).scaleUp(2))
  335.     }
  336.  
  337.     //check totalCurrentValue
  338.     @Test
  339.     fun checkTotalCurrentValueWithIntInvestedIntProfit(){
  340.         Assert.assertEquals(185.toBigDecimal(),totalCurrentValue(100.toBigDecimal(), 85.toBigDecimal()))
  341.     }
  342.     @Test
  343.     fun checkTotalCurrentValueWithIntInvestedFloatProfit(){
  344.         Assert.assertEquals(113.26.toBigDecimal(),totalCurrentValue(100.toBigDecimal(), 13.26.toBigDecimal()))
  345.     }
  346.     @Test
  347.     fun checkTotalCurrentValueWithFloatInvestedIntProfit(){
  348.         Assert.assertEquals(117.56.toBigDecimal(),totalCurrentValue(100.56.toBigDecimal(), 17.toBigDecimal()))
  349.     }
  350.     @Test
  351.     fun checkTotalCurrentValueWithFloatInvestedFloatProfit(){
  352.         Assert.assertEquals(3385.29.toBigDecimal(),totalCurrentValue(1020.06.toBigDecimal(), 2365.23.toBigDecimal()))
  353.     }
  354.     @Test
  355.     fun checkTotalCurrentValueWithNegativeProfit(){
  356.         Assert.assertEquals(491.71.toBigDecimal(),totalCurrentValue(745.36.toBigDecimal(), (-253.65).toBigDecimal()))
  357.     }
  358.     @Test
  359.     fun checkTotalCurrentValueWithNegativeProfitMoreThenInvested(){
  360.         Assert.assertEquals((-2365.17).toBigDecimal(),totalCurrentValue(7500.06.toBigDecimal(), (-9865.23).toBigDecimal()))
  361.     }
  362.     @Test
  363.     fun checkTotalCurrentValueWithProfitEqualsZero(){
  364.         Assert.assertEquals(500.06.toBigDecimal(),totalCurrentValue(500.06.toBigDecimal(), BigDecimal.ZERO))
  365.     }
  366.     @Test
  367.     fun checkTotalCurrentValueWithInvestedEqualsNullAndProfitEqualsZero(){
  368.         Assert.assertEquals(BigDecimal.ZERO,totalCurrentValue(null, BigDecimal.ZERO))
  369.     }
  370.     @Test
  371.     fun checkTotalCurrentValueWithInvestedEqualsNull(){
  372.         Assert.assertEquals(745.56.toBigDecimal(),totalCurrentValue(null, 745.56.toBigDecimal()))
  373.     }
  374.  
  375.     //check val
  376.     @Test
  377.     fun checkVal(){
  378.         val firstPair = ProfitAndInvested((-1256).toBigDecimal(), (-98.3).toBigDecimal())
  379.         val secondPair = ProfitAndInvested((-1256).toBigDecimal(), 852.3.toBigDecimal())
  380.         val thirdPair = ProfitAndInvested((-56).toBigDecimal(), BigDecimal.ZERO)
  381.         val forthPair = ProfitAndInvested(1256.toBigDecimal(), 698.39.toBigDecimal())
  382.         val fifthPair = ProfitAndInvested(BigDecimal.ZERO, BigDecimal.ZERO)
  383.         val sixthPair = ProfitAndInvested((156).toBigDecimal(), BigDecimal.ZERO)
  384.  
  385.         val dataForTest = listOf(firstPair, secondPair, thirdPair, forthPair, fifthPair, sixthPair)
  386.         dataForTest.toTotalProfitWithCurrentValue
  387.  
  388.         Assert.assertEquals((-859.61).toBigDecimal(), dataForTest.toTotalProfitWithCurrentValue.first + dataForTest.toTotalProfitWithCurrentValue.second)
  389.     }
  390. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement