Files
zszq-trs/YLErpUnitTest/Modules/TradeModule/OtcTradeCloseServiceTest.cs
T
2024-05-09 14:06:26 +08:00

66 lines
2.0 KiB
C#

using Microsoft.VisualStudio.TestTools.UnitTesting;
using YLErp.BLL;
using YLErp.DBModels;
using YLErp.DBModels.Consts;
using YLErp.Modules.TradeModule.DealModule;
namespace YLErp.Modules.TradeModule
{
[TestClass]
public class OtcTradeCloseServiceTest : UnitTestBase
{
[TestMethod("执行了结API")]
public void Test()
{
var model = new TradeCloseRequestModel
{
CloseDate = valuedateBLL.ValueDate,
CloseTradeAmountRate = 0.5,
CloseTradeAmount = 50,
CloseType = "平仓",
TradeNumber = "CW20180051C1555",
UnwindPrice = 30,
UnderlyingPrice = 3700,
UnwindVolatility = 0.2
};
var result = new OtcTradeCloseService(CurUser).ExecuteClose(model);
var td = result.Trade;
var tc = result.TradeCash;
var Notional = td.Notional;
if (ConsTrade.TradeCompleteStatus.Contains(td.TradeStatus))
{
Notional = 0;
}
var TcAction = tc.ExerciseWay == TradeCashExerciseWayEnum.到期行权 ? "到期" : "终止";
var TcTradePrice = (td.TradePrice ?? 0) * (tc.UnwindPercentRate ?? 0) * (td.BuySell == "买入" ? -1 : 1);
var WinLoss = tc.Amount + TcTradePrice;
//参考OtcTradeDetail类
var ret = new
{
td.TradeNumber,
td.TradeStatus,
Notional,
TcAction,
TcValueDate = tc.HappenedDate ?? tc.ValueDate,
TcFinalPrice = tc.FinalPrice,
TcUnwindPrice = tc.UnwindPrice,
TcUnwindPricePercent = tc.UnwindPricePercentRate,
TcUnwindNotional = tc.UnwindNotional ?? tc.Notional,
TcUnwindPercent = tc.UnwindPercentRate,
TcAmount = tc.Amount,
WinLoss,
TcTradePrice
};
Assert.AreEqual(tc.Amount, 1500);
}
}
}