从山证v2.3.0拷贝
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using YLErp.DBModels.Enums;
|
||||
using YLErp.Model.Enum;
|
||||
using YLErp.Modules.ClientModule;
|
||||
using YLErp.Modules.TradeModule.OrderModule;
|
||||
|
||||
namespace YLErp.Modules.HaitongApiTests
|
||||
{
|
||||
//OrderApiController: api/v1/order/option
|
||||
|
||||
[TestClass]
|
||||
public class HaitongApiTest : YLUnitTestBase
|
||||
{
|
||||
[TestMethod]
|
||||
public void TestOrderAPI()
|
||||
{
|
||||
var model = new OtcOptionTradeFullEx
|
||||
{
|
||||
TTMDays = 21.66,
|
||||
StrikeGearingFactor = 1,
|
||||
TradeType = "香草期权",
|
||||
TradeSinglePrice = 129.856,
|
||||
TradeOpenVolatility = 0.3,
|
||||
IsMoneynessOption = "否",
|
||||
TradeAmount = 1.0000,
|
||||
StockEqvNotional = 3660.000,
|
||||
StockEqvNotionalReal = 3660.000,
|
||||
VolType = "交易",
|
||||
UnderlyingInstrumentType = "CommodityFutures",
|
||||
ExerciseDate = new DateTime(2020, 08, 17),
|
||||
TraderName = "超级助理",
|
||||
Strike = 3660.0000,
|
||||
UnderlyingId = 99332671,
|
||||
Notional = 1.0000,
|
||||
OptionType = "看涨",
|
||||
ExerciseMode = "European",
|
||||
NoRiskRate = 0.03,
|
||||
SpotPrice = 3660.0000,
|
||||
UnderlyingCode = "RB2008",
|
||||
TradeDate = new DateTime(2020, 07, 17),
|
||||
BuySell = "卖出",
|
||||
MaturityDate = new DateTime(2020, 08, 17),
|
||||
TradePrice = 129.86,
|
||||
AnnualizeFactor = 1,
|
||||
ParticipationRate = 1,
|
||||
SettlementDate = new DateTime(2020, 08, 17),
|
||||
PremiumRate = 0.03548,
|
||||
InitialMargin = -278.09,
|
||||
AssetBookName = "111",
|
||||
ClientName = "111",
|
||||
TradeNumber = "UnitTest-" + DateTime.Now.ToString("yyyyMMddHHmmss"),
|
||||
TradeCloseVolatility = 0.03,
|
||||
NumOfSmoothingDays = 2,
|
||||
};
|
||||
|
||||
var trade = new OtcTradeSaveService(this).SaveOptionTradeFromApiOrImport(model, TradeSourceEnum.WebApiV2);
|
||||
|
||||
var hedgeVol = DbContext.trade_hedge_vol.FirstOrDefault(n => n.TradeId == trade.id);
|
||||
|
||||
Assert.IsTrue(hedgeVol != null);
|
||||
|
||||
Assert.IsTrue(Math.Abs(hedgeVol.TradeSavedVol - model.TradeOpenVolatility.Value) < 1e-6);
|
||||
|
||||
//var result = new TradeConfirmService(this).tradeConfirm(new[] { trade.id }, true);
|
||||
//Assert.IsTrue(string.IsNullOrWhiteSpace(result.errorMsg));
|
||||
|
||||
var reqModel = new ClientPositionQueryModel
|
||||
{
|
||||
TradeStatus = new[] { EnumTradeStatus.added },
|
||||
ClientId = DataCacheProvider.GetClientDataSource().AsQueryable().First(n => n.Name == "111").id
|
||||
};
|
||||
|
||||
var pagedList = new ClientPositionService(this).GetAllPositionsV2(reqModel);
|
||||
|
||||
Assert.IsTrue(pagedList.Any(n => n.TradeId == trade.id));
|
||||
Assert.IsTrue(pagedList.First(n => n.TradeId == trade.id).HedgeVol > 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user