From 013641a0b4d052fdb0ea69a891df502498943a0b Mon Sep 17 00:00:00 2001 From: Helius <wangdoubleone@gmail.com> Date: Fri, 28 Aug 2020 17:29:26 +0800 Subject: [PATCH] modify --- src/test/java/com/xcong/excoin/WholeTest.java | 70 +++++++++++++++++++++++++++++++++++ 1 files changed, 70 insertions(+), 0 deletions(-) diff --git a/src/test/java/com/xcong/excoin/WholeTest.java b/src/test/java/com/xcong/excoin/WholeTest.java index e685505..d488385 100644 --- a/src/test/java/com/xcong/excoin/WholeTest.java +++ b/src/test/java/com/xcong/excoin/WholeTest.java @@ -1,10 +1,18 @@ package com.xcong.excoin; +import com.alibaba.fastjson.JSONObject; +import com.xcong.excoin.common.contants.AppContants; +import com.xcong.excoin.common.enumerates.CoinTypeEnum; +import com.xcong.excoin.common.enumerates.RabbitPriceTypeEnum; import com.xcong.excoin.modules.contract.dao.ContractHoldOrderDao; import com.xcong.excoin.modules.contract.entity.ContractHoldOrderEntity; import com.xcong.excoin.modules.contract.service.RabbitOrderService; import com.xcong.excoin.modules.member.dao.MemberDao; +import com.xcong.excoin.modules.member.dao.MemberWalletContractDao; import com.xcong.excoin.modules.member.entity.MemberEntity; +import com.xcong.excoin.modules.member.entity.MemberWalletContractEntity; +import com.xcong.excoin.rabbit.pricequeue.OrderModel; +import com.xcong.excoin.rabbit.producer.OrderProducer; import com.xcong.excoin.utils.CalculateUtil; import com.xcong.excoin.utils.ThreadPoolUtils; import org.junit.jupiter.api.Test; @@ -12,6 +20,7 @@ import org.springframework.boot.test.context.SpringBootTest; import javax.annotation.Resource; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.List; @@ -30,6 +39,9 @@ @Autowired private RabbitOrderService rabbitOrderService; + @Autowired + private MemberWalletContractDao memberWalletContractDao; + @Test public void forceClosePriceTest() { MemberEntity memberEntity = memberDao.selectById(5L); @@ -47,5 +59,63 @@ rabbitOrderService.cancelHoldOrder(ids); } + @Test + public void wholeContractWalletTest() { + List<MemberEntity> memberEntities = memberDao.selectAllMember(); + for (MemberEntity member : memberEntities) { + CoinTypeEnum[] values = CoinTypeEnum.values(); + for (CoinTypeEnum value : values) { + MemberWalletContractEntity walletContract = new MemberWalletContractEntity(); + if (value.name().equals(CoinTypeEnum.USDT.name())) { + continue; + } + + walletContract.setMemberId(member.getId()); + walletContract.setAvailableBalance(AppContants.INIT_MONEY); + walletContract.setFrozenBalance(AppContants.INIT_MONEY); + walletContract.setTotalBalance(AppContants.INIT_MONEY); + walletContract.setBorrowedFund(AppContants.INIT_MONEY); + walletContract.setWalletCode(value.name()); + memberWalletContractDao.insert(walletContract); + } + } + } + + + @Test + public void bondAmountTest() { + BigDecimal openPrice = BigDecimal.valueOf(412.52124800); + + System.out.println(CalculateUtil.getBondAmount(openPrice, BigDecimal.valueOf(6), 1, 5)); + } + + @Autowired + private OrderProducer orderProducer; + + @Test + public void sendMsg() { + List<OrderModel> list = new ArrayList<>(); + OrderModel orderModel = new OrderModel(1L, RabbitPriceTypeEnum.ENTRUST_OPEN_MORE.getValue(), "111", "BTC"); + list.add(orderModel); + orderProducer.sendLimitClose(JSONObject.toJSONString(list)); + } + + + // 面值*(多单张数*多单开仓价-空单张数*空单开仓价)-余额-已实现盈亏 / 面值*(多单张数-空单张数)-(维持保证金率+TAKER手续费)*面值*(开多张数+开空张数) + + /* + 面值 : 0.1000 * 678 + 多单张数 : 300 开仓价 : 11400.53000000 -> 3420159 + 空单张数 : 300 开仓价 : 11398.27000000 -> 3419481 + 余额 : 562.92683993 -495.12 + + 手续费率 : 0.0460 + + + */ + @Test + public void forceSetPriceTest() { + + } } -- Gitblit v1.9.1