从山证v2.3.0拷贝
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
using Qdp.Foundation.Implementations;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using YLErp.Abstract.DataProviders;
|
||||
using YLErp.Modules.DictionaryModule;
|
||||
using YLErp.Modules.TradeModule.AccumulatorOptionModule;
|
||||
|
||||
namespace YLErp.Modules.TradeModule
|
||||
{
|
||||
[TestClass]
|
||||
public class TradeAccumulatorServiceTest
|
||||
{
|
||||
[TestMethod]
|
||||
public void TestConvertForward()
|
||||
{
|
||||
var dictionarySerivice = new DictionarySerivice();
|
||||
var dic = dictionarySerivice.GetForwardDateDic();
|
||||
var dicModel = dic.FirstOrDefault(l => l.Value == "标的交割月前一交易日");
|
||||
var basedb = DbContextFactory.GetErpBaseContext();
|
||||
var date = new DateTime(2023, 5, 17);
|
||||
DateTime exerciseDate = default;
|
||||
|
||||
if (dicModel.Value != null)
|
||||
{
|
||||
var model = basedb.DictionaryItems.Find(dicModel.Key);
|
||||
var lastMonth = Convert.ToInt32(model.Name);
|
||||
if (model.ShortName.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries).Any())
|
||||
{
|
||||
var lastDay = Convert.ToInt32(model.ShortName.Split(",")[0]);
|
||||
var typeEnum = (ForwardDateTypeEnum)Convert.ToInt32(model.ShortName.Split(",")[1]);
|
||||
var isbefore = true;
|
||||
if (Convert.ToInt32(model.ShortName.Split(",")[1]) > 0)
|
||||
{
|
||||
isbefore = model.ShortName.Split(",")[2] == "0";
|
||||
}
|
||||
exerciseDate = dictionarySerivice.GetForwardDateType(date, lastMonth, lastDay, typeEnum, isbefore);
|
||||
}
|
||||
}
|
||||
|
||||
Assert.AreEqual(exerciseDate, new DateTime(2023, 4, 18));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestConvertForward2()
|
||||
{
|
||||
var db = DbContextFactory.GetYLDbContext();
|
||||
var td = db.trade.FirstOrDefault(n => n.TradeNumber == "CW20230002OP230320002X");
|
||||
Assert.IsNotNull(td);
|
||||
var tdAcc = db.trade_accumulator_option.FirstOrDefault(n => n.TradeId == td.id);
|
||||
Assert.IsNotNull(tdAcc);
|
||||
|
||||
var valueDate = new DateTime(2023, 03, 21);
|
||||
var result = TradeAccumulatorService.CheckAccumulatorPayoff(td, tdAcc, valueDate, -300, tdAcc.AccumuTradeAmount);
|
||||
Assert.IsNotNull(result.ForwardTrade);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user