chore(swap): 删除YLErpUnitTest整个废弃测试项目——不进任何sln无法构建,全部文件冻结于2024-05-09分支拷贝日两年半零维护;68%是OptionCalculatorV1旧副本(sln内UnitTestProject自有副本且被实际引用),其余为被取代的DB依赖手工草稿测试与过期资源。-12351行
This commit is contained in:
@@ -1,61 +0,0 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using System.Text;
|
||||
using YieldChain.Helpers;
|
||||
using YLErp.Helpers;
|
||||
|
||||
namespace YLErp.BaseTests
|
||||
{
|
||||
[TestClass]
|
||||
public class BaseTest
|
||||
{
|
||||
[TestMethod("TestUrlHelper")]
|
||||
public void TestUrlHelper()
|
||||
{
|
||||
var str = "&a=1&b=2&b=3,4&c=555& b b = 8 & b = 8 ";
|
||||
var nv = UrlHelper.ParseQueryString(str);
|
||||
Assert.AreEqual(nv["a"], "1");
|
||||
Assert.AreEqual(nv["b"], "2,3,4,8");
|
||||
|
||||
var str2 = UrlHelper.ParseQueryString(str, "b");
|
||||
Assert.AreEqual(str2, "2");
|
||||
|
||||
var str3 = UrlHelper.ParseQueryString(str, "b", true);
|
||||
Assert.AreEqual(str3, "2,3,4,8");
|
||||
}
|
||||
|
||||
[TestMethod("TestNumberHelper")]
|
||||
public void TestNumberHelper()
|
||||
{
|
||||
var bl = NumberHelper.TryParseNumber("0.5", out double dd, out bool isPercent);
|
||||
Assert.IsTrue(bl);
|
||||
Assert.IsFalse(isPercent);
|
||||
Assert.AreEqual(dd, 0.5);
|
||||
|
||||
bl = NumberHelper.TryParseNumber("0.5%%", out dd, out isPercent);
|
||||
Assert.IsTrue(bl);
|
||||
Assert.IsTrue(isPercent);
|
||||
Assert.AreEqual(dd, 0.005);
|
||||
}
|
||||
|
||||
[TestMethod("TestGzipHelper")]
|
||||
public void TestGzipHelper()
|
||||
{
|
||||
var str = "sdfdfasdfasd是的烦恼你温柔问";
|
||||
var br= GZipHelper.CompressToBytes(str);
|
||||
var str2 = GZipHelper.DecompressString(br);
|
||||
Assert.AreEqual(str, str2);
|
||||
}
|
||||
|
||||
[TestMethod()]
|
||||
public void TestMathRound()
|
||||
{
|
||||
var d = 1.02555;
|
||||
Assert.AreEqual(d.ToString("F2"), "1.03");
|
||||
|
||||
d = 1.01555;
|
||||
Assert.AreEqual(d.ToString("F2"), "1.02");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using YLErp.Models;
|
||||
|
||||
namespace YLErp.CoreTests
|
||||
{
|
||||
[TestClass]
|
||||
public class OtcFormatTest
|
||||
{
|
||||
[TestMethod]
|
||||
public void Test1()
|
||||
{
|
||||
var opt = new OtcFormatOption
|
||||
{
|
||||
grouping = true,
|
||||
rounded = false,
|
||||
precision = 0
|
||||
};
|
||||
|
||||
Assert.AreEqual(opt.Format(1111.55555), "1,111");
|
||||
|
||||
opt = new OtcFormatOption
|
||||
{
|
||||
grouping = true,
|
||||
rounded = false,
|
||||
precision = 2
|
||||
};
|
||||
|
||||
Assert.AreEqual(opt.Format(1111.55555), "1,111.55");
|
||||
|
||||
opt = new OtcFormatOption
|
||||
{
|
||||
grouping = true,
|
||||
rounded = true,
|
||||
precision = 2
|
||||
};
|
||||
|
||||
Assert.AreEqual(opt.Format(1111.55555), "1,111.56");
|
||||
|
||||
opt = new OtcFormatOption
|
||||
{
|
||||
grouping = true,
|
||||
rounded = true,
|
||||
precision = 0
|
||||
};
|
||||
Assert.AreEqual(opt.Format(1111.55555), "1,112");
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,74 +0,0 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using YLErp.DBModels;
|
||||
using KellermanSoftware.CompareNetObjects;
|
||||
|
||||
namespace YLErp.ExternalLibTests
|
||||
{
|
||||
[TestClass]
|
||||
public class AutoMapperTest : UnitTestBase
|
||||
{
|
||||
class MapA
|
||||
{
|
||||
public int? id { get; set; }
|
||||
}
|
||||
|
||||
class MapB
|
||||
{
|
||||
public int id { get; set; }
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestBasic()
|
||||
{
|
||||
var config = new AutoMapper.MapperConfiguration(cfg =>
|
||||
{
|
||||
cfg.CreateMap<MapA, MapB>();
|
||||
});
|
||||
|
||||
var mapper = config.CreateMapper();
|
||||
var mapA = new MapA();
|
||||
var mapB = mapper.Map<MapB>(mapA);
|
||||
Assert.AreEqual(mapB.id, 0);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestVolatilityMap()
|
||||
{
|
||||
var volSrc = new volatility
|
||||
{
|
||||
id = 10,
|
||||
Ask_Deviation = 10,
|
||||
Bid_Deviation = 20,
|
||||
ContractCode = "RB2010",
|
||||
Data = ReadResourceFile("volatility.json"),
|
||||
InterpolationMethod = "testt",
|
||||
OptDate = new DateTime(2020, 02, 02),
|
||||
OptId = 10,
|
||||
OptName = "测试",
|
||||
QuotationDate = new DateTime(2020, 02, 08),
|
||||
ReviewDownLimit = 5.55,
|
||||
ReviewUpLimit = 8.88,
|
||||
UnderlyingId = 10009,
|
||||
UserGroup = "UserGroup",
|
||||
VolSurfaceMode = "VolSurfaceMode123",
|
||||
VolType = "VolType677"
|
||||
};
|
||||
|
||||
var volDest = YLAutoMapper.Map<volatility>(volSrc);
|
||||
|
||||
Assert.AreEqual(volDest.id, 0);
|
||||
|
||||
var config = new ComparisonConfig
|
||||
{
|
||||
MembersToIgnore = new List<string>() { nameof(volatility.id), nameof(volatility.EncryptId) }
|
||||
};
|
||||
var compareLogic = new CompareLogic(config);
|
||||
|
||||
ComparisonResult result = compareLogic.Compare(volSrc, volDest);
|
||||
|
||||
Assert.IsTrue(result.AreEqual);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
using DotNetDBF;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace YLErp.BaseTests
|
||||
{
|
||||
[TestClass]
|
||||
public class DbfReaderTest
|
||||
{
|
||||
[TestMethod("TestDBFReader")]
|
||||
public void TestDBFReader()
|
||||
{
|
||||
var path = @"C:\Users\yc999\Downloads\EquityReturn\StockPosition.dbf";
|
||||
using (var dbf = new DBFReader(path))
|
||||
{
|
||||
//dbf.SkipRecord(4);
|
||||
for (var i = 1; i <= 136; i++)
|
||||
{
|
||||
var values = dbf.NextRecord();
|
||||
System.Diagnostics.Debug.WriteLine(string.Join("\t", values));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,107 +0,0 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using YLErp.DBModels;
|
||||
|
||||
namespace YLErp.Modules.EntityFrameworkTests
|
||||
{
|
||||
[TestClass]
|
||||
public class EntityFrameworkTest : YLUnitTestBase
|
||||
{
|
||||
[TestMethod("测试NULL引用")]
|
||||
public void TestNullMap()
|
||||
{
|
||||
using (var db = DbContextFactory.GetYLDbContext())
|
||||
{
|
||||
var query = from t in db.trade
|
||||
join rr in db.realtime_trade_risk on t.id equals rr.TradeId into rrs
|
||||
from rr in rrs.DefaultIfEmpty()
|
||||
where t.id == 1
|
||||
select new
|
||||
{
|
||||
t.id,
|
||||
pv = rr.Pv
|
||||
};
|
||||
|
||||
var data = query.FirstOrDefault();
|
||||
|
||||
Assert.AreEqual(data.pv, null);
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod("获取可为空的列如何查询优化")]
|
||||
public void TestNullableDate()
|
||||
{
|
||||
var log1 = new StringBuilder(500);
|
||||
var log2 = new StringBuilder(500);
|
||||
var date = DateTime.Today.AddDays(-30);
|
||||
var predicate = PredicateBuilder.Create<ExchangeListOption>(n => n.MaturityDate > date);
|
||||
using (var db = DbContextFactory.GetYLDbContext())
|
||||
{
|
||||
db.Database.Log = log => log1.AppendLine(log);
|
||||
var data = db.exchange_list_option.Where(predicate).FirstOrDefault();
|
||||
}
|
||||
|
||||
predicate = PredicateBuilder.Create<ExchangeListOption>(n => n.MaturityDate > date);
|
||||
using (var db = DbContextFactory.GetYLDbContext())
|
||||
{
|
||||
db.Database.Log = log => log2.AppendLine(log);
|
||||
var data = db.exchange_list_option.Where(predicate).FirstOrDefault();
|
||||
}
|
||||
|
||||
Assert.AreNotEqual(log1.ToString(), log2.ToString());
|
||||
|
||||
//这个测试说明了和date类型的列进行比较的时候不会产生null处理,但最好linq中还是要使用value
|
||||
}
|
||||
|
||||
[TestMethod("测试AutoMapper.ProjectTo")]
|
||||
public void TestAutoMapper()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
[TestMethod("测试复杂对象是否被跟踪")]
|
||||
public void TestDataProxy()
|
||||
{
|
||||
var query = from a in DbContext.valuedate
|
||||
from b in DbContext.AppConfig
|
||||
where a.id == 1 && b.PGroup == "ProjectConfig" && b.PName == "Erp.VolMode"
|
||||
select new
|
||||
{
|
||||
a,
|
||||
b = new AppConfigDto
|
||||
{
|
||||
PValue = b.PValue,
|
||||
CreateTime = b.CreateTime
|
||||
}
|
||||
};
|
||||
|
||||
var item = query.FirstOrDefault();
|
||||
|
||||
var riskFreeRate = item.a.RiskFreeRate;
|
||||
|
||||
Assert.IsTrue(DbContext.Entry(item.a).State == System.Data.Entity.EntityState.Unchanged, "测试是否附加1");
|
||||
|
||||
item.a.RiskFreeRate = riskFreeRate + 1;
|
||||
|
||||
var state = DbContext.Entry(item.a).State;
|
||||
|
||||
Assert.IsTrue(state == System.Data.Entity.EntityState.Modified, "测试是否附加2");
|
||||
|
||||
var changes = DbContext.SaveChanges();
|
||||
|
||||
Assert.IsTrue(changes == 1, "测试是否附加3");
|
||||
|
||||
item.a.RiskFreeRate = riskFreeRate;
|
||||
|
||||
Assert.IsTrue(DbContext.Entry(item.a).State == System.Data.Entity.EntityState.Modified, "测试是否附加4");
|
||||
|
||||
changes = DbContext.SaveChanges();
|
||||
|
||||
Assert.IsTrue(changes == 1, "测试是否附加5");
|
||||
|
||||
//Assert.IsTrue(DbContext.Entry(item.b).State == System.Data.Entity.EntityState.Detached, "测试是否附加2");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
using ExcelDataReader;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using System.IO;
|
||||
using YLErp.Office;
|
||||
|
||||
namespace YLErp.ExtLibTests
|
||||
{
|
||||
[TestClass]
|
||||
public class ExcelDataReaderTest
|
||||
{
|
||||
[TestMethod("测试EXCEL文件读取(ExcelDataReader)")]
|
||||
public void TestExcelDataReader()
|
||||
{
|
||||
var path = Path.Combine(AppContext.BaseDirectory, "Resources\\场外期权交易导入.xlsx");
|
||||
using (var stream = new FileStream(path, FileMode.Open, FileAccess.Read))
|
||||
{
|
||||
using (var reader = ExcelReaderFactory.CreateReader(stream))
|
||||
{
|
||||
var ds = reader.AsDataSet(new ExcelDataSetConfiguration
|
||||
{
|
||||
FilterSheet = (r1, sheetIndex) => sheetIndex != 1,
|
||||
ConfigureDataTable = r1 => new ExcelDataTableConfiguration
|
||||
{
|
||||
UseHeaderRow = true,
|
||||
ReadHeaderRow = r2 =>
|
||||
{
|
||||
r2.Read();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Assert.AreEqual(ds.Tables.Count, 1);
|
||||
}
|
||||
}
|
||||
|
||||
var ds2 = ExcelHelper.ReadExcelAsDataSet(path, new[] { 1 }, 0);
|
||||
Assert.AreEqual(ds2.Tables.Count, 1);
|
||||
var str = ds2.Tables[0].Rows[0]["你好"]?.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
using YLErp.Abstract.DataProviders;
|
||||
|
||||
namespace YLErp.Helpers
|
||||
{
|
||||
class InnerExchangeOptionPriceProvider : IPriceProvider
|
||||
{
|
||||
public double GetPrice(string instrumentCode)
|
||||
{
|
||||
return TryGetPrice(instrumentCode, out var price) ? price : 0;
|
||||
}
|
||||
|
||||
public bool TryGetPrice(string instrumentCode, out double price)
|
||||
{
|
||||
switch (instrumentCode)
|
||||
{
|
||||
case "RB00-C-3400":
|
||||
price = 30;
|
||||
return true;
|
||||
case "RB00-P-3400":
|
||||
price = 20;
|
||||
return true;
|
||||
default:
|
||||
price = 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using YLErp.DBModels;
|
||||
using YLErp.Modules.CalculationModule.Abstract;
|
||||
|
||||
namespace YLErp.Helpers
|
||||
{
|
||||
class InnerExchangeTradeCommissionCalc : IExchangeTradeCommissionCalc
|
||||
{
|
||||
public ITradeCommissionCalcResult GetTradeCommission(IEnumerable<ExchangeTrade> tradeList, bool isActualTrade = true)
|
||||
{
|
||||
return new InnerTradeCommissionResult(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using YLErp.Modules.CalculationModule.Abstract;
|
||||
|
||||
namespace YLErp.Helpers
|
||||
{
|
||||
class InnerTradeCommissionResult : ITradeCommissionCalcResult
|
||||
{
|
||||
readonly Dictionary<int, double> _dic;
|
||||
|
||||
public InnerTradeCommissionResult(Dictionary<int, double> dic)
|
||||
{
|
||||
_dic = dic;
|
||||
}
|
||||
|
||||
public double GetTradeCommission(int tradeId)
|
||||
{
|
||||
if (_dic != null && _dic.TryGetValue(tradeId, out var dd))
|
||||
{
|
||||
return dd;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,153 +0,0 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using YLErp.Abstract.DataProviders;
|
||||
using YLErp.DBModels;
|
||||
using YLErp.Modules;
|
||||
|
||||
namespace YLErp.Helpers
|
||||
{
|
||||
class InnerUnderlyingDataProvider : IUnderlyingDataProvider
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取标的数据
|
||||
/// </summary>
|
||||
public underlying_manager GetUnderlying(int underlyingId)
|
||||
{
|
||||
return DataCacheProvider.GetUnderlyingDataSource().GetData(underlyingId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取标的数据
|
||||
/// </summary>
|
||||
public underlying_manager GetUnderlying(string underlyingCode)
|
||||
{
|
||||
return DataCacheProvider.GetUnderlyingDataSource().GetData(underlyingCode);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public underlying_manager GetUnderlying(string underlyingCode, out double contractSize)
|
||||
{
|
||||
var um = DataCacheProvider.GetUnderlyingDataSource().GetData(underlyingCode);
|
||||
contractSize = um?.ContractSize ?? 1;
|
||||
return um;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取品种数据
|
||||
/// </summary>
|
||||
public Variety GetVariety(int varietyId)
|
||||
{
|
||||
return DataCacheProvider.GetVarietyDataSource().GetData(varietyId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取品种信息
|
||||
/// </summary>
|
||||
public Variety GetVariety(string underlyingCode, out double contractSize)
|
||||
{
|
||||
var um = GetUnderlying(underlyingCode);
|
||||
contractSize = um?.ContractSize ?? 1;
|
||||
return DataCacheProvider.GetVarietyDataSource().GetData(um?.UnderlyingTypeId ?? 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取品种数据
|
||||
/// </summary>
|
||||
/// <param name="underlyingCode">标的代码</param>
|
||||
public Variety GetVariety(string underlyingCode)
|
||||
{
|
||||
var um = GetUnderlying(underlyingCode);
|
||||
return DataCacheProvider.GetVarietyDataSource().GetData(um?.UnderlyingTypeId ?? 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据标的代码获取份额和数量的乘积因子
|
||||
/// </summary>
|
||||
public int GetCountRatio(string underlyingCode)
|
||||
{
|
||||
return DataCacheProvider.GetUnderlyingDataSource().GetCountRatio(underlyingCode);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 尝试获取标的过期日(股票:2099-01-01)
|
||||
/// </summary>
|
||||
public bool TryGetMaturityDate(string underlyingCode, out DateTime date)
|
||||
{
|
||||
date = DateTime.MinValue;
|
||||
|
||||
if (string.IsNullOrEmpty(underlyingCode))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var data = DataCacheProvider.GetUnderlyingDataSource().GetData(underlyingCode);
|
||||
|
||||
if (data == null) return false;
|
||||
|
||||
date = data.UnderlyingInstrumentType == "Stock" ? DateTime.Now.AddYears(3) : data.MaturityDate ?? DateTime.MinValue;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据标的代码获取当前价格
|
||||
/// </summary>
|
||||
public double GetPrice(string underlyingCode)
|
||||
{
|
||||
return DataCacheProvider.GetUnderlyingDataSource().TryGetPrice(underlyingCode, out var price) ? price : 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据标的代码获取当前价格
|
||||
/// </summary>
|
||||
public bool TryGetPrice(string underlyingCode, out double price)
|
||||
{
|
||||
return DataCacheProvider.GetUnderlyingDataSource().TryGetPrice(underlyingCode, out price);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取相关性
|
||||
/// </summary>
|
||||
public virtual CorrelationTable GetCorrelation(int underlyingId1, int underlyingId2)
|
||||
{
|
||||
return DataCacheProvider.GetCorrelationDataSource().AsQueryable().FirstOrDefault(
|
||||
n => (n.UnderlyingId1 == underlyingId1 && n.UnderlyingId2 == underlyingId2) || (n.UnderlyingId1 == underlyingId2 && n.UnderlyingId2 == underlyingId1));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取场外期权标的信息
|
||||
/// </summary>
|
||||
public virtual ExchangeListOption GetExchange_List_Option(string ContractCode)
|
||||
{
|
||||
return new ExchangeListOption
|
||||
{
|
||||
CreateTime = DateTime.Now,
|
||||
ContractSize = 10,
|
||||
ContractCode = ContractCode,
|
||||
ExerciseMode = "European",
|
||||
MarginRate = 0,
|
||||
MaturityDate = DateTime.Today.AddMonths(1),
|
||||
MarketCode = "TEST",
|
||||
OpenDate = DateTime.Today.AddDays(-10),
|
||||
OptionType = ContractCode.Contains("-C-") ? "看涨" : "看跌",
|
||||
PrevClosePrice = 12,
|
||||
Price = 12.5,
|
||||
PriceTick = 0.1,
|
||||
PriceTime = DateTime.Now,
|
||||
Strike = int.Parse(Regex.Match(ContractCode, "\\d+$").Value),
|
||||
UnderlyingCode = "RB00"
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取组合标的
|
||||
/// </summary>
|
||||
public SyntheticUnderlying GetSyntheticUnderlying(string underlyingCode)
|
||||
{
|
||||
return DataCacheProvider.GetUnderlyingDataSource().GetSyntheticUnderlying(underlyingCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
using YLErp.Abstract.DataProviders;
|
||||
|
||||
namespace YLErp.Helpers
|
||||
{
|
||||
class InnerUnderlyingPriceProvider : IPriceProvider
|
||||
{
|
||||
public double GetPrice(string instrumentCode)
|
||||
{
|
||||
return TryGetPrice(instrumentCode, out var price) ? price : 0;
|
||||
}
|
||||
|
||||
public bool TryGetPrice(string instrumentCode, out double price)
|
||||
{
|
||||
switch (instrumentCode)
|
||||
{
|
||||
case "RBTest00":
|
||||
price = 3330;
|
||||
return true;
|
||||
default:
|
||||
price = 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using YLErp.Commons;
|
||||
|
||||
namespace YLErp.Modules.BaseModule
|
||||
{
|
||||
[TestClass]
|
||||
public class OtcFormatTest
|
||||
{
|
||||
[TestMethod]
|
||||
public void TestFormatValue()
|
||||
{
|
||||
var d = 1.24555555;
|
||||
var d2 = d.OtcFormatValue(OtcFormatFlag.StockEqvNotional);
|
||||
Assert.AreEqual(d2, 1.25);
|
||||
|
||||
var d3 = d.OtcFormatValue(OtcFormatFlag.premiumRateP);
|
||||
Assert.AreEqual(d3, 124.5556);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestFormatValue2()
|
||||
{
|
||||
var d = 1.24555555;
|
||||
var d2 = d.OtcFormatValue(2);
|
||||
Assert.AreEqual(d2, 1.25);
|
||||
|
||||
d = 1.23555555;
|
||||
d2 = d.OtcFormatValue(2);
|
||||
Assert.AreEqual(d2, 1.24);
|
||||
|
||||
d = 1.23555555;
|
||||
var d3 = d.OtcFormatValue(4);
|
||||
Assert.AreEqual(d3, 1.2356);
|
||||
|
||||
d = 111111111111.2249999999999999;
|
||||
var d4 = d.OtcFormatValue(2, false);
|
||||
Assert.AreEqual(d4, 111111111111.22);
|
||||
|
||||
d = 111111111111.2249999999999999;
|
||||
var d5 = d.OtcFormatValue(2, true);
|
||||
Assert.AreEqual(d5, 111111111111.22);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,118 +0,0 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using YLErp.BLL.Calculation;
|
||||
|
||||
namespace YLErp.Modules.CalculationModule
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[TestClass]
|
||||
public class ForwardradeCalcServiceTest
|
||||
{
|
||||
[TestMethod]
|
||||
public void TestCalcValueOld()
|
||||
{
|
||||
var testItems = new[] {
|
||||
new{ BuySell = "买入", CallPut = "Call", Strike = 3500,Notional = 100,SpotPrice= 3550 },
|
||||
new{ BuySell = "买入", CallPut = "Call", Strike = 3500, Notional = 100, SpotPrice= 3450 },
|
||||
new{ BuySell = "买入", CallPut = "Put", Strike = 3500, Notional = 100, SpotPrice= 3550 },
|
||||
new{ BuySell = "买入", CallPut = "Put", Strike = 3500, Notional = 100, SpotPrice= 3450 },
|
||||
|
||||
new{ BuySell = "卖出", CallPut = "Call", Strike = 3500,Notional = 100,SpotPrice= 3550 },
|
||||
new{ BuySell = "卖出", CallPut = "Call", Strike = 3500, Notional = 100, SpotPrice= 3450 },
|
||||
new{ BuySell = "卖出", CallPut = "Put", Strike = 3500, Notional = 100, SpotPrice= 3550 },
|
||||
new{ BuySell = "卖出", CallPut = "Put", Strike = 3500, Notional = 100, SpotPrice= 3450 },
|
||||
};
|
||||
|
||||
foreach (var item in testItems)
|
||||
{
|
||||
var r1 = CalcValueV1(item.Strike, item.SpotPrice, item.Notional, item.CallPut, item.BuySell);
|
||||
var r2 = CalcValueV2(item.Strike, item.SpotPrice, item.Notional, item.CallPut, item.BuySell);
|
||||
Console.WriteLine(item.ToJson());
|
||||
Console.WriteLine($"pv1: {r1.Pv}, pv2: {r2.Pv}, delta1: {r1.Delta}, delta2: {r2.Delta}");
|
||||
Assert.IsTrue(r1.Pv == r2.Pv && r1.Delta == r2.Delta);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算远期交易(买方角度)ValueCalculator.CalculateForward
|
||||
/// </summary>
|
||||
static TradeValueResult CalculateForwardV1(double strike, double spotPrice, double notional, string callPut)
|
||||
{
|
||||
var pv = 0.0;
|
||||
if (callPut == "Call")
|
||||
{
|
||||
pv = (spotPrice - strike) * notional;
|
||||
}
|
||||
else if (callPut == "Put")
|
||||
{
|
||||
pv = (strike - spotPrice) * notional;
|
||||
}
|
||||
|
||||
return new TradeValueResult()
|
||||
{
|
||||
Pv = pv,
|
||||
Delta = callPut == "Call" ? notional : -notional,
|
||||
DeltaCash = callPut == "Call" ? spotPrice * notional : -spotPrice * notional
|
||||
};
|
||||
}
|
||||
|
||||
public static TradeValueResult CalcValueV1(double strike, double spotPrice, double notional, string callput, string buysell)
|
||||
{
|
||||
var result = CalculateForwardV1(strike, spotPrice, notional, callput);
|
||||
result.Pv *= TradeCalcHelper.GetSign(buysell);
|
||||
result.Delta *= TradeCalcHelper.GetSign(buysell);
|
||||
//买入看跌和卖出看涨取反
|
||||
//var flag = (IsBuy(buysell) ? 1 : 2) | (callput == "Call" ? 1 : 2);
|
||||
//if (flag == 3)
|
||||
//{
|
||||
// result.Delta = -result.Delta;
|
||||
//}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算PV/Risk(交易员角度)
|
||||
/// </summary>
|
||||
public static TradeValueResult CalcValueV2(double strike, double spotPrice, double notional, string callput, string buysell)
|
||||
{
|
||||
var isCall = callput == "Call";
|
||||
var pv = (spotPrice - strike) * notional;
|
||||
|
||||
//买入看跌和卖出看涨取负值
|
||||
var flag = (TradeCalcHelper.IsBuy(buysell) ? 1 : 2) | (isCall ? 1 : 2);
|
||||
|
||||
TradeValueResult result;
|
||||
|
||||
if (flag == 3)
|
||||
{
|
||||
result = new TradeValueResult
|
||||
{
|
||||
Pv = -pv,
|
||||
Delta = -notional,
|
||||
DeltaCash = -spotPrice * notional
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
result = new TradeValueResult
|
||||
{
|
||||
Pv = pv,
|
||||
Delta = notional,
|
||||
DeltaCash = spotPrice * notional
|
||||
};
|
||||
}
|
||||
|
||||
result.RoundedPv = result.Pv;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static bool IsBuy(string tradeType)
|
||||
{
|
||||
return tradeType == "Buy" || tradeType == "买入" || string.IsNullOrWhiteSpace(tradeType);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,108 +0,0 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using YLErp.Abstract.DataProviders;
|
||||
using YLErp.BLL;
|
||||
using YLErp.DBModels;
|
||||
using YLErp.Helpers;
|
||||
using YLErp.Modules.CalculationModule.Abstract;
|
||||
|
||||
namespace YLErp.Modules.CalculationModule
|
||||
{
|
||||
[TestClass]
|
||||
public class HedgePnlCalcTest : YLUnitTestBase
|
||||
{
|
||||
[TestMethod]
|
||||
public void TestCalculate()
|
||||
{
|
||||
var valueDate = DateTime.Today;
|
||||
|
||||
var calc = new InnerHedgePnlCalcContext(true, valueDate, "对冲"
|
||||
, new InnerUnderlyingPriceProvider()
|
||||
, new InnerExchangeOptionPriceProvider(), OptUser).GetHedgePnlCalc();
|
||||
|
||||
var exchangeTrades = GetExchangeTrades();
|
||||
var eodTradePositions = GetEodTradePositions();
|
||||
|
||||
var results = calc.Calculate(exchangeTrades, eodTradePositions);
|
||||
|
||||
Assert.AreEqual(results.Count(), 3);
|
||||
}
|
||||
|
||||
private IEnumerable<ExchangeTrade> GetExchangeTrades()
|
||||
{
|
||||
var valueDate = valuedateBLL.ValueDate;
|
||||
|
||||
var un = GetUnderlyingManager(true);
|
||||
|
||||
var baseTrade = new ExchangeTrade
|
||||
{
|
||||
AssetBookId = 1,
|
||||
Comments = "单元测试",
|
||||
Commission = 0,
|
||||
CommissionType = DBModels.Enums.CommissionType.不收取,
|
||||
CreateTime = DateTime.Now,
|
||||
ExchangeAccountCode = "TEST",
|
||||
ExchangeAccountId = 1,
|
||||
ExerciseMode = "European",
|
||||
InstrumentType = ConsGlobal.InstrumentType.CommodityFutures,
|
||||
IsValid = true,
|
||||
MaturityDate = valueDate.AddMonths(1),
|
||||
Notional = 100,
|
||||
OptionCode = "RB00-C-3400",
|
||||
OptionStrike = 3400,
|
||||
TradeAmount = 100,
|
||||
TradeDate = valueDate.AddDays(-10),
|
||||
TradeLots = 10,
|
||||
TradeNumber = Guid.NewGuid().ToString("N"),
|
||||
TraderId = 1,
|
||||
TraderName = "",
|
||||
TradeSide = "多头开仓",
|
||||
TradeSinglePrice = 16,
|
||||
TradeSource = "",
|
||||
OptId = 0,
|
||||
OptDate = valueDate,
|
||||
OptionType = "看涨",
|
||||
OptName = "",
|
||||
TradeType = "场内期权",
|
||||
UnderlyingCode = "RB00",
|
||||
UnderlyingId = un.id,
|
||||
id = 1
|
||||
};
|
||||
|
||||
var td1 = baseTrade.Clone();
|
||||
td1.TradeType = "商品期权";
|
||||
td1.TradeSinglePrice = 3233;
|
||||
|
||||
var td2 = baseTrade.Clone();
|
||||
td2.id = 2;
|
||||
|
||||
var td3 = baseTrade.Clone();
|
||||
td3.id = 3;
|
||||
td3.OptionCode = "RB00-P-3400";
|
||||
td3.OptionType = "看跌";
|
||||
|
||||
return new[] { td1, td2, td3 };
|
||||
}
|
||||
|
||||
private IEnumerable<EodTradePosition> GetEodTradePositions()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
class InnerHedgePnlCalcContext : HedgePnlCalcContext
|
||||
{
|
||||
public InnerHedgePnlCalcContext(bool isEodSettle, DateTime valueDate, string volType
|
||||
, IPriceProvider underlyingPriceProvider, IPriceProvider exchangeOptionPriceProvider, OptUserInfo optUser)
|
||||
: base(isEodSettle, valueDate, volType, underlyingPriceProvider, exchangeOptionPriceProvider, optUser)
|
||||
{
|
||||
CommissionCalc = new InnerExchangeTradeCommissionCalc();
|
||||
ExchangeOptionPriceUseFlag = ExchangeOptionPriceUseFlag.CalcPv;
|
||||
UnderlyingDataProvider = new InnerUnderlyingDataProvider();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,144 +0,0 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using YLErp.Abstract;
|
||||
using YLErp.Abstract.DataProviders;
|
||||
using YLErp.BLL;
|
||||
using YLErp.DBModels;
|
||||
using YLErp.Models;
|
||||
using YLErp.Modules.CalculationModule.Abstract;
|
||||
using YLErp.Modules.DataProviderModule;
|
||||
using YLErp.Modules.VolatilityModule;
|
||||
using YLErp.QdpModule;
|
||||
|
||||
namespace YLErp.Modules.CalculationModule
|
||||
{
|
||||
[TestClass]
|
||||
public class OptionCaclTest : YLUnitTestBase
|
||||
{
|
||||
[TestMethod("测试雪球期权PV")]
|
||||
public void TestSnowball()
|
||||
{
|
||||
var td = DbContext.trade.FirstOrDefault(n => n.TradeNumber == "CW20200053E0008");
|
||||
Assert.IsNotNull(td);
|
||||
var calcDataProvider = new CalcDataProvider(this)
|
||||
{
|
||||
UnderlyingPriceProvider = new InnerUnderlyingPriceProvider(),
|
||||
VolatilityDataProvider = new InnerVolatilityDataProvider()
|
||||
};
|
||||
var context = new OptionValueCalcContext("对冲", valuedateBLL.ValueDate, valuedateBLL.RiskFreeRate / 100, calcDataProvider)
|
||||
{
|
||||
AddingVolRate = 0,
|
||||
IsEodSettle = false,
|
||||
IsUseTradeVol = true
|
||||
};
|
||||
context.IsPreciseTimeMode = context.IsUseTradeVol || !context.IsEodSettle;
|
||||
var result = TradeRiskCalcUtil.CalcTradeRisk(td, context, out var underlyings);
|
||||
Console.WriteLine($"PV:{result.Pv}; Delta:{result.Delta}");
|
||||
}
|
||||
|
||||
[TestMethod("测试二元期权计算")]
|
||||
public void TestBinaryOption()
|
||||
{
|
||||
var path = Path.Combine(AppContext.BaseDirectory, "Resources\\期权计算\\二元期权.json");
|
||||
var json = File.ReadAllText(path);
|
||||
var td = JsonHelper.Deserialize<trade>(json);
|
||||
var result = OptionCalculatorV2.GetOptionValueResult(DateTime.Today, td, new OptionValueCalcRequest( 0.025)
|
||||
{
|
||||
spotPrices = new[] { 6105.8249 },
|
||||
vols = new[] { 0.23 }
|
||||
}, out _);
|
||||
Console.WriteLine(result.Delta);
|
||||
}
|
||||
|
||||
[TestMethod("测试二元期权计算")]
|
||||
public void TestBinaryOption2()
|
||||
{
|
||||
var path = Path.Combine(AppContext.BaseDirectory, "Resources\\期权计算\\二元期权计算参数.json");
|
||||
var json = File.ReadAllText(path);
|
||||
var calcParam = JsonHelper.Deserialize<OptionCalcParam<BinaryOptionTradeParam>>(json);
|
||||
using (var mp = new MarketProxy(DateTime.Today, 0.025))
|
||||
{
|
||||
var vols = QdpVolHelper.GetDefaultVolatility(0.23);
|
||||
mp.SaveVolSurface(calcParam.volSurfaceNames[0], vols);
|
||||
var result = TradeRiskCalcUtil.GetBinaryOptionValue(mp, calcParam);
|
||||
Console.WriteLine(result.Gamma);
|
||||
}
|
||||
}
|
||||
|
||||
class CalcDataProvider : IOptionCalcDataProvider
|
||||
{
|
||||
public CalcDataProvider(YLBaseService baseService)
|
||||
{
|
||||
UnderlyingDataProvider = new UnderlyingDataProvider();
|
||||
TradeExtendDataProvider = new TradeExtendDataProvider(baseService);
|
||||
}
|
||||
|
||||
public IPriceProvider UnderlyingPriceProvider { get; set; }
|
||||
|
||||
public IUnderlyingDataProvider UnderlyingDataProvider { get; }
|
||||
|
||||
public ITradeExtendDataProvider TradeExtendDataProvider { get; }
|
||||
|
||||
public IVolatilityDataProvider VolatilityDataProvider { get; set; }
|
||||
}
|
||||
|
||||
class InnerUnderlyingPriceProvider : IPriceProvider
|
||||
{
|
||||
public double GetPrice(string instrumentCode)
|
||||
{
|
||||
return 15.45;
|
||||
}
|
||||
|
||||
public bool TryGetPrice(string instrumentCode, out double price)
|
||||
{
|
||||
price = 15.45;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
class InnerVolatilityDataProvider : IVolatilityDataProvider
|
||||
{
|
||||
public double? GetExchangeOptionTradeHedgeVol(string optionCode, DateTime valueDate)
|
||||
{
|
||||
return 0.25;
|
||||
}
|
||||
|
||||
public double? GetOtcOptionTradeEodVol(int tradeId, DateTime valueDate)
|
||||
{
|
||||
return 0.25;
|
||||
}
|
||||
|
||||
public double? GetOtcOptionTradeHedgeVol(int tradeId, DateTime valueDate)
|
||||
{
|
||||
return 0.25;
|
||||
}
|
||||
|
||||
public IOtcTradeVolatility GetOtcOptionTradeVol(int tradeId, DateTime valueDate)
|
||||
{
|
||||
return new OtcTradeVolatility
|
||||
{
|
||||
OpenVol = 0.25,
|
||||
CloseVol = 0.25,
|
||||
SmoothingDays = 1,
|
||||
IsFirst = false,
|
||||
ValueDate = valueDate
|
||||
};
|
||||
}
|
||||
|
||||
public IVolatility GetUnderlyingVolatility(string voltype, string contractCode, string userGroup)
|
||||
{
|
||||
return VolatilityHelper.GetDefaultVol(new SingleVolatilityRequest
|
||||
{
|
||||
QuotationDate = DateTime.Today,
|
||||
TradeVolWithBidAsk = false,
|
||||
UnderlyingCode = contractCode,
|
||||
UnderlyingId = 0,
|
||||
UserGroup = userGroup,
|
||||
VolType = voltype
|
||||
}, 0.25);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,251 +0,0 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Qdp.Pricing.Base.Enums;
|
||||
using System;
|
||||
using YLErp.BLL;
|
||||
using YLErp.BLL.Calculation;
|
||||
using YLErp.DBModels;
|
||||
using YLErp.QdpModule;
|
||||
|
||||
namespace YLErp.Modules.CalculationModule
|
||||
{
|
||||
/// <summary>
|
||||
/// 期权计算比较(新版本和老版本)
|
||||
/// </summary>
|
||||
[TestClass]
|
||||
public class OptionCalculatorCompare
|
||||
{
|
||||
const double ConstVol = 0.3;
|
||||
const double Notional = 1;
|
||||
const double SpotPrice = 3000;
|
||||
const double RiskFreeRate = 0.03;
|
||||
const string ExerciseType = "European";
|
||||
const string UnderlyingCode = "RB00";
|
||||
const int TTMDays = 36;
|
||||
const string InstrumentType = "CommodityFutures";
|
||||
static readonly string QdpMarketID = Guid.NewGuid().ToString();
|
||||
static readonly DateTime TradeDate = new DateTime(2021, 1, 4);
|
||||
static readonly DateTime ExerciseDate = new DateTime(2021, 3, 1);
|
||||
|
||||
[TestMethod]
|
||||
public void TestVanillaOption()
|
||||
{
|
||||
var vols = QdpVolHelper.GetDefaultVolatility(ConstVol);
|
||||
var valueDateStr = TradeDate.ToString("yyyy-MM-dd");
|
||||
var marketProxy = QdpMarketManager.Instance.GetPrebuiltMarketProxy(QdpMarketID);
|
||||
|
||||
var underlying = new
|
||||
{
|
||||
UnderlyingCode = UnderlyingCode,
|
||||
UnderlyingInstrumentType = InstrumentType,
|
||||
Price = SpotPrice
|
||||
};
|
||||
|
||||
//使用全局的DiscountCurve以提高计算效率
|
||||
var discountCurveName = Guid.NewGuid().ToString();
|
||||
var discountCurve = CalculatorHelper.CreateConstantRiskFreeCurve(discountCurveName, valuedateBLL.RiskFreeRate / 100.0);
|
||||
marketProxy.AddYieldCurve(discountCurveName, valueDateStr, discountCurve);
|
||||
|
||||
var initParam = new VolSurfaceInitParamsBuilder(QdpMarketID)
|
||||
.SetValueDate(TradeDate)
|
||||
.SetUnderlying(0, UnderlyingCode, UnderlyingCode)
|
||||
.SetVolatility(vols).Build(QdpMarketID);
|
||||
VolSurfaceInitializerSingleton.GetInitializer(false).InitializeMarketProxy(initParam);
|
||||
|
||||
var bidMaturityDate = ExerciseDate.ToString(ConsGlobal.DateFormat);
|
||||
|
||||
var tv1 = OptionCalculatorV1.ValueVanillaOptionTrade(
|
||||
marketProxy: marketProxy,
|
||||
valueDate: valueDateStr,
|
||||
underlyingTicker: underlying.UnderlyingCode,
|
||||
underlyingInstrumentType: underlying.UnderlyingInstrumentType,
|
||||
strike: SpotPrice,
|
||||
startDate: valueDateStr,
|
||||
endDate: bidMaturityDate,
|
||||
optionType: "Call",
|
||||
exerciseType: ExerciseType,
|
||||
spotPrice: underlying.Price,
|
||||
notional: Notional,
|
||||
volSurfaceName: initParam.volSurfaceNameKey,
|
||||
riskFreeRate: RiskFreeRate,
|
||||
modelName: null,
|
||||
tradeType: "Buy",
|
||||
exerciseDate: bidMaturityDate,
|
||||
hasNightMarket: false,
|
||||
commodityFuturesPreciseTimeMode: true,
|
||||
discountCurveName: discountCurveName,
|
||||
participationRate: 1.0,
|
||||
principalRate: 0.0,
|
||||
isAnnualized: false,
|
||||
annualizeFactor: 1.0,
|
||||
timeToMaturityDays: TTMDays);
|
||||
|
||||
System.Diagnostics.Debug.WriteLine("V1 PV:" + tv1.Pv);
|
||||
|
||||
var vtParam = new VanillaOptionTradeParam
|
||||
{
|
||||
annualizedFactor = 0,
|
||||
isAnnualized = false,
|
||||
buysell = "买入",
|
||||
commodityFuturesPreciseTimeMode = true,
|
||||
dividendRate = 0,
|
||||
dividends = null,
|
||||
endDate = ExerciseDate,
|
||||
exerciseDate = ExerciseDate,
|
||||
exerciseType = ExerciseType,
|
||||
hasNightMarket = false,
|
||||
initialSpotPrice = SpotPrice,
|
||||
isForwardTrade = false,
|
||||
isMoneynessOption = false,
|
||||
notional = Notional,
|
||||
optionType = OptionType.Call,
|
||||
participationRate = 1,
|
||||
principalRate = 0,
|
||||
riskFreeRate = RiskFreeRate,
|
||||
settlementDate = ExerciseDate,
|
||||
startDate = TradeDate,
|
||||
strike = SpotPrice,
|
||||
timeToMaturityDays = TTMDays,
|
||||
tradeDate = TradeDate,
|
||||
tradeId = QdpMarketID,
|
||||
underlyingInstrumentType = InstrumentType,
|
||||
underlyingTickers = new[] { UnderlyingCode },
|
||||
volSurfaceNames = new[] { QdpMarketID }
|
||||
};
|
||||
|
||||
TradeValueResult tv2;
|
||||
|
||||
using (var mp = new MarketProxy(TradeDate, 0.03))
|
||||
{
|
||||
mp.SaveVolSurface(QdpMarketID, vols);
|
||||
|
||||
tv2 = TradeRiskCalcUtil.GetVanillaOptionValue(mp, new OptionCalcParam<VanillaOptionTradeParam>(vtParam)
|
||||
{
|
||||
pricingRequest = QdpPricingRequest.BASIC_GREEKS,
|
||||
spotPrices = new[] { 3000d },
|
||||
});
|
||||
}
|
||||
|
||||
System.Diagnostics.Debug.WriteLine("V2 PV:" + tv2.Pv);
|
||||
|
||||
Assert.AreEqual(tv1.Pv, tv2.Pv, 1e-6);
|
||||
Assert.AreEqual(tv1.Delta, tv2.Delta, 1e-6);
|
||||
Assert.AreEqual(tv1.Gamma, tv2.Gamma, 1e-6);
|
||||
Assert.AreEqual(tv1.Theta, tv2.Theta, 1e-6);
|
||||
Assert.AreEqual(tv1.Rho, tv2.Rho, 1e-6);
|
||||
Assert.AreEqual(tv1.Vega, tv2.Vega, 1e-6);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestAsiaOption()
|
||||
{
|
||||
var vols = QdpVolHelper.GetDefaultVolatility(ConstVol);
|
||||
var valueDateStr = TradeDate.ToString("yyyy-MM-dd");
|
||||
var marketProxy = QdpMarketManager.Instance.GetPrebuiltMarketProxy(QdpMarketID);
|
||||
|
||||
var underlying = DataCacheProvider.GetUnderlyingDataSource().GetData(UnderlyingCode);
|
||||
|
||||
//使用全局的DiscountCurve以提高计算效率
|
||||
var discountCurveName = Guid.NewGuid().ToString();
|
||||
var discountCurve = CalculatorHelper.CreateConstantRiskFreeCurve(discountCurveName, valuedateBLL.RiskFreeRate / 100.0);
|
||||
marketProxy.AddYieldCurve(discountCurveName, valueDateStr, discountCurve);
|
||||
|
||||
var initParam = new VolSurfaceInitParamsBuilder(QdpMarketID)
|
||||
.SetValueDate(TradeDate)
|
||||
.SetUnderlying(0, UnderlyingCode, UnderlyingCode)
|
||||
.SetVolatility(vols).Build(QdpMarketID);
|
||||
VolSurfaceInitializerSingleton.GetInitializer(false).InitializeMarketProxy(initParam);
|
||||
|
||||
underlying.Price = SpotPrice;
|
||||
underlying.QuotationDate = TradeDate;
|
||||
|
||||
var td = new trade()
|
||||
{
|
||||
TradeType = "亚式期权",
|
||||
UnderlyingCode = underlying.UnderlyingCode,
|
||||
UnderlyingInstrumentType = InstrumentType,
|
||||
TradeDate = TradeDate,
|
||||
StartDate = TradeDate,
|
||||
MaturityDate = ExerciseDate,
|
||||
ExerciseDate = ExerciseDate,
|
||||
OptionType = "看涨",
|
||||
ExerciseMode = ExerciseType,
|
||||
Strike = SpotPrice,
|
||||
SpotPrice = SpotPrice,
|
||||
Notional = Notional,
|
||||
NoRiskRate = RiskFreeRate,
|
||||
BuySell = "Buy",
|
||||
QuotationType = "波动率调整",
|
||||
TradeOpenVolatility = ConstVol,
|
||||
TTMDays = TTMDays,
|
||||
trade_asian_option = new trade_asian_option()
|
||||
{
|
||||
PayoffType = "ArithmeticAverage",
|
||||
StrikeType = "Fixed",
|
||||
AveragingPeriodStartDate = TradeDate
|
||||
}
|
||||
};
|
||||
|
||||
var tv1 = OptionCalculatorV1.GetOptionValueResult(QdpMarketID, underlying, td, new[] { SpotPrice },
|
||||
useTradeVolMode: true, volSurfaceNames: new[] { initParam.volSurfaceNameKey },
|
||||
fixing: $"{TradeDate:yyyy-MM-dd},{SpotPrice}", commodityFuturesPreciseTimeMode: false);
|
||||
|
||||
System.Diagnostics.Debug.WriteLine("V1 PV:" + tv1.Pv);
|
||||
|
||||
var vtParam = new AsianOptionTradeParam
|
||||
{
|
||||
annualizedFactor = 0,
|
||||
isAnnualized = false,
|
||||
buysell = "买入",
|
||||
commodityFuturesPreciseTimeMode = false,
|
||||
dividendRate = 0,
|
||||
dividends = null,
|
||||
endDate = ExerciseDate,
|
||||
exerciseDate = ExerciseDate,
|
||||
exerciseType = ExerciseType,
|
||||
hasNightMarket = false,
|
||||
initialSpotPrice = SpotPrice,
|
||||
isForwardTrade = false,
|
||||
isMoneynessOption = false,
|
||||
notional = 1,
|
||||
optionType = OptionType.Call,
|
||||
participationRate = 1,
|
||||
principalRate = 0,
|
||||
riskFreeRate = RiskFreeRate,
|
||||
settlementDate = ExerciseDate,
|
||||
startDate = TradeDate,
|
||||
strike = SpotPrice,
|
||||
timeToMaturityDays = TTMDays,
|
||||
tradeDate = TradeDate,
|
||||
tradeId = QdpMarketID,
|
||||
underlyingInstrumentType = InstrumentType,
|
||||
underlyingTickers = new[] { UnderlyingCode },
|
||||
volSurfaceNames = new[] { QdpMarketID },
|
||||
payoffType = "ArithmeticAverage",
|
||||
strikeStyle = "Fixed",
|
||||
averagingPeriodStartDate = TradeDate
|
||||
};
|
||||
|
||||
TradeValueResult tv2;
|
||||
|
||||
using (var mp = new MarketProxy(TradeDate, RiskFreeRate))
|
||||
{
|
||||
mp.SaveVolSurface(QdpMarketID, vols);
|
||||
|
||||
tv2 = TradeRiskCalcUtil.GetAsianOptionValue(mp, new OptionCalcParam<AsianOptionTradeParam>(vtParam)
|
||||
{
|
||||
pricingRequest = QdpPricingRequest.BASIC_GREEKS,
|
||||
spotPrices = new[] { SpotPrice },
|
||||
});
|
||||
}
|
||||
|
||||
System.Diagnostics.Debug.WriteLine("V2 PV:" + tv2.Pv);
|
||||
|
||||
Assert.AreEqual(tv1.Pv, tv2.Pv, 1e-6);
|
||||
Assert.AreEqual(tv1.Delta, tv2.Delta, 1e-6);
|
||||
Assert.AreEqual(tv1.Gamma, tv2.Gamma, 1e-6);
|
||||
Assert.AreEqual(tv1.Theta, tv2.Theta, 1e-6);
|
||||
Assert.AreEqual(tv1.Rho, tv2.Rho, 1e-6);
|
||||
Assert.AreEqual(tv1.Vega, tv2.Vega, 1e-6);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,401 +0,0 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Qdp.ComputeService.Data.CommonModels.ValuationParams.Equity;
|
||||
using Qdp.ComputeServiceV2.Data.CommonModels.TradeInfos.Options;
|
||||
using Qdp.Foundation.Implementations;
|
||||
using Qdp.Pricing.Base.Enums;
|
||||
using Qdp.Pricing.Base.Implementations;
|
||||
using Qdp.Pricing.Base.Utilities;
|
||||
using Qdp.Pricing.Library.Options.Products.SyntheticSpread;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using YLErp.BLL.Calculation;
|
||||
using YLErp.DBModels;
|
||||
using YLErp.DBModels.Helpers;
|
||||
using YLErp.QdpModule;
|
||||
|
||||
namespace YLErp.Modules.CalculationModule
|
||||
{
|
||||
[TestClass]
|
||||
public class SSpreadOptionCalcTest
|
||||
{
|
||||
[TestMethod("测试雪球期权PV")]
|
||||
public void TestSSpreadOptionCalcCrossGammas()
|
||||
{
|
||||
var spotPrice = 3200d;
|
||||
var coefficients = new double[] { -1, 1 };
|
||||
var td = new trade
|
||||
{
|
||||
id = 1,
|
||||
AssetBookName = "test",
|
||||
AssetId = 1,
|
||||
BasisGap = 0,
|
||||
BasisUnderlyingCode = null,
|
||||
BasisUnderlyingId = 0,
|
||||
BuySell = "卖出",
|
||||
CalcFlag = 1,
|
||||
ClientId = 1,
|
||||
ClientName = "客户名称",
|
||||
Comments = null,
|
||||
CreateDate = DateTime.Now,
|
||||
UnderlyingCode = "RB00-TA00",
|
||||
UnderlyingInstrumentType = ConsGlobal.InstrumentType.CommodityFutures,
|
||||
Strike = 3000,
|
||||
StartDate = new DateTime(2020, 12, 1),
|
||||
ExerciseDate = new DateTime(2020, 12, 31),
|
||||
MaturityDate = new DateTime(2023, 12, 31),
|
||||
OptionType = "看涨",
|
||||
ExerciseMode = ConsGlobal.ExerciseMode.American,
|
||||
Notional = 100,
|
||||
NoRiskRate = 0.05,
|
||||
ParticipationRate = 1,
|
||||
PrincipalRate = 0,
|
||||
IsAnnualized = false,
|
||||
AnnualizeFactor = 1,
|
||||
DividendRate = 0,
|
||||
IsMoneynessOption = "否",
|
||||
SpotPrice = 3200
|
||||
};
|
||||
|
||||
var marketProxy = QdpMarketManager.Instance.GetPrebuiltMarketProxy("111");
|
||||
|
||||
var crossGammas = SSpreadOptionCalc.CalculateSyntheticNormalSpreadCrossGammas(
|
||||
marketProxy,
|
||||
"2020-12-25",
|
||||
td.UnderlyingCode,
|
||||
td.UnderlyingInstrumentType,
|
||||
td.Strike ?? 0,
|
||||
td.StartDate.Value.ToString("yyyy-MM-dd"),
|
||||
td.MaturityDate.Value.ToString("yyyy-MM-dd"),
|
||||
td.CallPut,
|
||||
td.ExerciseMode,
|
||||
spotPrice,
|
||||
coefficients.ToArray(),
|
||||
td.Notional,
|
||||
"1111111",
|
||||
td.NoRiskRate ?? 0.0,
|
||||
td.BuySell,
|
||||
td.ExerciseDate.Value.ToString("yyyy-MM-dd"),
|
||||
td.ParticipationRate ?? 1.0,
|
||||
td.PrincipalRate ?? 0.0,
|
||||
td.IsAnnualized,
|
||||
td.AnnualizeFactor ?? 1.0,
|
||||
td.DividendRate ?? 0,
|
||||
td.IsMoneynessOptionData,
|
||||
td.SpotPrice ?? 0,
|
||||
hasNightMarket: false,
|
||||
commodityFuturesPreciseTimeMode: false,
|
||||
riskFreeRateOverride: td.NoRiskRate ?? double.NaN,
|
||||
dividendRateOverride: td.DividendRate ?? double.NaN);
|
||||
Assert.IsNotNull(crossGammas);
|
||||
|
||||
var crossGammas2 = OptionCalculatorV2.CalcSSpreadCrossGammas(new DateTime(2020, 12, 25), td, new OptionValueCalcRequest(0.05)
|
||||
{
|
||||
spotPrices = new[] { spotPrice },
|
||||
vols = new[] { 1.3 },
|
||||
}, coefficients);
|
||||
|
||||
Assert.IsNotNull(crossGammas);
|
||||
}
|
||||
}
|
||||
|
||||
static class SSpreadOptionCalc
|
||||
{
|
||||
/// <summary>
|
||||
/// 股指期货类型转换为商品期货类型
|
||||
/// </summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private static string ConvertInstrumentType(string instrumentType)
|
||||
{
|
||||
return ConsGlobal.InstrumentType.IsStockIF(instrumentType) ? ConsGlobal.InstrumentType.CommodityFutures : instrumentType;
|
||||
}
|
||||
|
||||
public static OptionExercise ConvertExerciseType(string exerciseType)
|
||||
{
|
||||
if (exerciseType != null)
|
||||
{
|
||||
switch (exerciseType.ToUpper())
|
||||
{
|
||||
case "美式":
|
||||
case "AMERICAN":
|
||||
return OptionExercise.American;
|
||||
default:
|
||||
return OptionExercise.European;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return OptionExercise.European;
|
||||
}
|
||||
}
|
||||
|
||||
public static SyntheticNormalSpreadOptionTrade CreateSyntheticNormalSpreadOptionTrade(
|
||||
string tradeId,
|
||||
string volSurfaceName,
|
||||
string tradeDate,
|
||||
string underlyingTicker,
|
||||
string underlyingInstrumentType,
|
||||
double strike,
|
||||
string startDate,
|
||||
string endDate,
|
||||
string optionType,
|
||||
string exerciseType,
|
||||
double notional,
|
||||
string tradeType,
|
||||
string exerciseDate,
|
||||
double participationRate,
|
||||
double principalRate,
|
||||
bool isAnnualized,
|
||||
double annualizeFactor,
|
||||
double[] coefficients = null,
|
||||
bool isMoneynessOption = false,
|
||||
double initialSpotPrice = 0.0,
|
||||
Dictionary<Date, double> dividends = null,
|
||||
bool hasNightMarket = false,
|
||||
bool commodityFuturesPreciseTimeMode = false,
|
||||
double timeToMaturityDays = double.NaN,
|
||||
double riskFreeRateOverride = double.NaN,
|
||||
double dividendRateOverride = double.NaN)
|
||||
{
|
||||
underlyingInstrumentType = ConvertInstrumentType(underlyingInstrumentType);
|
||||
|
||||
var exercise = ConvertExerciseType(exerciseType);
|
||||
var optionStartDate = startDate.ToDate();
|
||||
var underlyingMaturityDate = string.IsNullOrWhiteSpace(endDate) ? null : endDate.ToDate();
|
||||
var temp_exerciseDate = exerciseDate.ToDate();
|
||||
|
||||
if (temp_exerciseDate < optionStartDate)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
Date[] exerciseDates = null;
|
||||
Date[] observationDates = null;
|
||||
if (exercise == OptionExercise.American)
|
||||
{
|
||||
exerciseDates = CalendarImpl.Get("chn").BizDaysBetweenDatesInclEndDay(optionStartDate, temp_exerciseDate).ToArray();
|
||||
observationDates = CalendarImpl.Get("chn").BizDaysBetweenDatesExcluStartDay(optionStartDate, temp_exerciseDate).ToArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
exerciseDates = new Date[] { temp_exerciseDate };
|
||||
observationDates = new Date[] { temp_exerciseDate };
|
||||
}
|
||||
|
||||
if (underlyingInstrumentType == null)
|
||||
{
|
||||
throw new Exception("标的资产类型不能为空");
|
||||
}
|
||||
|
||||
var optionDayCount = CalculatorHelper.GetTradeDayCount();
|
||||
var pricingTOverride = double.IsNaN(timeToMaturityDays) ? double.NaN : QdpCalendarHelper.CalculateTFromDays(timeToMaturityDays, optionDayCount, optionStartDate.DateTime);
|
||||
|
||||
var syntheticNormalSpreadOption =
|
||||
new SyntheticNormalSpreadOption(
|
||||
optionStartDate,
|
||||
exercise,
|
||||
(OptionType)Enum.Parse(typeof(OptionType), optionType),
|
||||
strike,
|
||||
(InstrumentType)Enum.Parse(typeof(InstrumentType), underlyingInstrumentType),
|
||||
CalendarImpl.Get("chn"),
|
||||
optionDayCount.ToDayCountImpl(),
|
||||
CurrencyCode.CNY,
|
||||
CurrencyCode.CNY,
|
||||
exerciseDates,
|
||||
observationDates,
|
||||
coefficients, // coefficients
|
||||
notional,
|
||||
null,
|
||||
null,
|
||||
0.0,
|
||||
isMoneynessOption,
|
||||
initialSpotPrice,
|
||||
dividends,
|
||||
hasNightMarket: hasNightMarket,
|
||||
commodityFuturesPreciseTimeMode: commodityFuturesPreciseTimeMode,
|
||||
pricingToverride: pricingTOverride,
|
||||
riskFreeRateOverride: riskFreeRateOverride,
|
||||
dividendRateOverride: dividendRateOverride,
|
||||
participationRate: participationRate,
|
||||
isAnnualized: isAnnualized,
|
||||
annualizedFactor: annualizeFactor)
|
||||
{
|
||||
UnderlyingTickers = new string[] { underlyingTicker }
|
||||
};
|
||||
|
||||
if (string.IsNullOrWhiteSpace(tradeId))
|
||||
{
|
||||
tradeId = Guid.NewGuid().ToString();
|
||||
}
|
||||
return new SyntheticNormalSpreadOptionTrade(
|
||||
tradeId,
|
||||
tradeDate.ToDate(),
|
||||
syntheticNormalSpreadOption.StartDate,
|
||||
syntheticNormalSpreadOption.ExerciseDates.Last(),
|
||||
QdpConverter.ConvertTradeType(tradeType),
|
||||
syntheticNormalSpreadOption.Notional,
|
||||
0.0,
|
||||
syntheticNormalSpreadOption)
|
||||
{
|
||||
ValuationParameters = new OptionValuationParameters("RiskFreeDiscountCurve", MarketProxy.ConstantZeroCurve, volSurfaceName, syntheticNormalSpreadOption.UnderlyingTickers[0]),
|
||||
ProtectionRate = principalRate,
|
||||
ParticipationRate = participationRate,
|
||||
AnnualizedFactor = annualizeFactor,
|
||||
OriginalNotional = TradeHelper.GetStockEqvNotional(notional * initialSpotPrice, participationRate, annualizeFactor)
|
||||
};
|
||||
}
|
||||
|
||||
public static double[] CalculateSyntheticNormalSpreadCrossGammas(
|
||||
IQdpMarketProxy marketProxy,
|
||||
string valueDate,
|
||||
string underlyingTicker,
|
||||
string underlyingInstrumentType,
|
||||
double strike,
|
||||
string startDate,
|
||||
string endDate,
|
||||
string optionType,
|
||||
string exerciseType,
|
||||
double spotPrice,
|
||||
double[] coefficients,
|
||||
double notional,
|
||||
string volSurfaceName,
|
||||
double riskFreeRate,
|
||||
string tradeType,
|
||||
string exerciseDate,
|
||||
double participationRate,
|
||||
double principalRate,
|
||||
bool isAnnualized,
|
||||
double annualizeFactor,
|
||||
double dividendRate = 0.0,
|
||||
bool isMoneynessOption = false,
|
||||
double initialSpotPrice = 0.0,
|
||||
Dictionary<Date, double> dividends = null,
|
||||
bool hasNightMarket = false,
|
||||
bool commodityFuturesPreciseTimeMode = false,
|
||||
string engineName = null,
|
||||
string discountCurveName = null,
|
||||
bool ignoreSkewMap = false,
|
||||
bool isForwardTrade = false,
|
||||
double timeToMaturityDays = double.NaN,
|
||||
double riskFreeRateOverride = double.NaN,
|
||||
double dividendRateOverride = double.NaN)
|
||||
{
|
||||
if (coefficients == null || coefficients.Length == 1)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
string tradeId = null;
|
||||
|
||||
var trade = CreateSyntheticNormalSpreadOptionTrade(
|
||||
tradeId,
|
||||
volSurfaceName,
|
||||
valueDate,
|
||||
underlyingTicker,
|
||||
underlyingInstrumentType,
|
||||
strike,
|
||||
startDate,
|
||||
endDate,
|
||||
optionType,
|
||||
exerciseType,
|
||||
notional,
|
||||
tradeType,
|
||||
exerciseDate,
|
||||
participationRate,
|
||||
principalRate,
|
||||
isAnnualized,
|
||||
annualizeFactor,
|
||||
coefficients,
|
||||
isMoneynessOption,
|
||||
initialSpotPrice,
|
||||
dividends,
|
||||
hasNightMarket,
|
||||
commodityFuturesPreciseTimeMode,
|
||||
timeToMaturityDays,
|
||||
riskFreeRateOverride,
|
||||
dividendRateOverride);
|
||||
|
||||
var market = marketProxy.GetQdpMarket(valueDate);
|
||||
if (market == null)
|
||||
{
|
||||
marketProxy.CreateMarket(valueDate);
|
||||
market = marketProxy.GetQdpMarket(valueDate);
|
||||
if (market == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var volPart = QdpVolHelper.GetDefaultVolatility(1.3);
|
||||
|
||||
var volSurfaceWrap = new VolSurfaceBuilder
|
||||
{
|
||||
volSurfaceName = volSurfaceName,
|
||||
volSurfaceType = "MoneynessVol",
|
||||
interpolation = "BiLinear"
|
||||
}.SetVectors(volPart.VolTable).Build(valueDate);
|
||||
marketProxy.SaveVolSurface(volSurfaceWrap);
|
||||
}
|
||||
|
||||
var useLocalDiscountCurve = string.IsNullOrWhiteSpace(discountCurveName);
|
||||
|
||||
//设置DiscountCurve
|
||||
if (useLocalDiscountCurve)
|
||||
{
|
||||
discountCurveName = Guid.NewGuid().ToString();
|
||||
var discountCurve = CalculatorHelper.CreateConstantRiskFreeCurve(discountCurveName, riskFreeRate);
|
||||
marketProxy.AddYieldCurve(discountCurveName, valueDate, discountCurve);
|
||||
}
|
||||
|
||||
//设置标的价格
|
||||
marketProxy.AddStockPrice(underlyingTicker, valueDate, spotPrice);
|
||||
|
||||
OptionValuationParameters parameters;
|
||||
if (underlyingInstrumentType == "Stock")
|
||||
{
|
||||
//设置DividendCurve
|
||||
var dividendCurveName = Guid.NewGuid().ToString();
|
||||
var dividendCurve = CalculatorHelper.CreateConstantRiskFreeCurve(dividendCurveName, dividendRate);
|
||||
marketProxy.AddYieldCurve(dividendCurveName, valueDate, dividendCurve);
|
||||
|
||||
parameters = new OptionValuationParameters(
|
||||
isForwardTrade ? MarketProxy.ConstantZeroCurve : discountCurveName,
|
||||
dividendCurveName,
|
||||
volSurfaceName,
|
||||
underlyingTicker);
|
||||
}
|
||||
else
|
||||
{
|
||||
parameters = new OptionValuationParameters(
|
||||
isForwardTrade ? MarketProxy.ConstantZeroCurve : discountCurveName,
|
||||
MarketProxy.ConstantZeroCurve,
|
||||
volSurfaceName,
|
||||
underlyingTicker);
|
||||
}
|
||||
|
||||
var result = trade.CalcCrossGammas(marketProxy.GetQdpMarket(valueDate), parameters);
|
||||
if (result == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var crossGammas = new List<double>();
|
||||
|
||||
// 先获取返回的结果矩阵中的对角线上的元素,对应的是每个标的的Gamma
|
||||
for (var i = 0; i < coefficients.Length; ++i)
|
||||
{
|
||||
crossGammas.Add(result[i, i]);
|
||||
}
|
||||
|
||||
// 再获取两两对应的Cross Gamma
|
||||
for (var i = 0; i < coefficients.Length - 1; ++i)
|
||||
{
|
||||
for (var j = i + 1; j < coefficients.Length; ++j)
|
||||
{
|
||||
crossGammas.Add(result[i, j]);
|
||||
}
|
||||
}
|
||||
|
||||
return crossGammas.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,20 +0,0 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System.Linq;
|
||||
|
||||
namespace YLErp.Modules.ClientModule
|
||||
{
|
||||
[TestClass]
|
||||
public class ClientPositionServiceTest : UnitTestBase
|
||||
{
|
||||
[TestMethod("测试tapconsole api:api/v2/clientPositionList")]
|
||||
public void TestGetAllPositionsV2()
|
||||
{
|
||||
var datas = new ClientPositionService(CurUser).GetAllPositionsV2(new ClientPositionQueryModel { PageSize = 1000 });
|
||||
var t = datas.FirstOrDefault(n => n.TradeId == 104120);
|
||||
if (t != null)
|
||||
{
|
||||
Assert.AreEqual(t.HedgeVol, 0.4);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace YLErp.Modules.DataCacheModule
|
||||
{
|
||||
[TestClass]
|
||||
public class DataCacheTest
|
||||
{
|
||||
[TestMethod("测试标的缓存不存在时自动读取数据库")]
|
||||
public void TestUnderlyingDataSource()
|
||||
{
|
||||
var dataSource = DataCacheManager.GetUnderlyingDataSource();
|
||||
|
||||
var blResult = dataSource.TryGetPrice(null, out var price);
|
||||
Assert.AreEqual(price, 0);
|
||||
Assert.AreEqual(blResult, false);
|
||||
|
||||
blResult = dataSource.TryGetPrice("Virtual01", out price);
|
||||
Assert.AreEqual(price, 0);
|
||||
Assert.AreEqual(blResult, false);
|
||||
|
||||
blResult = dataSource.TryGetPrice(0, out price);
|
||||
Assert.AreEqual(price, 0);
|
||||
Assert.AreEqual(blResult, false);
|
||||
|
||||
blResult = dataSource.TryGetPrice("RB2001", out price);
|
||||
Assert.AreEqual(price, 3770);
|
||||
Assert.AreEqual(blResult, true);
|
||||
|
||||
blResult = dataSource.TryGetPrice(2, out price);
|
||||
Assert.AreEqual(price, 3378);
|
||||
Assert.AreEqual(blResult, true);
|
||||
}
|
||||
|
||||
[TestMethod("测试场内期权信息")]
|
||||
public void TestExchangeListOptionDataSource()
|
||||
{
|
||||
var dataSource = DataCacheManager.GetExchangeListOptionDataSource();
|
||||
var data = dataSource.GetData("SR005P6122");
|
||||
Assert.AreEqual(data?.id, 1);
|
||||
|
||||
data = dataSource.GetData("SR005P6122");
|
||||
Assert.AreEqual(data?.id, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using YLErp.DBModels;
|
||||
|
||||
namespace YLErp.Modules.DataProviderModule
|
||||
{
|
||||
[TestClass]
|
||||
public class EodExchangeOptionPriceProviderTest : YLUnitTestBase
|
||||
{
|
||||
[TestMethod]
|
||||
public void TestGetPrice()
|
||||
{
|
||||
var valueDate = new DateTime(1900, 1, 1);
|
||||
|
||||
const string optionCode = "RBTest-P-2650";
|
||||
|
||||
var insertModel = new eod_exchange_option_price
|
||||
{
|
||||
ClosePrice = 12.22,
|
||||
DataSource = "单元测试",
|
||||
HighPrice = 12.32,
|
||||
LowPrice = 12.2,
|
||||
SettlePrice = 12.24,
|
||||
UnderlyingCode = optionCode,
|
||||
ValueDate = valueDate
|
||||
};
|
||||
|
||||
SetDBModelOpt(insertModel);
|
||||
|
||||
AddClearSQL<eod_exchange_option_price>($"ValueDate='{valueDate:yyyy-MM-dd}' and ContractCode='{optionCode}'");
|
||||
|
||||
DbContext.eod_exchange_option_price.Add(insertModel);
|
||||
DbContext.SaveChanges();
|
||||
|
||||
var provider = new EodExchangeOptionPriceProvider(valueDate, true);
|
||||
|
||||
var price = provider.GetPrice("RBTest-P-2650");
|
||||
Assert.AreEqual(price, 12.22);
|
||||
|
||||
var hasPrice = provider.TryGetPrice(optionCode, out price);
|
||||
Assert.AreEqual(price, 12.22);
|
||||
|
||||
var priceModel = provider.GetPriceModel("RBTest-P-2650");
|
||||
Assert.AreEqual(priceModel.SettlePrice, 12.24);
|
||||
|
||||
provider.TryGetPriceModel("RBTest-P-2650", out priceModel);
|
||||
Assert.AreEqual(priceModel.HighPrice, 12.32);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using YLErp.BLL;
|
||||
using YLErp.DBModels;
|
||||
|
||||
namespace YLErp.Modules.DataProviderModule
|
||||
{
|
||||
[TestClass]
|
||||
public class ExchangeOptionPriceProviderTest : YLUnitTestBase
|
||||
{
|
||||
[TestMethod]
|
||||
public void TestGetPrice()
|
||||
{
|
||||
var valueDate = valuedateBLL.ValueDate;
|
||||
|
||||
const string optionCode = "RBTest-P-2650";
|
||||
|
||||
var insertModel = new ExchangeListOption
|
||||
{
|
||||
ContractCode = optionCode,
|
||||
ContractSize = 10,
|
||||
CreateTime = DateTime.Now,
|
||||
ExerciseMode = "European",
|
||||
MarginRate = 0.05,
|
||||
MarketCode = "TEST_TEST",
|
||||
MaturityDate = valueDate.AddMonths(1),
|
||||
OpenDate = valueDate.AddDays(-10),
|
||||
OptionType = "看跌",
|
||||
PrevClosePrice = 12.2,
|
||||
Price = 12.32,
|
||||
PriceTick = 0.1,
|
||||
PriceTime = DateTime.Now,
|
||||
Strike = 2650,
|
||||
UnderlyingCode = "RBTest"
|
||||
};
|
||||
|
||||
AddClearSQL<ExchangeListOption>($"ContractCode='{optionCode}'");
|
||||
|
||||
DbContext.exchange_list_option.Add(insertModel);
|
||||
DbContext.SaveChanges();
|
||||
|
||||
var provider = new ExchangeOptionPriceProvider();
|
||||
|
||||
var price = provider.GetPrice("RBTest-P-2650");
|
||||
Assert.AreEqual(price, 12.32);
|
||||
|
||||
var hasPrice = provider.TryGetPrice(optionCode, out price);
|
||||
Assert.AreEqual(price, 12.32);
|
||||
|
||||
var priceModel = provider.GetPriceModel("RBTest-P-2650");
|
||||
Assert.AreEqual(priceModel.Price, 12.32);
|
||||
|
||||
//场内期权没有取昨日收盘价
|
||||
provider.TryGetPriceModel("RBTest-P-2650", out priceModel);
|
||||
Assert.AreEqual(priceModel.PreClose, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using YLErp.DBModels;
|
||||
using YLErp.DBModels.Consts;
|
||||
|
||||
namespace YLErp.Modules.DataProviderModule
|
||||
{
|
||||
[TestClass]
|
||||
public class TradeHisDataProviderTest : YLUnitTestBase
|
||||
{
|
||||
[TestMethod]
|
||||
public void Test1()
|
||||
{
|
||||
TradeHisData t;
|
||||
|
||||
DbContext.BulkDelete<TradeHisData>($"{nameof(t.TradeId)} in (1)");
|
||||
|
||||
var value = 0.1;
|
||||
var datas = new TradeHisData[20];
|
||||
var startDate = DateTime.Today.AddYears(1);
|
||||
|
||||
for (var i = 0; i < 20; i += 2)
|
||||
{
|
||||
datas[i] = new TradeHisData
|
||||
{
|
||||
TradeId = 1,
|
||||
OptDate = DateTime.Now,
|
||||
OptId = 0,
|
||||
OptName = UserName,
|
||||
Value = value + i * 0.05,
|
||||
ValueDate = startDate.AddDays(i * 3),
|
||||
ValueType = ConsTradeField.NoRiskRate
|
||||
};
|
||||
|
||||
datas[i + 1] = datas[i].Clone();
|
||||
datas[i + 1].ValueType = ConsTradeField.DividendRate;
|
||||
}
|
||||
|
||||
DbContext.TradeHisData.AddRange(datas);
|
||||
DbContext.SaveChanges();
|
||||
|
||||
for (var i = 0; i < 10; i += 2)
|
||||
{
|
||||
var provider = new TradeHisDataProvider(datas[i].ValueDate.AddDays(1));
|
||||
|
||||
Assert.AreEqual(datas[i].Value.ToString("F4"), provider.GetNoRiskRate(1)?.ToString("F4"));
|
||||
Assert.AreEqual(datas[i + 1].Value.ToString("F4"), provider.GetDividendRate(1)?.ToString("F4"));
|
||||
|
||||
provider = new TradeHisDataProvider(datas[i].ValueDate.AddDays(2));
|
||||
provider.Initialize();
|
||||
|
||||
Assert.AreEqual(datas[i].Value.ToString("F4"), provider.GetNoRiskRate(1)?.ToString("F4"));
|
||||
Assert.AreEqual(datas[i + 1].Value.ToString("F4"), provider.GetDividendRate(1)?.ToString("F4"));
|
||||
|
||||
provider = new TradeHisDataProvider(datas[i].ValueDate.AddDays(6));
|
||||
|
||||
Assert.AreNotEqual(datas[i].Value.ToString("F4"), provider.GetNoRiskRate(1)?.ToString("F4"));
|
||||
Assert.AreNotEqual(datas[i + 1].Value.ToString("F4"), provider.GetDividendRate(1)?.ToString("F4"));
|
||||
}
|
||||
|
||||
DbContext.BulkDelete<TradeHisData>($"{nameof(t.TradeId)} in (1)");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,86 +0,0 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using YLErp.Abstract.DataProviders;
|
||||
using YLErp.BLL.Eod;
|
||||
using YLErp.BLL.EodSettlement;
|
||||
using YLErp.DBModels;
|
||||
using YLErp.Models;
|
||||
using YLErp.Modules.EodModule.SettlementModule;
|
||||
using YLErp.Modules.TradeModule;
|
||||
using YLErp.QdpModule;
|
||||
|
||||
namespace YLErp.Modules.EodModule
|
||||
{
|
||||
[TestClass]
|
||||
public class EodSettlementServiceTest : YLUnitTestBase
|
||||
{
|
||||
[TestMethod("TestGetEodTradePosition")]
|
||||
public void TestGetEodTradePosition()
|
||||
{
|
||||
var datas = new EodSettlementService(this).GetEodTradePosition<eod_trade_position_hedgevol>(new DateTime(2020, 8, 20));
|
||||
|
||||
Console.WriteLine(datas.Count());
|
||||
}
|
||||
|
||||
[TestMethod("测试收盘任务")]
|
||||
public void TestEodTask()
|
||||
{
|
||||
DbContext.Database.ExecuteSqlCommand("UPDATE eod_task set TaskState=101 where TaskState<100;");
|
||||
|
||||
var eodTask = new EodTaskSaveService(UserInfo).SaveData(new EodTaskSaveReq
|
||||
{
|
||||
StartDate = new DateTime(2020, 11, 23),
|
||||
//EndDate = new DateTime(2020, 11, 23),
|
||||
EndDate = new DateTime(2020, 11, 23),
|
||||
PriceType = EodSettlePriceType.ClosePrice,
|
||||
VolTypes = "持仓", //"对冲", "持仓", "开仓"
|
||||
PartFlag = "场外", // 全部,场内
|
||||
}, false);
|
||||
|
||||
EodTaskRunner.Execute();
|
||||
|
||||
var db = DbContextFactory.GetYLDbContext();
|
||||
|
||||
var eodTask2 = db.EodTask.Find(eodTask.id);
|
||||
|
||||
Console.WriteLine(eodTask2.TaskResult);
|
||||
|
||||
Assert.IsTrue(eodTask2.TaskState == EodTaskState.completed);
|
||||
}
|
||||
|
||||
[TestMethod("测试凤凰票息")]
|
||||
public void TestAutoCall()
|
||||
{
|
||||
new TradeAutocallBLL(OptUser).CheckStatus(new DateTime(2021, 03, 22), new AutocallPriceProvider(), new DateTime(2020, 03, 22), null);
|
||||
}
|
||||
|
||||
class AutocallPriceProvider : IEodPriceProvider
|
||||
{
|
||||
public bool TryGetEodPrice(int underlyingId, out EodPrice eodPrice)
|
||||
{
|
||||
eodPrice = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool TryGetEodPrice(string underlyingCode, out EodPrice eodPrice)
|
||||
{
|
||||
using (var db = DbContextFactory.GetYLDbContext())
|
||||
{
|
||||
eodPrice = db.eod_stock_price.Where(n => n.UnderlyingCode == underlyingCode).Select(n => new EodPrice
|
||||
{
|
||||
ClosePrice = n.ClosePrice,
|
||||
HighPrice = n.HighPrice,
|
||||
IsStock = true,
|
||||
LowPrice = n.LowPrice,
|
||||
SettlePrice = n.ClosePrice,
|
||||
UnderlyingCode = n.UnderlyingCode,
|
||||
ValueDate = n.ValueDate
|
||||
}).FirstOrDefault();
|
||||
|
||||
return eodPrice != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using YLErp.BLL.Calculation;
|
||||
using YLErp.Modules.CalculationModule;
|
||||
using YLErp.Modules.DataProviderModule;
|
||||
|
||||
namespace YLErp.Modules.MarginModule.MarginTests
|
||||
{
|
||||
[TestClass]
|
||||
public class BasicCalcTest : UnitTestBase
|
||||
{
|
||||
[TestMethod("测试CalculatorHelper计算")]
|
||||
public void TestOldNew()
|
||||
{
|
||||
var req = new CalculateRisksForTradesReqV1
|
||||
{
|
||||
userId = "1",
|
||||
addVolRateDic = null,
|
||||
isAddVolPercent = false,
|
||||
isEodSettle = false,
|
||||
isUseTradeVol = PS.Config.IsTradeVol,
|
||||
overrideVolsForTrade = null,
|
||||
PreciseTimeMode = true,
|
||||
pricingRequest = QdpModule.QdpPricingRequest.PV_ONLY,
|
||||
valueDate = DateTime.Today,
|
||||
volType = "交易"
|
||||
};
|
||||
|
||||
using (var db = DbContextFactory.GetYLDbContext())
|
||||
{
|
||||
req.tradeList = db.trade.Where(t => t.ValidState != ConsGlobal.InValid && t.ClientId > 0
|
||||
&& t.TradeType != "结构化交易" && t.TradeStatus == "确认成交" && t.SpotPrice != null)
|
||||
.OrderByDescending(n => n.id).Take(10).ToList();
|
||||
}
|
||||
|
||||
var priceDic = new Dictionary<string, double>();
|
||||
|
||||
foreach (var t in req.tradeList)
|
||||
{
|
||||
if (!priceDic.ContainsKey(t.UnderlyingCode))
|
||||
{
|
||||
priceDic[t.UnderlyingCode] = t.SpotPrice.Value * 1.08;
|
||||
}
|
||||
}
|
||||
|
||||
req.priceProvider = (ManualPriceProvider)priceDic;
|
||||
|
||||
var resultNew = CalculatorHelper.CalculateRisksForTrades(req);
|
||||
|
||||
var resultNewDic = resultNew.Results.ToDictionary(n => n.Trade.id);
|
||||
|
||||
//var resultOld = CalculatorHelperOld.CalculateRisksForTrades(
|
||||
// req.userId, req.settleDate, req.tradeList, priceDic, req.pricingRequest,
|
||||
// req.addVolRateDic, req.isEndOfDate, req.volType, req.overrideVolsForTrade, req.isUseTradeVol,
|
||||
// req.PreciseTimeMode, req.isAddVolPercent);
|
||||
|
||||
Assert.AreEqual(resultNew.Results.Count, req.tradeList.Count());
|
||||
//Assert.AreEqual(resultOld.Results.Count, req.tradeList.Count());
|
||||
|
||||
//foreach (var ro in resultOld.Results)
|
||||
//{
|
||||
// if (resultNewDic.TryGetValue(ro.Trade.id, out var rn))
|
||||
// {
|
||||
// Assert.IsTrue(Math.Abs((ro.ValueResult.Pv) - (rn.ValueResult.Pv)) < 1e-6);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Assert.Fail();
|
||||
// System.Diagnostics.Debug.WriteLine("没有计算出PV");
|
||||
// }
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace YLErp.Modules.MarginModule
|
||||
{
|
||||
[TestClass]
|
||||
public class MarginParamsProviderTest : UnitTestBase
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System.Linq;
|
||||
|
||||
namespace YLErp.Modules.SalesModule
|
||||
{
|
||||
[TestClass]
|
||||
public class SalesCommissionServiceTest : YLUnitTestBase
|
||||
{
|
||||
[TestMethod]
|
||||
public void TestGetSalesCommissionInfoDtos()
|
||||
{
|
||||
var dtos = new SalesCommissionDataService(this).GetSalesCommissionInfoDtos(106279);
|
||||
Assert.IsTrue(dtos.Any() && !string.IsNullOrEmpty(dtos.First().SalesmanName));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,241 +0,0 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using YLErp.Modules.TradeModule.OrderModule;
|
||||
using ClosedXML.Excel;
|
||||
|
||||
namespace YLErp.Modules.TradeModule
|
||||
{
|
||||
/// <summary>
|
||||
/// 场外期权交易导入测试
|
||||
/// </summary>
|
||||
[TestClass]
|
||||
public class OtcTradeImportServiceTest : UnitTestBase
|
||||
{
|
||||
[TestMethod("测试场外期权雪球交易导入")]
|
||||
public void TestImportSnowBallTrade()
|
||||
{
|
||||
List<OtcOptionTradeFullEx> trades = null;
|
||||
var path = Path.Combine(AppContext.BaseDirectory, "Resources\\场外期权导入\\场外期权交易导入(雪球).xlsx");
|
||||
using (var stream = new FileStream(path, FileMode.Open, FileAccess.Read))
|
||||
{
|
||||
trades = new OtcTradeImportService(CurUser).ReadOptionTradesFromExcel(stream);
|
||||
}
|
||||
|
||||
var td = trades[0];
|
||||
Assert.AreEqual(td.TradeNumber, "FH0001");
|
||||
Assert.AreEqual(td.AssetBookName, "FH0001");
|
||||
Assert.AreEqual(td.TraderName, "FH0001");
|
||||
Assert.AreEqual(td.TradeType, "雪球期权");
|
||||
Assert.AreEqual(td.BuySell, "买入");
|
||||
Assert.AreEqual(td.ExerciseMode, "European");
|
||||
Assert.AreEqual(td.TradeDate, new DateTime(2020, 8, 8));
|
||||
Assert.AreEqual(td.ExerciseDate, new DateTime(2021, 2, 1));
|
||||
Assert.AreEqual(td.SettlementDate, new DateTime(2021, 2, 1));
|
||||
Assert.AreEqual(td.UnderlyingCode, "FH0001");
|
||||
Assert.AreEqual(td.SpotPrice, 888.88);
|
||||
Assert.AreEqual(td.IsMoneynessOption, "是");
|
||||
Assert.AreEqual(td.Strike, 1.01);
|
||||
|
||||
Assert.AreEqual(td.TradeSinglePrice, 55.55);
|
||||
Assert.AreEqual(td.TradePrice, 555500);
|
||||
Assert.AreEqual(td.PremiumRate, 0.07);
|
||||
Assert.AreEqual(td.Notional, 1000);
|
||||
Assert.AreEqual(td.StockEqvNotional, 800000);
|
||||
Assert.AreEqual(td.StockEqvNotionalReal, 800000);
|
||||
|
||||
Assert.AreEqual(td.IsAnnualized, false);
|
||||
Assert.AreEqual(td.AnnualizeFactor, 1);
|
||||
Assert.AreEqual(td.MetaDic[nameof(td.AnnualizeFactor)], null);
|
||||
|
||||
Assert.AreEqual(td.IsAnnualized2, true);
|
||||
Assert.AreEqual(td.AnnualizeFactor2, 33.0 / 244);
|
||||
Assert.AreEqual(td.MetaDic[nameof(td.AnnualizeFactor2)], "33/244");
|
||||
|
||||
Assert.AreEqual(td.PrincipalRate, 0.1);
|
||||
Assert.AreEqual(td.ParticipationRate, 0.9);
|
||||
Assert.AreEqual(td.DividendRate, 0.01);
|
||||
Assert.AreEqual(td.NoRiskRate, 0.02);
|
||||
Assert.AreEqual(td.TradeOpenVolatility, 0.33);
|
||||
Assert.AreEqual(td.TradeCloseVolatility, 0.23);
|
||||
Assert.AreEqual(td.NumOfSmoothingDays, 50);
|
||||
Assert.AreEqual(td.SettlementType, 0);
|
||||
|
||||
Assert.AreEqual(td.Comments, "1111");
|
||||
|
||||
Assert.AreEqual(td.KOBarrier, 1.05);
|
||||
Assert.AreEqual(td.KOPayoffType, DBModels.KOPayoffTypeEnum.Rebate);
|
||||
Assert.AreEqual(td.IsFixedCoupon, false);
|
||||
Assert.AreEqual(td.KORebate, 0.1);
|
||||
Assert.AreEqual(td.SpreadStrikeAtKO1, null);
|
||||
Assert.AreEqual(td.SpreadStrikeAtKO, null);
|
||||
Assert.AreEqual(td.AnnualizedPremiumRate, 0.01);
|
||||
Assert.AreEqual(td.KORebateType, DBModels.RebateTypeEnum.AtHit);
|
||||
|
||||
Assert.AreEqual(td.KIBarrier, 0.98);
|
||||
Assert.AreEqual(td.KIPayoffType, DBModels.KIPayoffTypeEnum.ToCallOption);
|
||||
Assert.AreEqual(td.SpreadStrike1, 0.97);
|
||||
Assert.AreEqual(td.SpreadStrike, null);
|
||||
Assert.AreEqual(td.Coupon, 0.01);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestCreateImportExcel()
|
||||
{
|
||||
using (var fs = new FileStream("d:\\www999test.xlsx", FileMode.Create, FileAccess.ReadWrite))
|
||||
{
|
||||
CreateImportExcel("雪球期权", fs);
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateImportExcel(string tradeType, Stream streamIn)
|
||||
{
|
||||
using (var wb = new XLWorkbook())
|
||||
{
|
||||
var ws = wb.AddWorksheet("交易导入");
|
||||
|
||||
var basicFields = new MyField[] { "交易编号", "簿记账户名称", "交易员名称", "交易对手方名称",
|
||||
new MyField("结构类型"){ SetCell=cc=>cc.SetDataValidation().List("香草期权,亚式期权,合成价差期权,二元期权,障碍期权,双鲨期权,区间累积期权,凤凰期权,雪球期权,气囊结构,收益增强结构,自定义交易") },
|
||||
new MyField("交易方向"){ SetCell=cc=>cc.SetDataValidation().List("买入,卖出") },
|
||||
new MyField("行权方式"){ SetCell=cc=>cc.SetDataValidation().List("欧式,美式") },
|
||||
new MyField("看涨看跌"){ SetCell=cc=>cc.SetDataValidation().List("看涨,看跌") },
|
||||
"交易日期","到期日期","结算日期","标的代码", "标的价格",
|
||||
new MyField("相对行权价"){ SetCell=cc=>cc.SetDataValidation().List("是,否") },
|
||||
"执行价格",
|
||||
new MyField("权利金单价"){ SetCell=cc=>{
|
||||
cc.Style.Fill.BackgroundColor=XLColor.FromArgb(255,255,230,153);
|
||||
}},
|
||||
new MyField("权利金总额"){ SetCell=cc=>{
|
||||
cc.Style.Fill.BackgroundColor=XLColor.FromArgb(255,255,230,153);
|
||||
}},
|
||||
new MyField("期权费率%"){ SetCell=cc=>{
|
||||
cc.Style.Fill.BackgroundColor=XLColor.FromArgb(255,255,230,153);
|
||||
cc.WorksheetColumn().Style.NumberFormat.SetFormat("0.00%");
|
||||
}},
|
||||
new MyField("交易份额"){ SetCell=cc=>{
|
||||
cc.Style.Fill.BackgroundColor=XLColor.FromArgb(255,189,215,238);
|
||||
}},
|
||||
new MyField("名义本金"){ SetCell=cc=>{
|
||||
cc.Style.Fill.BackgroundColor=XLColor.FromArgb(255,189,215,238);
|
||||
}},
|
||||
new MyField("实际名义本金"){ SetCell=cc=>{
|
||||
cc.Style.Fill.BackgroundColor=XLColor.FromArgb(255,189,215,238);
|
||||
}},
|
||||
new MyField("期权年化"){ SetCell=cc=>cc.SetDataValidation().List("是,否") },
|
||||
"年化系数",
|
||||
new MyField("保底收益率%"){ SetCell=cc=>cc.WorksheetColumn().Style.NumberFormat.SetFormat("0.00%")},
|
||||
new MyField("参与率%"){ SetCell=cc=>cc.WorksheetColumn().Style.NumberFormat.SetFormat("0.00%")},
|
||||
new MyField("分红率%"){ SetCell=cc=>cc.WorksheetColumn().Style.NumberFormat.SetFormat("0.00%")},
|
||||
new MyField("无风险利率%"){ SetCell=cc=>cc.WorksheetColumn().Style.NumberFormat.SetFormat("0.00%")},
|
||||
new MyField("成交波动率%"){ SetCell=cc=>cc.WorksheetColumn().Style.NumberFormat.SetFormat("0.00%")},
|
||||
new MyField("目标波动率%"){ SetCell=cc=>cc.WorksheetColumn().Style.NumberFormat.SetFormat("0.00%")},
|
||||
"平滑过渡天数",
|
||||
new MyField("收益结算"){ SetCell=cc=>cc.SetDataValidation().List("收盘价,结算价") },
|
||||
"销售员",
|
||||
new MyField("提成方式"){ SetCell=cc=>cc.SetDataValidation().List("绝对值,比例") },
|
||||
"提成金额", "备注" };
|
||||
var cell = ws.Row(2).FirstCell();
|
||||
WriteExcelHeader("基本要素", basicFields, ws, ref cell, null);
|
||||
|
||||
//了结信息字段
|
||||
|
||||
|
||||
//奇异期权要素
|
||||
MyField[] exoticFields = null;
|
||||
|
||||
switch (tradeType)
|
||||
{
|
||||
case "雪球期权":
|
||||
exoticFields = new MyField[] { "敲出障碍价格", "敲出赔付类别", "票息年化", "票息率%", "敲出行权价1", "敲出行权价2", "年化期权费率%", "敲出支付方式", "票息支付日期", "敲入障碍价格", "敲入到期支付类别", "敲入行权价1", "敲入行权价2", "非敲入到期支付票息%" };
|
||||
break;
|
||||
}
|
||||
|
||||
if (exoticFields != null)
|
||||
{
|
||||
WriteExcelHeader(tradeType, exoticFields, ws, ref cell, null);
|
||||
}
|
||||
|
||||
WriteExcelHeader("敲入观察日设置", new MyField[] { "自定义观察日", "使用规则生成观察日" }, ws, ref cell, null);
|
||||
WriteExcelHeader("敲出观察日设置", new MyField[] { "观察日", "障碍价格", "票息率" }, ws, ref cell, null);
|
||||
|
||||
wb.SaveAs(streamIn);
|
||||
}
|
||||
}
|
||||
|
||||
private void WriteExcelHeader2(string mainCol, string[] subCols, IXLWorksheet ws, ref IXLCell firstCell)
|
||||
{
|
||||
var cell = firstCell;
|
||||
|
||||
foreach (var str in subCols)
|
||||
{
|
||||
cell.SetValue(str);
|
||||
cell = cell.CellRight();
|
||||
}
|
||||
|
||||
var above = firstCell.CellAbove().SetValue(mainCol);
|
||||
var wr = ws.Range(above, cell.CellLeft().CellAbove()).Merge();
|
||||
firstCell = cell;
|
||||
}
|
||||
|
||||
private void WriteExcelHeader(MyField mainCell, MyField[] subCells, IXLWorksheet ws, ref IXLCell firstCell, MyStyle myStyle)
|
||||
{
|
||||
var cell = firstCell;
|
||||
|
||||
foreach (var col in subCells)
|
||||
{
|
||||
cell.SetValue(col.Text);
|
||||
cell.Style.Font.Bold = true;
|
||||
if (myStyle != null)
|
||||
{
|
||||
cell.Style.Font.FontColor = myStyle.fgcolor;
|
||||
cell.Style.Fill.BackgroundColor = myStyle.bgcolor;
|
||||
}
|
||||
col.SetCell?.Invoke(cell);
|
||||
cell.WorksheetColumn().AdjustToContents();
|
||||
cell = cell.CellRight();
|
||||
}
|
||||
|
||||
var above = firstCell.CellAbove().SetValue(mainCell.Text);
|
||||
above.Style.Font.Bold = true;
|
||||
above.Style.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Center);
|
||||
if (myStyle != null)
|
||||
{
|
||||
above.Style.Font.FontColor = myStyle.fgcolor;
|
||||
above.Style.Fill.BackgroundColor = myStyle.bgcolor;
|
||||
}
|
||||
mainCell.SetCell?.Invoke(above);
|
||||
var wr = ws.Range(above, cell.CellLeft().CellAbove()).Merge();
|
||||
|
||||
firstCell = cell;
|
||||
}
|
||||
|
||||
class MyField
|
||||
{
|
||||
public string Text { get; private set; }
|
||||
|
||||
public Action<IXLCell> SetCell { get; set; }
|
||||
|
||||
public MyField(string text)
|
||||
{
|
||||
Text = text ?? throw new ArgumentNullException(nameof(text));
|
||||
}
|
||||
|
||||
public static implicit operator MyField(string text)
|
||||
{
|
||||
return new MyField(text);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Text;
|
||||
}
|
||||
}
|
||||
|
||||
class MyStyle
|
||||
{
|
||||
public XLColor bgcolor = XLColor.White;
|
||||
public XLColor fgcolor = XLColor.Black;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,347 +0,0 @@
|
||||
using KellermanSoftware.CompareNetObjects;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using YLErp.Commons;
|
||||
using YLErp.DBModels;
|
||||
using YLErp.DBModels.Consts;
|
||||
using YLErp.DBModels.Helpers;
|
||||
using YLErp.Model;
|
||||
|
||||
namespace YLErp.Modules.TradeModule.OrderModule
|
||||
{
|
||||
/// <summary>
|
||||
/// 测试交易保存服务
|
||||
/// </summary>
|
||||
|
||||
[TestClass]
|
||||
public class OtcTradeSaveServiceTest : YLUnitTestBase
|
||||
{
|
||||
readonly bool _delete = true;
|
||||
readonly CompareLogic _compareLogic;
|
||||
|
||||
public OtcTradeSaveServiceTest()
|
||||
{
|
||||
_compareLogic = new CompareLogic(new ComparisonConfig
|
||||
{
|
||||
MaxDifferences = 10,
|
||||
DoublePrecision = 5,
|
||||
MembersToIgnore = new List<string> { nameof(trade.id), nameof(trade.EncryptId),
|
||||
nameof(trade.CreateDate), nameof(trade.UnderlyingAssetClass) },
|
||||
CaseSensitive = false,
|
||||
});
|
||||
}
|
||||
|
||||
[TestMethod("测试保存香草期权交易")]
|
||||
public void TestSaveVanillaOption()
|
||||
{
|
||||
var asset = GetAssetUnit();
|
||||
var client = GetClient();
|
||||
var uly = GetUnderlyingManager(true);
|
||||
var valueDate = ValueDate;
|
||||
var td = new OtcOptionTradeFullEx
|
||||
{
|
||||
AssetBookName = asset.Name,
|
||||
TraderName = "Admin",
|
||||
ClientNumber = client.Number,
|
||||
ClientName = client.Name,
|
||||
TradeType = "香草期权",
|
||||
TradeNumber = "UAT-" + UniqueTimeId.GetStr(),
|
||||
UnderlyingCode= uly.UnderlyingCode,
|
||||
BuySell="买入",
|
||||
ExerciseMode= "European",
|
||||
OptionType="Put",
|
||||
SpotPrice=12900,
|
||||
IsMoneynessOption="否",
|
||||
Strike= 12900,
|
||||
TradeDate=valueDate,
|
||||
ExerciseDate=valueDate.AddMonths(3),
|
||||
SettlementDate = valueDate.AddMonths(3),
|
||||
Notional = 400,
|
||||
TradeSinglePrice=100,
|
||||
SettlementType=0,
|
||||
ParticipationRate=1,
|
||||
IsAnnualized=false,
|
||||
PrincipalRate=0,
|
||||
NoRiskRate=0.05,
|
||||
DividendRate=0,
|
||||
TradeOpenVolatility=0.1616,
|
||||
TradeCloseVolatility = 0.1616,
|
||||
NumOfSmoothingDays=1,
|
||||
Comments="测试API"
|
||||
};
|
||||
|
||||
var td2 = new OtcTradeSaveService(this.OptUser).SaveOptionTradeFromApiOrImport(td, Model.Enum.TradeSourceEnum.WebApiV2);
|
||||
|
||||
Assert.IsTrue(td.TradeSinglePrice==td2.TradeSinglePrice);
|
||||
}
|
||||
|
||||
[TestMethod("测试保存亚式期权交易")]
|
||||
public void TestSaveAsianOption()
|
||||
{
|
||||
InnerTest<trade_asian_option>("亚式期权");
|
||||
}
|
||||
|
||||
[TestMethod("测试保存二元期权交易")]
|
||||
public void TestSaveBinaryOption()
|
||||
{
|
||||
InnerTest<trade_binary_option>("二元期权");
|
||||
}
|
||||
|
||||
[TestMethod("测试保存障碍期权交易")]
|
||||
public void TestSaveBarrierOption()
|
||||
{
|
||||
InnerTest<trade_barrier_option>("障碍期权");
|
||||
}
|
||||
|
||||
[TestMethod("测试保存双鲨期权交易")]
|
||||
public void TestSaveDoubleSharkfinOption()
|
||||
{
|
||||
InnerTest<trade_double_sharkfin_option>("双鲨期权");
|
||||
}
|
||||
|
||||
[TestMethod("测试保存区间累积期权交易")]
|
||||
public void TestSaveRangeAccOption()
|
||||
{
|
||||
InnerTest<trade_rangeaccrual>("区间累积期权");
|
||||
}
|
||||
|
||||
[TestMethod("测试保存气囊结构交易")]
|
||||
public void TestSaveAirBagOption()
|
||||
{
|
||||
InnerTest<trade_airbag>("气囊结构");
|
||||
}
|
||||
|
||||
[TestMethod("测试保存收益增强结构交易")]
|
||||
public void TestSaveUnderlyingEnhanceOption()
|
||||
{
|
||||
InnerTest<trade_underlying_enhance>("收益增强结构");
|
||||
}
|
||||
|
||||
[TestMethod("测试保存雪球期权交易")]
|
||||
public void TestSaveSnowballOption()
|
||||
{
|
||||
InnerTest<trade_snowball>("雪球期权");
|
||||
}
|
||||
|
||||
[TestMethod("测试保存凤凰期权交易")]
|
||||
public void TestSaveAutoCallOption()
|
||||
{
|
||||
InnerTest<trade_autocall>("凤凰期权");
|
||||
}
|
||||
|
||||
private void InnerTest<TExtend>(string tradeType) where TExtend : TradeExtendBase
|
||||
{
|
||||
var asset = GetAssetUnit();
|
||||
var client = GetClient();
|
||||
var uly = GetUnderlyingManager(true);
|
||||
var valueDate = ValueDate;
|
||||
var td = new OtcOptionTradeFull
|
||||
{
|
||||
AnnualizedEnhanceRate = 0.01,
|
||||
AnnualizedPremiumRate = 0.01,
|
||||
AnnualizeFactor = 100.0 / 244,
|
||||
AnnualizeFactor2 = 0.9,
|
||||
AssetBookName = asset.Name,
|
||||
AssetId = asset.id,
|
||||
AveragingPeriodStartDate = valueDate,
|
||||
BarrierHigh = 1.05,
|
||||
BarrierLow = 0.95,
|
||||
BarrierShift = 10,
|
||||
BarrierType = "双障碍敲出",
|
||||
BasisGap = 1,
|
||||
BasisUnderlyingCode = "RB00",
|
||||
BasisUnderlyingId = uly.id,
|
||||
BonusRate = 0.1,
|
||||
BuySell = "卖出",
|
||||
CalcFlag = 0,
|
||||
CalcId = "CalcId",
|
||||
OptionType = "看涨",
|
||||
CashOrNothingAmount = 500,
|
||||
CashOrNothingAmountHigh = 1000,
|
||||
CashOrNothingAmountHighRate = 0.1,
|
||||
CashOrNothingAmountRate = 0.05,
|
||||
CheckStatus = 0,
|
||||
CheckTradeUpdate = 0,
|
||||
ClientId = client.id,
|
||||
ClientName = client.Name,
|
||||
Comments = "单元测试",
|
||||
ContractVersion = "V2",
|
||||
Coupon = 0.1,
|
||||
CouponBarrier = 1.05,
|
||||
CouponPayType = CouponPayTypeEnum.AtMaturity,
|
||||
CreateDate = valueDate,
|
||||
DividendDate = DateTime.MinValue,
|
||||
DividendRate = 0.1,
|
||||
DurationDays = 10,
|
||||
ExerciseDate = valueDate.AddMonths(3),
|
||||
ExerciseMode = ConsGlobal.ExerciseMode.American,
|
||||
FinalPrice = 3700,
|
||||
GroupId = 1,
|
||||
GroupName = "Test",
|
||||
HasPartialUnWind = 0,
|
||||
HasPayoffLimit = true,
|
||||
HighStrike = 1.05,
|
||||
IncludeCouponAfterKI = true,
|
||||
InitialSpotPriceState = "期初价格已确认",
|
||||
IsAnnualized = true,
|
||||
IsAnnualized2 = true,
|
||||
IsDiscreteMonitored = true,
|
||||
IsFixedCoupon = false,
|
||||
IsMoneynessOption = "是",
|
||||
IsSingleContract = 1,
|
||||
IsTradePricePayType = false,
|
||||
IsUsePremiumRate = true,
|
||||
|
||||
InitialMargin = 100,
|
||||
KIBarrier = 0.9,
|
||||
KIParticipationRate = 0.1,
|
||||
KIPayoffType = KIPayoffTypeEnum.ToCallSpreadOption,
|
||||
KOBarrier = 1.05,
|
||||
KOObservationDates = valueDate.OtcFormatDate(),
|
||||
KOObservationSettleDates = valueDate.OtcFormatDate(),
|
||||
KOPayoffType = KOPayoffTypeEnum.ToSpreadOption,
|
||||
KORebate = 0.1,
|
||||
KORebateType = RebateTypeEnum.AtEnd,
|
||||
Lots = 10,
|
||||
LowerRange = 0.9,
|
||||
MaturityDate = uly.MaturityDate,
|
||||
MonitorType = "离散",
|
||||
NoRiskRate = 0.05,
|
||||
NumOfSmoothingDays = 10,
|
||||
Notional = 100,
|
||||
ObservationDates = valueDate.OtcFormatDate(),
|
||||
ObservationDateStr = valueDate.OtcFormatDate(),
|
||||
OptDate = OptDate,
|
||||
OptId = UserId,
|
||||
OptName = UserName,
|
||||
OriginalNotional = 100,
|
||||
OriginalStockEqvNotional = 0,
|
||||
PairTrade = "",
|
||||
ParentTradeId = 0,
|
||||
ParticipationRate = 0.5,
|
||||
PayoffType = "DoubleNoTouch",
|
||||
PremiumPayDate = valueDate.AddMonths(3),
|
||||
PremiumRate = 0.1,
|
||||
PricingModel = "",
|
||||
PrincipalRate = 0.05,
|
||||
ProcessOptDate = null,
|
||||
ProcessOrderId = 0,
|
||||
ProcessStatus = "",
|
||||
Rebate = 500,
|
||||
RebateHigh = 1000,
|
||||
RebateRate = 0.05,
|
||||
RebateHighRate = 0.1,
|
||||
RebateType = "AtHit",
|
||||
SentMailCount = 0,
|
||||
SettlementDate = valueDate.AddMonths(3),
|
||||
SettlementType = 0,
|
||||
SpreadStrike = 0.95,
|
||||
SpreadStrike1 = 0.9,
|
||||
SpreadStrikeAtKO = 1.06,
|
||||
SpreadStrikeAtKO1 = 1.01,
|
||||
StartDate = valueDate,
|
||||
StockEqvNotional = 0,
|
||||
StockEqvNotionalMax = 0,
|
||||
StockEqvNotionalReal = 100 * 3600,
|
||||
Strike = 1.002,
|
||||
StrikeGearingFactor = 1,
|
||||
StrikeHigh = 1.02,
|
||||
StrikeType = ConsTrade.AsiaStrikeType.Fixed,
|
||||
StructureIntroduction = "StructureIntroduction",
|
||||
StructureType = "",
|
||||
TradeAmount = 100,
|
||||
TradeDate = valueDate,
|
||||
TradeInstruction = "TradeInstruction",
|
||||
TradeCloseVolatility = 0.5,
|
||||
TradeNumber = "UT-" + Guid.NewGuid().ToString("N"),
|
||||
TradeOpenVolatility = 0.45,
|
||||
TradePremium = 0.03,
|
||||
TraderId = 1,
|
||||
TraderName = "Admin",
|
||||
TradeSavedVol = 0.4,
|
||||
TradeSource = "系统交易",
|
||||
TradeStatus = "新增待确认",
|
||||
TradeType = tradeType,
|
||||
TradeUnit = "吨",
|
||||
TTMDays = null,
|
||||
UnderlyingAssetClass = "螺纹钢",
|
||||
UnderlyingCode = uly.UnderlyingCode,
|
||||
UnderlyingId = uly.id,
|
||||
UnderlyingInstrumentType = uly.UnderlyingInstrumentType,
|
||||
UnderlyingAssetName = uly.UnderlyingName,
|
||||
UnderlyingPrice = null,
|
||||
UnWindDate = null,
|
||||
UnWindNotional = null,
|
||||
UpperRange = 1.1,
|
||||
ValidState = ConsGlobal.Valid,
|
||||
Vol = null,
|
||||
VolType = null,
|
||||
SpotPrice = 3600
|
||||
};
|
||||
|
||||
td.KOObservationDates += "," + td.ExerciseDate.OtcFormatDate();
|
||||
|
||||
if (tradeType == "雪球期权" || tradeType == "凤凰期权")
|
||||
{
|
||||
td.IsAnnualized = false;
|
||||
td.AnnualizeFactor = 1;
|
||||
td.MetaDic[nameof(td.AnnualizeFactor)] = "/";
|
||||
|
||||
td.ExerciseMode = ConsTrade.ExerciseType.European;
|
||||
td.StockEqvNotionalMax = td.OriginalStockEqvNotional = td.StockEqvNotional = td.StockEqvNotionalReal;
|
||||
|
||||
var spotPrice = Math.Abs(td.SpotPrice.Value);
|
||||
td.StockEqvNotionalReal = TradeHelper.GetStockEqvNotionalReal(td.StockEqvNotional, td.ParticipationRate, td.AnnualizeFactor);
|
||||
td.TradeAmount = td.Notional = spotPrice > 0 ? td.StockEqvNotionalReal / spotPrice : 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
td.MetaDic[nameof(td.AnnualizeFactor)] = "100/244";
|
||||
|
||||
if (tradeType == "双鲨期权")
|
||||
{
|
||||
td.ExerciseMode = ConsTrade.ExerciseType.European;
|
||||
}
|
||||
else if (tradeType == "亚式期权")
|
||||
{
|
||||
td.PayoffType = ConsTrade.AsianAverageType.ArithmeticAverage;
|
||||
}
|
||||
td.StockEqvNotionalMax = td.OriginalStockEqvNotional = td.StockEqvNotional = TradeHelper.GetStockEqvNotional(td.StockEqvNotionalReal, td.ParticipationRate, td.AnnualizeFactor);
|
||||
}
|
||||
|
||||
td.OriginalNotional = td.Notional;
|
||||
td.TradePrice = TradeHelper.GetTradePriceByPremiumRate(td.PremiumRate, td.StockEqvNotional, td.ParticipationRate, td.PrincipalRate, td.AnnualizeFactor,td.BuySell,td.TradeType,false);
|
||||
td.TradeSinglePrice = TradeHelper.GetTradeSinglePriceByPremiumRate(td.PremiumRate, td.SpotPrice);
|
||||
|
||||
var saved = new OtcTradeSaveService(this).SaveOptionTradesFromTradeEdit(td);
|
||||
|
||||
td.id = saved.id;
|
||||
|
||||
var dbTrade = new TradeDetailsQueryService(this).GetOtcTradeFull(saved.TradeNumber);
|
||||
|
||||
if (_delete)
|
||||
{
|
||||
AddClearSQL<trade>("id=" + td.id);
|
||||
AddClearSQL<TradeMeta>("TradeId=" + td.id);
|
||||
AddClearSQL<TExtend>("TradeId=" + td.id);
|
||||
}
|
||||
|
||||
var map1 = YLAutoMapper.Map<OtcTradeBase>(td);
|
||||
var map2 = YLAutoMapper.Map<OtcTradeBase>(dbTrade);
|
||||
ComparisonResult result = _compareLogic.Compare(map1, map2);
|
||||
Assert.IsTrue(result.AreEqual, result.DifferencesString);
|
||||
|
||||
var tdex1 = YLAutoMapper.Map<TExtend>(td);
|
||||
var tdex2 = YLAutoMapper.Map<TExtend>(dbTrade);
|
||||
Assert.IsTrue(tdex2.TradeId > 0, "TradeId映射失败");
|
||||
result = _compareLogic.Compare(tdex1, tdex2);
|
||||
Assert.IsTrue(result.AreEqual, result.DifferencesString);
|
||||
}
|
||||
|
||||
class VanillaTrade : TradeExtendBase
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using YLErp.DBModels;
|
||||
|
||||
namespace YLErp.Modules.TradeModule.OrderModule
|
||||
{
|
||||
[TestClass]
|
||||
public class TradeAbstractServiceTest
|
||||
{
|
||||
[TestMethod]
|
||||
public void TestGetTradeAbstractInfo()
|
||||
{
|
||||
var td = new trade
|
||||
{
|
||||
TradeType = "香草期权",
|
||||
UnderlyingCode = "RB2009",
|
||||
IsUsePremiumRate = true,
|
||||
Strike = 1.1,
|
||||
TradeAmount = 100,
|
||||
ExerciseMode = "American",
|
||||
TradeNumber = "Test-001",
|
||||
TradeDate = new DateTime(2020, 1, 12),
|
||||
ExerciseDate = new DateTime(2020, 3, 1),
|
||||
ClientName = "福建龙岩可乐公司",
|
||||
BuySell = "买入",
|
||||
SpotPrice = 3350,
|
||||
PremiumRate = 0.23,
|
||||
TradeSinglePrice = 356,
|
||||
TradePrice = 199999,
|
||||
StockEqvNotional = 256789012,
|
||||
StockEqvNotionalReal = 256789012,
|
||||
ParticipationRate = 0.9,
|
||||
IsMoneynessOption = "是"
|
||||
};
|
||||
|
||||
var items = TradeAbstractService.GetTradeAbstractInfoItems(td);
|
||||
|
||||
foreach (var item in items)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine(item.text + ":" + item.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System.Linq;
|
||||
using YLErp.Modules.TradeModule.QueryModule;
|
||||
|
||||
namespace YLErp.Modules.TradeModule
|
||||
{
|
||||
/// <summary>
|
||||
/// 场外期权交易导出测试
|
||||
/// </summary>
|
||||
[TestClass]
|
||||
public class OtcTradeExportServiceTest : UnitTestBase
|
||||
{
|
||||
[TestMethod("测试场外期权交易导出")]
|
||||
public void TestImportTemplate()
|
||||
{
|
||||
var list = new OtcTradeListExportService(new OptUserInfo(0, "UnitTest")).SearchOptionTradeListForExport(new Model.TradeReq
|
||||
{
|
||||
TradeIds = "103506,103409"
|
||||
}, new TradeQueryRequest { ShowAllTrades = true });
|
||||
|
||||
Assert.AreEqual(list.Count(), 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using YLErp.DBModels;
|
||||
using YLErp.Model.Enum;
|
||||
using YLErp.Modules.TradeModule.OrderModule;
|
||||
|
||||
namespace YLErp.Modules.TradeModule
|
||||
{
|
||||
[TestClass]
|
||||
public class OtcTradeSaveServiceTest : YLUnitTestBase
|
||||
{
|
||||
[TestMethod]
|
||||
public void TestMethod1()
|
||||
{
|
||||
var model = new OtcOptionTradeFullEx
|
||||
{
|
||||
AssetBookName = "111",
|
||||
TraderName = "超级助理",
|
||||
ClientNumber = "F0028",
|
||||
TradeType = "合成价差期权",
|
||||
TradeNumber = "200610003",
|
||||
UnderlyingCode = "TA101-TA105",
|
||||
BuySell = "买入",
|
||||
ExerciseMode = "未知",
|
||||
OptionType = "看跌",
|
||||
SpotPrice = -102.0,
|
||||
Strike = -120.0,
|
||||
TradeDate = new DateTime(2020, 07, 17),
|
||||
ExerciseDate = new DateTime(2020, 07, 17),
|
||||
Notional = 3000.0,
|
||||
TradeSinglePrice = 18.23,
|
||||
TradeOpenVolatility = 6.7518667393419873,
|
||||
TradeCloseVolatility = 7.7646,
|
||||
NumOfSmoothingDays = 20,
|
||||
Comments = "F0028",
|
||||
SyntheticPrices = new UnderlyingPriceModel[]{
|
||||
new UnderlyingPriceModel
|
||||
{
|
||||
UnderlyingCode= "TA101",
|
||||
Price= 3857.0
|
||||
},
|
||||
new UnderlyingPriceModel{
|
||||
UnderlyingCode= "TA105",
|
||||
Price= 3959.0
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var trade = new OtcTradeSaveService(this).SaveOptionTradeFromApiOrImport(model, TradeSourceEnum.WebApiV2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
|
||||
namespace YLErp.Modules.TradeModule
|
||||
{
|
||||
[TestClass]
|
||||
public class TradeHisDataServiceTest : YLUnitTestBase
|
||||
{
|
||||
[TestMethod("保存交易持仓波动率")]
|
||||
public void TestSaveTradeVolatility()
|
||||
{
|
||||
var data = new TradeHisDataService(this).SaveTradeVolatility(new DBModels.TradeVolatilityDto
|
||||
{
|
||||
TradeNumber = "CW20180051C1693",
|
||||
NumOfSmoothingDays = 1,
|
||||
TradeCloseVolatility = 0.33,
|
||||
TradePositionVolatility = 0.33,
|
||||
},false);
|
||||
|
||||
Assert.IsTrue(Math.Abs((data.TradePositionVolatility ?? 0) - 0.33) < 1e-6);
|
||||
|
||||
data = new TradeHisDataService(this).SaveTradeVolatility(new DBModels.TradeVolatilityDto
|
||||
{
|
||||
TradeNumber = "CW20180051C1693",
|
||||
NumOfSmoothingDays = 1,
|
||||
TradeCloseVolatility = 0.36,
|
||||
TradePositionVolatility = 0.36,
|
||||
}, false);
|
||||
|
||||
Assert.IsTrue(Math.Abs((data.TradePositionVolatility ?? 0) - 0.36) < 1e-6);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using YLErp.Modules.UnderlyingModule.ApiModudle;
|
||||
|
||||
namespace YLErp.Modules.UnderlyingModule
|
||||
{
|
||||
[TestClass]
|
||||
public class ApiModuleTest : UnitTestBase
|
||||
{
|
||||
[TestMethod]
|
||||
public void TestGetUnderlyingList()
|
||||
{
|
||||
var datas = new ApiDataQueryService(CurUser).GetUnderlyingList();
|
||||
Assert.IsTrue(datas.Any());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,205 +0,0 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using YLErp.BLL;
|
||||
using YLErp.DBModels;
|
||||
using YLErp.Models;
|
||||
|
||||
namespace YLErp.Modules.UnderlyingModule
|
||||
{
|
||||
[TestClass]
|
||||
public class HisDataServiceTest : YLUnitTestBase
|
||||
{
|
||||
[TestMethod("测试历史数据升级(标的品种)")]
|
||||
public void TestVarietyUpdate()
|
||||
{
|
||||
var service = new VarietyDalService(OptUser);
|
||||
|
||||
var db = DbContextFactory.GetYLDbContext();
|
||||
|
||||
var va = db.variety.AsNoTracking().FirstOrDefault(n => n.VarietyCode == "LU");
|
||||
|
||||
va.id = 0;
|
||||
va.VarietyCode = "LUX";
|
||||
va.UpLimit = string.Empty;
|
||||
va = service.SaveData(va);
|
||||
|
||||
var date = va.Margin.HasValue ? valuedateBLL.ValueDate : new DateTime(2000, 1, 1);
|
||||
|
||||
var dvalue = 0.033;
|
||||
|
||||
va.Margin = dvalue;
|
||||
va.VolatilityRate = "3.3%";
|
||||
va.UpLimit = "3.3%";
|
||||
var va2 = service.SaveData(va);
|
||||
|
||||
Assert.AreEqual(va2.Margin, dvalue);
|
||||
|
||||
var tf = db.VarietyHisData.Any(n => n.VarietyId == va.id && n.ValueDate == date
|
||||
&& n.ValueType == nameof(MarginParamModel.MarginRate) && n.Value == dvalue);
|
||||
Assert.IsTrue(tf);
|
||||
}
|
||||
|
||||
[TestMethod("测试历史数据升级(标的资产)")]
|
||||
public void TestUnderlyingUpdate()
|
||||
{
|
||||
var service = new UnderlyingDalService(OptUser);
|
||||
|
||||
var db = DbContextFactory.GetYLDbContext();
|
||||
|
||||
var va = db.underlying_manager.AsNoTracking().FirstOrDefault(n => n.UnderlyingCode == "HC2106");
|
||||
|
||||
va.id = 0;
|
||||
va.UnderlyingCode = "HCC2106";
|
||||
va = service.SaveUnderlyingData(va);
|
||||
|
||||
var date = va.MarginRate.HasValue ? valuedateBLL.ValueDate : new DateTime(2000, 1, 1);
|
||||
|
||||
var dvalue = 0.033;
|
||||
|
||||
va.MarginRate = dvalue;
|
||||
va.VolatilityRate = "3.3%";
|
||||
va.UpDownLimit = "3.3%";
|
||||
var va2 = service.SaveUnderlyingData(va);
|
||||
|
||||
Assert.AreEqual(va2.MarginRate, dvalue);
|
||||
Assert.AreEqual(va2.VolatilityRate, 0.033);
|
||||
|
||||
var tf = db.UnderlyingHisData.Any(n => n.UnderlyingCode == va.UnderlyingCode && n.ValueDate == date
|
||||
&& n.ValueType == nameof(MarginParamModel.MarginRate) && n.Value == dvalue);
|
||||
Assert.IsTrue(tf);
|
||||
}
|
||||
|
||||
[TestMethod("测试标的历史数据回写")]
|
||||
public void TestUnderlyingBackHisDataToMainTable()
|
||||
{
|
||||
var un = GetUnderlyingManager();
|
||||
|
||||
var date = valuedateBLL.ValueDate.AddDays(-2);
|
||||
|
||||
AddClearSQL<UnderlyingHisData>("UnderlyingCode='{0}'", un.UnderlyingCode);
|
||||
|
||||
var service = new UnderlyingHisDataService(OptUser);
|
||||
|
||||
service.AddOrUpdateHisData(new UnderlyingHisDataAddOrUpdateRequest
|
||||
{
|
||||
UnderlyingCode = un.UnderlyingCode,
|
||||
Value = 0.0335,
|
||||
ValueDate = date,
|
||||
ValueFlag = "F",
|
||||
ValueType = nameof(MarginParamModel.MarginRate)
|
||||
});
|
||||
|
||||
service.AddOrUpdateHisData(new UnderlyingHisDataAddOrUpdateRequest
|
||||
{
|
||||
UnderlyingCode = un.UnderlyingCode,
|
||||
Value = 0.0355,
|
||||
ValueDate = date.AddDays(1),
|
||||
ValueFlag = "F",
|
||||
ValueType = nameof(MarginParamModel.MarginRate)
|
||||
});
|
||||
|
||||
service.AddOrUpdateHisData(new UnderlyingHisDataAddOrUpdateRequest
|
||||
{
|
||||
UnderlyingCode = un.UnderlyingCode,
|
||||
Value = null,
|
||||
ValueDate = date.AddDays(1),
|
||||
ValueFlag = "F",
|
||||
ValueType = nameof(MarginParamModel.MarginRate)
|
||||
});
|
||||
|
||||
service.AddOrUpdateHisData(new UnderlyingHisDataAddOrUpdateRequest
|
||||
{
|
||||
UnderlyingCode = un.UnderlyingCode,
|
||||
Value = 0.0335,
|
||||
ValueDate = date,
|
||||
ValueFlag = "F",
|
||||
ValueType = nameof(MarginParamModel.VolatilityRate)
|
||||
});
|
||||
|
||||
service.AddOrUpdateHisData(new UnderlyingHisDataAddOrUpdateRequest
|
||||
{
|
||||
UnderlyingCode = un.UnderlyingCode,
|
||||
Value = 33.555,
|
||||
ValueDate = date,
|
||||
ValueFlag = "F",
|
||||
ValueType = nameof(MarginParamModel.UpDownLimit)
|
||||
});
|
||||
|
||||
service.AddOrUpdateHisData(new UnderlyingHisDataAddOrUpdateRequest
|
||||
{
|
||||
UnderlyingCode = un.UnderlyingCode,
|
||||
Value = null,
|
||||
ValueDate = date,
|
||||
ValueFlag = "F",
|
||||
ValueType = nameof(MarginParamModel.UpDownLimit)
|
||||
});
|
||||
|
||||
var changes = service.BackHisDataToMainTable();
|
||||
|
||||
Assert.IsTrue(changes == 3);
|
||||
|
||||
var un2 = DbContextFactory.GetYLDbContext().underlying_manager.FirstOrDefault(n => n.UnderlyingCode == un.UnderlyingCode);
|
||||
|
||||
//Assert.IsTrue(un2.MarginRate == 0.0355);
|
||||
Assert.IsTrue(un2.MarginRate == null);
|
||||
Assert.IsTrue(un2.VolatilityRate == "3.35%");
|
||||
Assert.IsTrue(string.IsNullOrEmpty(un2.UpDownLimit));//"33.555"
|
||||
}
|
||||
|
||||
[TestMethod("测试品种历史数据回写")]
|
||||
public void TestVarietyBackHisDataToMainTable()
|
||||
{
|
||||
var va = GetVariety();
|
||||
|
||||
var date = valuedateBLL.ValueDate.AddDays(-2);
|
||||
|
||||
AddClearSQL<VarietyHisData>("VarietyId='{0}'", va.id);
|
||||
|
||||
var service = new VarietyHisDataService(OptUser);
|
||||
|
||||
service.AddOrUpdateHisData(new VarietyHisDataAddOrUpdateRequest
|
||||
{
|
||||
VarietyId = va.id,
|
||||
Value = 0.0335,
|
||||
ValueDate = date,
|
||||
ValueType = nameof(MarginParamModel.MarginRate)
|
||||
});
|
||||
|
||||
service.AddOrUpdateHisData(new VarietyHisDataAddOrUpdateRequest
|
||||
{
|
||||
VarietyId = va.id,
|
||||
Value = 0.0355,
|
||||
ValueDate = date.AddDays(1),
|
||||
ValueType = nameof(MarginParamModel.MarginRate)
|
||||
});
|
||||
|
||||
service.AddOrUpdateHisData(new VarietyHisDataAddOrUpdateRequest
|
||||
{
|
||||
VarietyId = va.id,
|
||||
Value = 0.0335,
|
||||
ValueDate = date,
|
||||
ValueType = nameof(MarginParamModel.VolatilityRate)
|
||||
});
|
||||
|
||||
service.AddOrUpdateHisData(new VarietyHisDataAddOrUpdateRequest
|
||||
{
|
||||
VarietyId = va.id,
|
||||
Value = 0.05566,
|
||||
ValueDate = date,
|
||||
ValueType = nameof(MarginParamModel.UpDownLimit)
|
||||
});
|
||||
|
||||
var changes = service.BackHisDataToMainTable();
|
||||
|
||||
Assert.IsTrue(changes == 3);
|
||||
|
||||
var va2 = DbContextFactory.GetYLDbContext().variety.FirstOrDefault(n => n.id == va.id);
|
||||
|
||||
Assert.IsTrue(va2.Margin == 0.0355);
|
||||
Assert.IsTrue(va2.VolatilityRate == "3.35%");
|
||||
Assert.IsTrue(va2.UpLimit == "5.566%");
|
||||
Assert.IsTrue(va2.DownLimit == "5.566%");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,91 +0,0 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using System.Data.Entity.Infrastructure;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using YLErp.BLL;
|
||||
using YLErp.DBModels;
|
||||
|
||||
namespace YLErp.Modules.MarginModule
|
||||
{
|
||||
[TestClass]
|
||||
public class MarginParamsImportServiceTest : YLUnitTestBase
|
||||
{
|
||||
[TestMethod("测试标的保证金参数导入")]
|
||||
public void TestImportUnderlying()
|
||||
{
|
||||
var un = GetUnderlyingManager();
|
||||
|
||||
AddClearSQL<UnderlyingHisData>("{0}='{1}'", nameof(UnderlyingHisData.UnderlyingCode), un.UnderlyingCode);
|
||||
|
||||
using (var ms = new MemoryStream())
|
||||
{
|
||||
WriteExcel(false, un.UnderlyingCode, ms);
|
||||
var result = new MarginParamsImportService(this).ImportUnderlying(ms);
|
||||
Assert.IsTrue(result.SuccessSum > 0, result.ResultMsg);
|
||||
Assert.IsTrue(un.MarginRate == 0.077);
|
||||
var datas = DbContext.UnderlyingHisData.Where(n => n.UnderlyingCode == un.UnderlyingCode).ToArray();
|
||||
Assert.IsTrue(datas.Length == 1 && datas[0].Value == 0.077);
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod("测试品种保证金参数导入")]
|
||||
public void TestImportVariety()
|
||||
{
|
||||
var va = GetVariety();
|
||||
|
||||
AddClearSQL<VarietyHisData>("{0}='{1}'", nameof(VarietyHisData.VarietyId), va.id);
|
||||
|
||||
using (var ms = new MemoryStream())
|
||||
{
|
||||
WriteExcel(true, va.VarietyCode, ms);
|
||||
var result = new MarginParamsImportService(this).ImportVariety(ms);
|
||||
Assert.IsTrue(result.SuccessSum > 0, result.ResultMsg);
|
||||
Assert.IsTrue(va.Margin == 0.077);
|
||||
var datas = DbContext.VarietyHisData.Where(n => n.VarietyId == va.id).ToArray();
|
||||
Assert.IsTrue(datas.Length == 1 && datas[0].Value == 0.077);
|
||||
}
|
||||
}
|
||||
|
||||
private void WriteExcel(bool isVariety, string code, Stream streamIn)
|
||||
{
|
||||
var codeColName = isVariety ? "品种代码" : "标的代码";
|
||||
|
||||
using (var wb = new ClosedXML.Excel.XLWorkbook())
|
||||
{
|
||||
var ws = wb.AddWorksheet("保证金比例");
|
||||
var cell = ws.FirstCell();
|
||||
foreach (var str in new[] { codeColName, "变动日期", "保证金比例" })
|
||||
{
|
||||
cell.SetValue(str);
|
||||
cell = cell.CellRight();
|
||||
}
|
||||
cell = ws.Row(2).FirstCell();
|
||||
foreach (var str in new[] { code, valuedateBLL.ValueDate.OtcFormatDate(), "7.7%" })
|
||||
{
|
||||
cell.SetValue(str);
|
||||
cell = cell.CellRight();
|
||||
}
|
||||
|
||||
ws = wb.AddWorksheet("Span波动率变动");
|
||||
cell = ws.FirstCell();
|
||||
foreach (var str in new[] { codeColName, "变动日期", "Span波动率变动" })
|
||||
{
|
||||
cell.SetValue(str);
|
||||
cell = cell.CellRight();
|
||||
}
|
||||
|
||||
|
||||
ws = wb.AddWorksheet("Span涨跌幅度");
|
||||
cell = ws.FirstCell();
|
||||
foreach (var str in new[] { codeColName, "变动日期", "Span涨跌幅度" })
|
||||
{
|
||||
cell.SetValue(str);
|
||||
cell = cell.CellRight();
|
||||
}
|
||||
|
||||
wb.SaveAs(streamIn);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,145 +0,0 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using YLErp.DBModels;
|
||||
using YLErp.Modules.DataProviderModule;
|
||||
|
||||
namespace YLErp.Modules.VolatilityModule
|
||||
{
|
||||
[TestClass]
|
||||
public class VarietyVolServiceTest : YLUnitTestBase
|
||||
{
|
||||
[ClassInitialize]
|
||||
public static void Init(TestContext context)
|
||||
{
|
||||
using (var db = DbContextFactory.GetYLDbContext())
|
||||
{
|
||||
db.OptUser = new OptUserInfo(0, "UnitTest");
|
||||
|
||||
db.Database.ExecuteSqlCommand("truncate table variety_vol;");
|
||||
|
||||
var datas = new[] {
|
||||
new VarietyVol{ VarietyId = 1,ValueDate = new DateTime(2020,9,1),Vol = 0.301 },
|
||||
new VarietyVol{ VarietyId = 1,ValueDate = new DateTime(2020,9,3),Vol = 0.311 },
|
||||
new VarietyVol{ VarietyId = 1,ValueDate = new DateTime(2020,9,13),Vol = 0.331 },
|
||||
|
||||
new VarietyVol{ VarietyId = 2,ValueDate = new DateTime(2020,9,21),Vol = 0.401 },
|
||||
new VarietyVol{ VarietyId = 2,ValueDate = new DateTime(2020,9,22),Vol = 0.501 },
|
||||
new VarietyVol{ VarietyId = 2,ValueDate = new DateTime(2020,10,10),Vol = 0.601 },
|
||||
};
|
||||
|
||||
foreach (var data in datas)
|
||||
{
|
||||
data.OptId = 0;
|
||||
data.OptName = "UnitTest";
|
||||
data.OptDate = DateTime.Now;
|
||||
}
|
||||
|
||||
db.variety_vol.AddRange(datas);
|
||||
db.SaveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestGetVols()
|
||||
{
|
||||
var dates = new[] { new DateTime(2020, 9, 10), new DateTime(2020, 9, 22) };
|
||||
var check = new[] {
|
||||
new Action<VarietyVolDto[]>(n=>{
|
||||
Assert.IsTrue(n.Length == 1);
|
||||
Assert.IsTrue(n[0].Vol == 0.311);
|
||||
Assert.IsTrue(n[0].ValueDate == new DateTime(2020, 9, 3));
|
||||
}),
|
||||
new Action<VarietyVolDto[]>(n=>{
|
||||
Assert.IsTrue(n.Length == 2);
|
||||
Assert.IsTrue(n[0].Vol == 0.331);
|
||||
Assert.IsTrue(n[0].ValueDate == new DateTime(2020, 9, 13));
|
||||
|
||||
Assert.IsTrue(n[1].Vol == 0.501);
|
||||
Assert.IsTrue(n[1].ValueDate == new DateTime(2020, 9, 22));
|
||||
}),
|
||||
};
|
||||
|
||||
for (var i = 0; i < dates.Length; i++)
|
||||
{
|
||||
var date = dates[i];
|
||||
|
||||
var grpQry = from vol in DbContext.variety_vol
|
||||
where vol.ValueDate <= date
|
||||
group vol by vol.VarietyId into grp
|
||||
select new
|
||||
{
|
||||
VarietyId = grp.Key,
|
||||
ValueDate = grp.Max(n => n.ValueDate)
|
||||
};
|
||||
|
||||
var qry = from gv in grpQry
|
||||
join vol in DbContext.variety_vol on gv equals new { vol.VarietyId, vol.ValueDate }
|
||||
orderby gv.VarietyId
|
||||
select new VarietyVolDto
|
||||
{
|
||||
VarietyId = vol.VarietyId,
|
||||
ValueDate = vol.ValueDate,
|
||||
Vol = vol.Vol
|
||||
};
|
||||
|
||||
var qryDatas = qry.ToArray();
|
||||
|
||||
check[i](qryDatas);
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestGetVols2()
|
||||
{
|
||||
var dates = new[] { new DateTime(2020, 9, 10), new DateTime(2020, 9, 22) };
|
||||
var check = new[] {
|
||||
new Action<VarietyVolDto[]>(n=>{
|
||||
Assert.IsTrue(n.Length == 3);
|
||||
Assert.IsTrue(n[0].Vol == 0.311);
|
||||
Assert.IsTrue(n[0].ValueDate == new DateTime(2020, 9, 3));
|
||||
|
||||
Assert.IsTrue(n[1].Vol == 0.3);
|
||||
Assert.IsTrue(n[1].ValueDate == new DateTime(2020, 9, 10));
|
||||
|
||||
Assert.IsTrue(n[2].Vol == 0.3);
|
||||
Assert.IsTrue(n[2].ValueDate == new DateTime(2020, 9, 10));
|
||||
}),
|
||||
new Action<VarietyVolDto[]>(n=>{
|
||||
Assert.IsTrue(n.Length == 3);
|
||||
Assert.IsTrue(n[0].Vol == 0.331);
|
||||
Assert.IsTrue(n[0].ValueDate == new DateTime(2020, 9, 13));
|
||||
|
||||
Assert.IsTrue(n[1].Vol == 0.501);
|
||||
Assert.IsTrue(n[1].ValueDate == new DateTime(2020, 9, 22));
|
||||
|
||||
Assert.IsTrue(n[2].Vol == 0.3);
|
||||
Assert.IsTrue(n[2].ValueDate == new DateTime(2020, 9, 22));
|
||||
}),
|
||||
};
|
||||
|
||||
for (var i = 0; i < dates.Length; i++)
|
||||
{
|
||||
var date = dates[i];
|
||||
|
||||
var qryDatas = new VarietyVolService(this).GetVols(date, new[] { 1, 2, 3 });
|
||||
|
||||
check[i](qryDatas.ToArray());
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestGetVols3()
|
||||
{
|
||||
var provider = new VarietyVolProvider(new DateTime(2020, 9, 22));
|
||||
|
||||
Assert.IsTrue(provider.TryGetVol(1, out var vol1)&&vol1 == 0.331);
|
||||
|
||||
Assert.IsTrue(provider.TryGetVol(5, out var vol11)&&vol11 == 0.3);
|
||||
|
||||
Assert.IsTrue(provider.TryGetVol("RB00", out var vol2) && vol2 == 0.501);
|
||||
|
||||
Assert.IsTrue(provider.TryGetVol("ceshi1", out var vol3) && vol3 == 0.3);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using YLErp.DBModels;
|
||||
using YLErp.Models;
|
||||
using YLErp.QdpModule.Constants;
|
||||
|
||||
namespace YLErp.Modules.VolatilityModule
|
||||
{
|
||||
[TestClass]
|
||||
public class VolatilityBasicTest
|
||||
{
|
||||
[TestMethod("测试波动率数据序列化")]
|
||||
public void TestSerialize()
|
||||
{
|
||||
var date = new DateTime(2020, 4, 23);
|
||||
|
||||
var vola = VolatilityBuilder.CreateMoneynessVolBuilder(date)
|
||||
.SetUnderlying(111, "RB2005").SetData(0.25533333).Build();
|
||||
|
||||
Assert.AreEqual(vola.QuotationDate, date);
|
||||
Assert.AreEqual(vola.VolType, ConsVolInfos.defVolType);
|
||||
Assert.AreEqual(vola.VolSurfaceMode, ConsVolInfos.defVolMode);
|
||||
Assert.AreEqual(vola.UnderlyingId, 111);
|
||||
Assert.AreEqual(vola.ContractCode, "RB2005");
|
||||
|
||||
var list = JsonHelper.Deserialize<List<SingleVol>>(vola.Data);
|
||||
|
||||
Assert.AreEqual(0.255333, list[0].Vol);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,142 +0,0 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using YLErp.DBModels;
|
||||
|
||||
namespace YLErp.Modules.VolatilityModule
|
||||
{
|
||||
[TestClass]
|
||||
public class VolatilityQueryServiceTest : YLUnitTestBase
|
||||
{
|
||||
readonly VolatilityQueryService service;
|
||||
|
||||
public VolatilityQueryServiceTest()
|
||||
{
|
||||
service = new VolatilityQueryService(new OptUserInfo(0, "UnitTest"));
|
||||
}
|
||||
|
||||
[TestMethod("获取单个标的的曲面波动率")]
|
||||
public void TestGetVolatility()
|
||||
{
|
||||
var date = new DateTime(2020, 4, 20);
|
||||
|
||||
//标的不存在的情况下获取不到波动率
|
||||
|
||||
var vols = service.GetVolatility(new SingleVolatilityRequest
|
||||
{
|
||||
QuotationDate = date,
|
||||
TradeVolWithBidAsk = true,
|
||||
UnderlyingId = 1,
|
||||
UnderlyingCode = "TA006",
|
||||
UserGroup = "",
|
||||
VolType = "交易"
|
||||
});
|
||||
|
||||
Assert.AreEqual(vols.Count(), 0);
|
||||
|
||||
//同源标的不存在波动率的情况下获取默认波动率
|
||||
|
||||
var vols2 = service.GetVolatility(new SingleVolatilityRequest
|
||||
{
|
||||
QuotationDate = date,
|
||||
TradeVolWithBidAsk = true,
|
||||
UnderlyingCode = "AP005",
|
||||
UserGroup = "",
|
||||
VolType = "交易"
|
||||
});
|
||||
|
||||
Assert.AreEqual(vols2.Count(), 3);
|
||||
Assert.AreEqual(vols2.First().VolTable[0].Vol, 0.3);
|
||||
Assert.AreEqual(vols2.First().QuotationDate, date);
|
||||
|
||||
var vols3 = service.GetVolatility(new SingleVolatilityRequest
|
||||
{
|
||||
QuotationDate = date,
|
||||
TradeVolWithBidAsk = true,
|
||||
UnderlyingId = 14,
|
||||
//UnderlyingCode = "AP005",
|
||||
UserGroup = "",
|
||||
VolType = "交易"
|
||||
});
|
||||
|
||||
Assert.AreEqual(vols3.Count(), 3);
|
||||
Assert.AreEqual(vols3.First().VolTable[0].Vol, 0.3);
|
||||
Assert.AreEqual(vols3.First().QuotationDate, date);
|
||||
|
||||
//标的已过期的情况下返回波动率为0的默认波动率
|
||||
|
||||
var vols4 = service.GetVolatility(new SingleVolatilityRequest
|
||||
{
|
||||
QuotationDate = date,
|
||||
TradeVolWithBidAsk = true,
|
||||
UnderlyingCode = "RB2003",
|
||||
UserGroup = "",
|
||||
VolType = "交易"
|
||||
});
|
||||
|
||||
Assert.AreEqual(vols4.Count(), 3);
|
||||
Assert.AreEqual(vols4.First().VolTable[0].Vol, 0);
|
||||
Assert.AreEqual(vols4.First().QuotationDate, date);
|
||||
}
|
||||
|
||||
[TestMethod("获取单个标的的曲面波动率2")]
|
||||
public void TestGetVolatility2()
|
||||
{
|
||||
var date = DateTime.Today;
|
||||
|
||||
var vols = service.GetVolatility(new SingleVolatilityRequest
|
||||
{
|
||||
QuotationDate = date,
|
||||
TradeVolWithBidAsk = true,
|
||||
UnderlyingCode = "AL00",
|
||||
VolType = "交易"
|
||||
});
|
||||
|
||||
Assert.AreEqual(vols.Count(), 0);
|
||||
}
|
||||
|
||||
[TestMethod("获取批量标的的曲面波动率")]
|
||||
public void TestGetVolatilities()
|
||||
{
|
||||
var vols = service.GetVolatilities(new BatchVolatilityRequest
|
||||
{
|
||||
QuotationDate = DateTime.Today,
|
||||
TradeVolWithBidAsk = true,
|
||||
UserGroup = string.Empty,
|
||||
VolType = "交易"
|
||||
}, true);
|
||||
}
|
||||
|
||||
[TestMethod("验证波动率复制")]
|
||||
public void TestMissingVolatilities()
|
||||
{
|
||||
var un = GetUnderlyingManager();
|
||||
|
||||
AddClearSQL<volatility>($"{nameof(volatility.ContractCode)}='{un.UnderlyingCode}'");
|
||||
|
||||
var vols = service.GetVolatility(new SingleVolatilityRequest
|
||||
{
|
||||
QuotationDate = DateTime.Today,
|
||||
TradeVolWithBidAsk = false,
|
||||
UserGroup = string.Empty,
|
||||
VolType = "交易",
|
||||
UnderlyingCode = un.UnderlyingCode,
|
||||
UnderlyingId = un.id
|
||||
}, true);
|
||||
|
||||
Assert.IsTrue(vols.Count() == 1 && vols.First().VolTable[0].Vol == 0.3);
|
||||
|
||||
var vols2 = service.GetVolatility(new SingleVolatilityRequest
|
||||
{
|
||||
QuotationDate = DateTime.Today,
|
||||
TradeVolWithBidAsk = true,
|
||||
UserGroup = string.Empty,
|
||||
VolType = "交易",
|
||||
UnderlyingCode = un.UnderlyingCode,
|
||||
UnderlyingId = un.id
|
||||
}, true);
|
||||
|
||||
Assert.IsTrue(vols2.Count() == 3 && vols2.First().VolTable[0].Vol == 0.3);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
[assembly: AssemblyTitle("YLErpUnitTest")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("YLErpUnitTest")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2020")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
[assembly: Guid("12baf174-cb2f-4a92-9c82-b7ae28c1bad9")]
|
||||
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
-63
@@ -1,63 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 此代码由工具生成。
|
||||
// 运行时版本:4.0.30319.42000
|
||||
//
|
||||
// 对此文件的更改可能会导致不正确的行为,并且如果
|
||||
// 重新生成代码,这些更改将会丢失。
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace YLErp.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 一个强类型的资源类,用于查找本地化的字符串等。
|
||||
/// </summary>
|
||||
// 此类是由 StronglyTypedResourceBuilder
|
||||
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
|
||||
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
|
||||
// (以 /str 作为命令选项),或重新生成 VS 项目。
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 返回此类使用的缓存的 ResourceManager 实例。
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("YLErp.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重写当前线程的 CurrentUICulture 属性
|
||||
/// 重写当前线程的 CurrentUICulture 属性。
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,120 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
@@ -1,28 +0,0 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
|
||||
namespace YLErp.QdpModule
|
||||
{
|
||||
[TestClass]
|
||||
public class QdpCalendarTest
|
||||
{
|
||||
[TestMethod]
|
||||
public void TestGetWorkDayCount()
|
||||
{
|
||||
var date = DateTime.Today;
|
||||
|
||||
for (var i = 0; i < 7; i++)
|
||||
{
|
||||
if (date.DayOfWeek == DayOfWeek.Monday)
|
||||
{
|
||||
break;
|
||||
}
|
||||
date = date.AddDays(1);
|
||||
}
|
||||
|
||||
var daycount= QdpCalendarHelper.GetWorkDayCount(date, date.AddDays(2));
|
||||
|
||||
Assert.AreEqual(daycount, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
[{
|
||||
"Strike": 0.9,
|
||||
"Expire": "1W",
|
||||
"Vol": 0.3
|
||||
}, {
|
||||
"Strike": 0.9,
|
||||
"Expire": "2W",
|
||||
"Vol": 0.3
|
||||
}, {
|
||||
"Strike": 0.9,
|
||||
"Expire": "1M",
|
||||
"Vol": 0.3
|
||||
}, {
|
||||
"Strike": 0.95,
|
||||
"Expire": "1W",
|
||||
"Vol": 0.3
|
||||
}, {
|
||||
"Strike": 0.95,
|
||||
"Expire": "2W",
|
||||
"Vol": 0.3
|
||||
}, {
|
||||
"Strike": 0.95,
|
||||
"Expire": "1M",
|
||||
"Vol": 0.3
|
||||
}, {
|
||||
"Strike": 1.0,
|
||||
"Expire": "1W",
|
||||
"Vol": 0.3
|
||||
}, {
|
||||
"Strike": 1.0,
|
||||
"Expire": "2W",
|
||||
"Vol": 0.3
|
||||
}, {
|
||||
"Strike": 1.0,
|
||||
"Expire": "1M",
|
||||
"Vol": 0.3
|
||||
}, {
|
||||
"Strike": 1.05,
|
||||
"Expire": "1W",
|
||||
"Vol": 0.3
|
||||
}, {
|
||||
"Strike": 1.05,
|
||||
"Expire": "2W",
|
||||
"Vol": 0.3
|
||||
}, {
|
||||
"Strike": 1.05,
|
||||
"Expire": "1M",
|
||||
"Vol": 0.3
|
||||
}, {
|
||||
"Strike": 1.1,
|
||||
"Expire": "1W",
|
||||
"Vol": 0.3
|
||||
}, {
|
||||
"Strike": 1.1,
|
||||
"Expire": "2W",
|
||||
"Vol": 0.3
|
||||
}, {
|
||||
"Strike": 1.1,
|
||||
"Expire": "1M",
|
||||
"Vol": 0.3
|
||||
}
|
||||
]
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,183 +0,0 @@
|
||||
ALTER TABLE `eod_trade_position` DROP COLUMN `ActualLastPv`;
|
||||
ALTER TABLE `eod_trade_position` DROP COLUMN `ActualPv`;
|
||||
ALTER TABLE `eod_trade_position` DROP COLUMN `ActualDailyPnL`;
|
||||
ALTER TABLE `eod_trade_position` DROP COLUMN `ActualTotalPnL`;
|
||||
|
||||
ALTER TABLE `eod_trade_position_s` DROP COLUMN `ActualLastPv`;
|
||||
ALTER TABLE `eod_trade_position_s` DROP COLUMN `ActualPv`;
|
||||
ALTER TABLE `eod_trade_position_s` DROP COLUMN `ActualDailyPnL`;
|
||||
ALTER TABLE `eod_trade_position_s` DROP COLUMN `ActualTotalPnL`;
|
||||
|
||||
ALTER TABLE `eod_trade_position_hedgevol` DROP COLUMN `ActualLastPv`;
|
||||
ALTER TABLE `eod_trade_position_hedgevol` DROP COLUMN `ActualPv`;
|
||||
ALTER TABLE `eod_trade_position_hedgevol` DROP COLUMN `ActualDailyPnL`;
|
||||
ALTER TABLE `eod_trade_position_hedgevol` DROP COLUMN `ActualTotalPnL`;
|
||||
|
||||
ALTER TABLE `eod_trade_position_hedgevol_s` DROP COLUMN `ActualLastPv`;
|
||||
ALTER TABLE `eod_trade_position_hedgevol_s` DROP COLUMN `ActualPv`;
|
||||
ALTER TABLE `eod_trade_position_hedgevol_s` DROP COLUMN `ActualDailyPnL`;
|
||||
ALTER TABLE `eod_trade_position_hedgevol_s` DROP COLUMN `ActualTotalPnL`;
|
||||
|
||||
ALTER TABLE `eod_trade_position_openvol` DROP COLUMN `ActualLastPv`;
|
||||
ALTER TABLE `eod_trade_position_openvol` DROP COLUMN `ActualPv`;
|
||||
ALTER TABLE `eod_trade_position_openvol` DROP COLUMN `ActualDailyPnL`;
|
||||
ALTER TABLE `eod_trade_position_openvol` DROP COLUMN `ActualTotalPnL`;
|
||||
|
||||
ALTER TABLE `eod_trade_position_openvol_s` DROP COLUMN `ActualLastPv`;
|
||||
ALTER TABLE `eod_trade_position_openvol_s` DROP COLUMN `ActualPv`;
|
||||
ALTER TABLE `eod_trade_position_openvol_s` DROP COLUMN `ActualDailyPnL`;
|
||||
ALTER TABLE `eod_trade_position_openvol_s` DROP COLUMN `ActualTotalPnL`;
|
||||
|
||||
ALTER TABLE `eod_trade_position_extend` DROP COLUMN `ActualLastPv`;
|
||||
ALTER TABLE `eod_trade_position_extend` DROP COLUMN `ActualPv`;
|
||||
ALTER TABLE `eod_trade_position_extend` DROP COLUMN `ActualDailyPnL`;
|
||||
ALTER TABLE `eod_trade_position_extend` DROP COLUMN `ActualTotalPnL`;
|
||||
|
||||
ALTER TABLE `eod_trade_position`
|
||||
ADD COLUMN `ClosedPnL` DOUBLE NOT NULL DEFAULT 0 COMMENT '平仓盈亏' AFTER `Strike`;
|
||||
ALTER TABLE `eod_trade_position`
|
||||
ADD COLUMN `PriceType` tinyint(0) UNSIGNED NOT NULL DEFAULT 1 COMMENT '1:收盘价,2:结算价,3: 1|2';
|
||||
|
||||
ALTER TABLE `eod_trade_position_s`
|
||||
ADD COLUMN `ClosedPnL` DOUBLE NOT NULL DEFAULT 0 COMMENT '平仓盈亏' AFTER `Strike`;
|
||||
ALTER TABLE `eod_trade_position_s`
|
||||
ADD COLUMN `PriceType` tinyint(0) UNSIGNED NOT NULL DEFAULT 1 COMMENT '1:收盘价,2:结算价,3: 1|2';
|
||||
|
||||
ALTER TABLE `eod_trade_position_hedgevol`
|
||||
ADD COLUMN `ClosedPnL` DOUBLE NOT NULL DEFAULT 0 COMMENT '平仓盈亏' AFTER `Strike`;
|
||||
ALTER TABLE `eod_trade_position_hedgevol`
|
||||
ADD COLUMN `PriceType` tinyint(0) UNSIGNED NOT NULL DEFAULT 1 COMMENT '1:收盘价,2:结算价,3: 1|2';
|
||||
|
||||
ALTER TABLE `eod_trade_position_hedgevol_s`
|
||||
ADD COLUMN `ClosedPnL` DOUBLE NOT NULL DEFAULT 0 COMMENT '平仓盈亏' AFTER `Strike`;
|
||||
ALTER TABLE `eod_trade_position_hedgevol_s`
|
||||
ADD COLUMN `PriceType` tinyint(0) UNSIGNED NOT NULL DEFAULT 1 COMMENT '1:收盘价,2:结算价,3: 1|2';
|
||||
|
||||
ALTER TABLE `eod_trade_position_openvol`
|
||||
ADD COLUMN `ClosedPnL` DOUBLE NOT NULL DEFAULT 0 COMMENT '平仓盈亏' AFTER `Strike`;
|
||||
ALTER TABLE `eod_trade_position_openvol`
|
||||
ADD COLUMN `PriceType` tinyint(0) UNSIGNED NOT NULL DEFAULT 1 COMMENT '1:收盘价,2:结算价,3: 1|2';
|
||||
|
||||
ALTER TABLE `eod_trade_position_openvol_s`
|
||||
ADD COLUMN `ClosedPnL` DOUBLE NOT NULL DEFAULT 0 COMMENT '平仓盈亏' AFTER `Strike`;
|
||||
ALTER TABLE `eod_trade_position_openvol_s`
|
||||
ADD COLUMN `PriceType` tinyint(0) UNSIGNED NOT NULL DEFAULT 1 COMMENT '1:收盘价,2:结算价,3: 1|2';
|
||||
|
||||
ALTER TABLE `eod_trade_position_extend`
|
||||
ADD COLUMN `ClosedPnL` DOUBLE NOT NULL DEFAULT 0 COMMENT '平仓盈亏' AFTER `Strike`;
|
||||
ALTER TABLE `eod_trade_position_extend`
|
||||
ADD COLUMN `PriceType` tinyint(0) UNSIGNED NOT NULL DEFAULT 1 COMMENT '1:收盘价,2:结算价,3: 1|2';
|
||||
|
||||
----------------------------------------------------------------------------------------------------
|
||||
|
||||
update `eod_trade_risk` set TradeId=0 where TradeId is null;
|
||||
update `eod_trade_risk` set BookId=0 where BookId is null;
|
||||
update `eod_trade_risk` set ClientId=0 where ClientId is null;
|
||||
|
||||
ALTER TABLE `eod_trade_risk`
|
||||
MODIFY COLUMN `TradeId` int(0) NOT NULL DEFAULT 0 COMMENT '交易信息' AFTER `ValueDate`,
|
||||
MODIFY COLUMN `BookId` int(0) NOT NULL DEFAULT 0 COMMENT '簿记账户' AFTER `TradeId`,
|
||||
MODIFY COLUMN `ClientId` int(0) NOT NULL DEFAULT 0 COMMENT '客户信息' AFTER `BookId`,
|
||||
MODIFY COLUMN `OtherRisks` varchar(1000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '其他风险指标(JSON格式)' AFTER `HedgeUniqueCode`;
|
||||
ALTER TABLE `eod_trade_risk`
|
||||
ADD COLUMN `PriceType` tinyint(0) UNSIGNED NOT NULL DEFAULT 1 COMMENT '1:收盘价,2:结算价,3: 1|2' AFTER `OtherRisks`;
|
||||
|
||||
update `eod_trade_risk_s` set TradeId=0 where TradeId is null;
|
||||
update `eod_trade_risk_s` set BookId=0 where BookId is null;
|
||||
update `eod_trade_risk_s` set ClientId=0 where ClientId is null;
|
||||
|
||||
ALTER TABLE `eod_trade_risk_s`
|
||||
MODIFY COLUMN `TradeId` int(0) NOT NULL DEFAULT 0 COMMENT '交易信息' AFTER `ValueDate`,
|
||||
MODIFY COLUMN `BookId` int(0) NOT NULL DEFAULT 0 COMMENT '簿记账户' AFTER `TradeId`,
|
||||
MODIFY COLUMN `ClientId` int(0) NOT NULL DEFAULT 0 COMMENT '客户信息' AFTER `BookId`,
|
||||
MODIFY COLUMN `OtherRisks` varchar(1000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '其他风险指标(JSON格式)' AFTER `HedgeUniqueCode`;
|
||||
ALTER TABLE `eod_trade_risk_s`
|
||||
ADD COLUMN `PriceType` tinyint(0) UNSIGNED NOT NULL DEFAULT 1 COMMENT '1:收盘价,2:结算价,3: 1|2' AFTER `OtherRisks`;
|
||||
|
||||
update `eod_trade_risk_hedgevol` set TradeId=0 where TradeId is null;
|
||||
update `eod_trade_risk_hedgevol` set BookId=0 where BookId is null;
|
||||
update `eod_trade_risk_hedgevol` set ClientId=0 where ClientId is null;
|
||||
|
||||
ALTER TABLE `eod_trade_risk_hedgevol`
|
||||
MODIFY COLUMN `TradeId` int(0) NOT NULL DEFAULT 0 COMMENT '交易信息' AFTER `ValueDate`,
|
||||
MODIFY COLUMN `BookId` int(0) NOT NULL DEFAULT 0 COMMENT '簿记账户' AFTER `TradeId`,
|
||||
MODIFY COLUMN `ClientId` int(0) NOT NULL DEFAULT 0 COMMENT '客户信息' AFTER `BookId`,
|
||||
MODIFY COLUMN `OtherRisks` varchar(1000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '其他风险指标(JSON格式)' AFTER `HedgeUniqueCode`;
|
||||
ALTER TABLE `eod_trade_risk_hedgevol`
|
||||
ADD COLUMN `PriceType` tinyint(0) UNSIGNED NOT NULL DEFAULT 1 COMMENT '1:收盘价,2:结算价,3: 1|2' AFTER `OtherRisks`;
|
||||
|
||||
update `eod_trade_risk_hedgevol_s` set TradeId=0 where TradeId is null;
|
||||
update `eod_trade_risk_hedgevol_s` set BookId=0 where BookId is null;
|
||||
update `eod_trade_risk_hedgevol_s` set ClientId=0 where ClientId is null;
|
||||
|
||||
ALTER TABLE `eod_trade_risk_hedgevol_s`
|
||||
MODIFY COLUMN `TradeId` int(0) NOT NULL DEFAULT 0 COMMENT '交易信息' AFTER `ValueDate`,
|
||||
MODIFY COLUMN `BookId` int(0) NOT NULL DEFAULT 0 COMMENT '簿记账户' AFTER `TradeId`,
|
||||
MODIFY COLUMN `ClientId` int(0) NOT NULL DEFAULT 0 COMMENT '客户信息' AFTER `BookId`,
|
||||
MODIFY COLUMN `OtherRisks` varchar(1000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '其他风险指标(JSON格式)' AFTER `HedgeUniqueCode`;
|
||||
ALTER TABLE `eod_trade_risk_hedgevol_s`
|
||||
ADD COLUMN `PriceType` tinyint(0) UNSIGNED NOT NULL DEFAULT 1 COMMENT '1:收盘价,2:结算价,3: 1|2' AFTER `OtherRisks`;
|
||||
|
||||
update `eod_trade_risk_openvol` set TradeId=0 where TradeId is null;
|
||||
update `eod_trade_risk_openvol` set BookId=0 where BookId is null;
|
||||
update `eod_trade_risk_openvol` set ClientId=0 where ClientId is null;
|
||||
|
||||
ALTER TABLE `eod_trade_risk_openvol`
|
||||
MODIFY COLUMN `TradeId` int(0) NOT NULL DEFAULT 0 COMMENT '交易信息' AFTER `ValueDate`,
|
||||
MODIFY COLUMN `BookId` int(0) NOT NULL DEFAULT 0 COMMENT '簿记账户' AFTER `TradeId`,
|
||||
MODIFY COLUMN `ClientId` int(0) NOT NULL DEFAULT 0 COMMENT '客户信息' AFTER `BookId`,
|
||||
MODIFY COLUMN `OtherRisks` varchar(1000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '其他风险指标(JSON格式)' AFTER `HedgeUniqueCode`;
|
||||
ALTER TABLE `eod_trade_risk_openvol`
|
||||
ADD COLUMN `PriceType` tinyint(0) UNSIGNED NOT NULL DEFAULT 1 COMMENT '1:收盘价,2:结算价,3: 1|2' AFTER `OtherRisks`;
|
||||
|
||||
update `eod_trade_risk_openvol_s` set TradeId=0 where TradeId is null;
|
||||
update `eod_trade_risk_openvol_s` set BookId=0 where BookId is null;
|
||||
update `eod_trade_risk_openvol_s` set ClientId=0 where ClientId is null;
|
||||
|
||||
ALTER TABLE `eod_trade_risk_openvol_s`
|
||||
MODIFY COLUMN `TradeId` int(0) NOT NULL DEFAULT 0 COMMENT '交易信息' AFTER `ValueDate`,
|
||||
MODIFY COLUMN `BookId` int(0) NOT NULL DEFAULT 0 COMMENT '簿记账户' AFTER `TradeId`,
|
||||
MODIFY COLUMN `ClientId` int(0) NOT NULL DEFAULT 0 COMMENT '客户信息' AFTER `BookId`,
|
||||
MODIFY COLUMN `OtherRisks` varchar(1000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '其他风险指标(JSON格式)' AFTER `HedgeUniqueCode`;
|
||||
ALTER TABLE `eod_trade_risk_openvol_s`
|
||||
ADD COLUMN `PriceType` tinyint(0) UNSIGNED NOT NULL DEFAULT 1 COMMENT '1:收盘价,2:结算价,3: 1|2' AFTER `OtherRisks`;
|
||||
|
||||
update `eod_trade_risk_extend` set TradeId=0 where TradeId is null;
|
||||
update `eod_trade_risk_extend` set BookId=0 where BookId is null;
|
||||
update `eod_trade_risk_extend` set ClientId=0 where ClientId is null;
|
||||
|
||||
ALTER TABLE `eod_trade_risk_extend`
|
||||
MODIFY COLUMN `TradeId` int(0) NOT NULL DEFAULT 0 COMMENT '交易信息' AFTER `ValueDate`,
|
||||
MODIFY COLUMN `BookId` int(0) NOT NULL DEFAULT 0 COMMENT '簿记账户' AFTER `TradeId`,
|
||||
MODIFY COLUMN `ClientId` int(0) NOT NULL DEFAULT 0 COMMENT '客户信息' AFTER `BookId`,
|
||||
MODIFY COLUMN `OtherRisks` varchar(1000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '其他风险指标(JSON格式)' AFTER `HedgeUniqueCode`;
|
||||
ALTER TABLE `eod_trade_risk_extend`
|
||||
ADD COLUMN `PriceType` tinyint(0) UNSIGNED NOT NULL DEFAULT 1 COMMENT '1:收盘价,2:结算价,3: 1|2' AFTER `OtherRisks`;
|
||||
|
||||
----------------------------------------------------------------------------------------------------
|
||||
|
||||
ALTER TABLE `eod_pnl`
|
||||
ADD COLUMN `PriceType` tinyint(0) UNSIGNED NOT NULL DEFAULT 1 COMMENT '1:收盘价,2:结算价,3: 1|2';
|
||||
|
||||
ALTER TABLE `eod_pnl_hedgevol`
|
||||
ADD COLUMN `PriceType` tinyint(0) UNSIGNED NOT NULL DEFAULT 1 COMMENT '1:收盘价,2:结算价,3: 1|2';
|
||||
|
||||
ALTER TABLE `eod_pnl_openvol`
|
||||
ADD COLUMN `PriceType` tinyint(0) UNSIGNED NOT NULL DEFAULT 1 COMMENT '1:收盘价,2:结算价,3: 1|2';
|
||||
|
||||
ALTER TABLE `eod_pnl_extend`
|
||||
ADD COLUMN `PriceType` tinyint(0) UNSIGNED NOT NULL DEFAULT 1 COMMENT '1:收盘价,2:结算价,3: 1|2';
|
||||
|
||||
ALTER TABLE `eod_pnl_s`
|
||||
ADD COLUMN `PriceType` tinyint(0) UNSIGNED NOT NULL DEFAULT 1 COMMENT '1:收盘价,2:结算价,3: 1|2';
|
||||
|
||||
ALTER TABLE `eod_pnl_hedgevol_s`
|
||||
ADD COLUMN `PriceType` tinyint(0) UNSIGNED NOT NULL DEFAULT 1 COMMENT '1:收盘价,2:结算价,3: 1|2';
|
||||
|
||||
ALTER TABLE `eod_pnl_openvol_s`
|
||||
ADD COLUMN `PriceType` tinyint(0) UNSIGNED NOT NULL DEFAULT 1 COMMENT '1:收盘价,2:结算价,3: 1|2';
|
||||
|
||||
----------------------------------------------------------------------------------------------------
|
||||
|
||||
ALTER TABLE `eod_trade_position`
|
||||
CHANGE COLUMN `ClosePnL` `ClosedPnL` double NOT NULL DEFAULT 0 COMMENT '平仓盈亏' AFTER `ParentTradeId`;
|
||||
@@ -1,45 +0,0 @@
|
||||
select * from eod_status where ValueDate='2020-11-02';
|
||||
|
||||
select * from eod_trade where ValueDate='2020-11-02';
|
||||
|
||||
select * from eod_pnl_statics where ValueDate='2020-11-02';
|
||||
|
||||
select * from eod_forward_margin where ValueDate='2020-11-02';
|
||||
|
||||
select * from trade_span where ValueDate='2020-11-02';
|
||||
|
||||
select * from clientbalancedaily where BalanceDate='2020-11-02';
|
||||
|
||||
--------------------------------------------------------
|
||||
|
||||
select * from eod_pnl where ValueDate='2020-11-02';
|
||||
|
||||
select * from eod_trade_risk where ValueDate='2020-11-02';
|
||||
|
||||
select * from eod_trade_position where ValueDate='2020-11-02';
|
||||
|
||||
--------------------------------------------------------
|
||||
|
||||
select * from eod_pnl_hedgevol where ValueDate='2020-11-02';
|
||||
|
||||
select * from eod_trade_risk_hedgevol where ValueDate='2020-11-02';
|
||||
|
||||
select * from eod_trade_position_hedgevol where ValueDate='2020-11-02';
|
||||
|
||||
--------------------------------------------------------
|
||||
|
||||
select * from eod_pnl_openvol where ValueDate='2020-11-02';
|
||||
|
||||
select * from eod_trade_risk_openvol where ValueDate='2020-11-02';
|
||||
|
||||
select * from eod_trade_position_openvol where ValueDate='2020-11-02';
|
||||
|
||||
--------------------------------------------------------
|
||||
|
||||
select * from eod_pnl_s where ValueDate='2020-11-02';
|
||||
|
||||
select * from eod_trade_risk_s where ValueDate='2020-11-02';
|
||||
|
||||
select * from eod_trade_position_s where ValueDate='2020-11-02';
|
||||
|
||||
--------------------------------------------------------
|
||||
@@ -1,32 +0,0 @@
|
||||
TRUNCATE TABLE eod_status;
|
||||
TRUNCATE TABLE eod_task;
|
||||
TRUNCATE TABLE eod_trade;
|
||||
TRUNCATE TABLE eod_forward_margin;
|
||||
TRUNCATE TABLE eod_pnl_statics;
|
||||
TRUNCATE TABLE trade_span;
|
||||
TRUNCATE TABLE client_span;
|
||||
TRUNCATE TABLE clientbalancedaily;
|
||||
----------------------------------------------------
|
||||
TRUNCATE TABLE eod_pnl;
|
||||
TRUNCATE TABLE eod_pnl_hedgevol;
|
||||
TRUNCATE TABLE eod_pnl_openvol;
|
||||
TRUNCATE TABLE eod_pnl_extend;
|
||||
TRUNCATE TABLE eod_pnl_s;
|
||||
TRUNCATE TABLE eod_pnl_hedgevol_s;
|
||||
TRUNCATE TABLE eod_pnl_openvol_s;
|
||||
----------------------------------------------------
|
||||
TRUNCATE TABLE eod_trade_position;
|
||||
TRUNCATE TABLE eod_trade_position_hedgevol;
|
||||
TRUNCATE TABLE eod_trade_position_openvol;
|
||||
TRUNCATE TABLE eod_trade_position_extend;
|
||||
TRUNCATE TABLE eod_trade_position_s;
|
||||
TRUNCATE TABLE eod_trade_position_hedgevol_s;
|
||||
TRUNCATE TABLE eod_trade_position_openvol_s;
|
||||
----------------------------------------------------
|
||||
TRUNCATE TABLE eod_trade_risk;
|
||||
TRUNCATE TABLE eod_trade_risk_hedgevol;
|
||||
TRUNCATE TABLE eod_trade_risk_openvol;
|
||||
TRUNCATE TABLE eod_trade_risk_extend;
|
||||
TRUNCATE TABLE eod_trade_risk_s;
|
||||
TRUNCATE TABLE eod_trade_risk_hedgevol_s;
|
||||
TRUNCATE TABLE eod_trade_risk_openvol_s;
|
||||
@@ -1,406 +0,0 @@
|
||||
select * from eod_status order by id desc limit 10;
|
||||
|
||||
----------------------------------------------------------------------------------------------------
|
||||
|
||||
select ClientId,BalanceDate,'c2 more' as remark from uat_ylcms2.clientbalancedaily c2
|
||||
where BalanceDate between '2020-11-02' and '2020-11-23' AND not EXISTS(select * from uat_ylcms.clientbalancedaily where BalanceDate=c2.BalanceDate and ClientID=c2.ClientId)
|
||||
UNION ALL
|
||||
select ClientId,BalanceDate,'c1 more' as remark from uat_ylcms.clientbalancedaily c1
|
||||
where BalanceDate between '2020-11-02' and '2020-11-23' AND not EXISTS(select * from uat_ylcms2.clientbalancedaily where BalanceDate=c1.BalanceDate and ClientID=c1.ClientId)
|
||||
;
|
||||
----------------------------------------------------------------------------------------------------
|
||||
|
||||
select t1.ClientId, t1.BalanceDate,t1.md5_expect,t2.md5_compare,STRCMP(t1.md5_expect,t2.md5_compare) cmp
|
||||
from (
|
||||
SELECT ClientId,BalanceDate,
|
||||
MD5(CONCAT(
|
||||
IFNULL( ToDayRemainFund, '' ),
|
||||
IFNULL( LastDayRemainFund, '' ),
|
||||
IFNULL( InFund, '' ),
|
||||
IFNULL( OutFund, '' ),
|
||||
IFNULL( DayGainLoss, '' ),
|
||||
IFNULL( State, '' ),
|
||||
IFNULL( CashDeposit, '' ),
|
||||
IFNULL( OptionPremium, '' ),
|
||||
IFNULL( SettlementBalance, '' ),
|
||||
IFNULL( Margin, '' ),
|
||||
IFNULL( NetFund, '' ),
|
||||
IFNULL( MarginBalance, '' ),
|
||||
IFNULL( FrozenPremium, '' ),
|
||||
IFNULL( FrozenBalance, '' ),
|
||||
IFNULL( CopeWithExpirePremium, '' ),
|
||||
IFNULL( CopeWithLastPremium, '' ),
|
||||
IFNULL( Pv, '' ),
|
||||
IFNULL( TotalNominal, '' ),
|
||||
IFNULL( PayableMargin, '' ),
|
||||
IFNULL( AdvisableMargin, '' ),
|
||||
IFNULL( Credit, '' ),
|
||||
IFNULL( TodayRemianFundProduct, '' ),
|
||||
IFNULL( CashInCashOutProductChange, '' ),
|
||||
IFNULL( PotentialSurpluses, '' ),
|
||||
IFNULL( FrozenOutFund, '' ),
|
||||
IFNULL( FrozenRedeemFunds, '' ),
|
||||
IFNULL( FrozenMarginMoney, '' ),
|
||||
IFNULL( TotalPnl, '' ),
|
||||
IFNULL( PositionPnL, '' ),
|
||||
IFNULL( IsTradeCredit, '' ),
|
||||
IFNULL( RoundedPv, '' ),
|
||||
IFNULL( RoundedPositionPnl, '' ),
|
||||
IFNULL( PositionPremiumNetCash, '' ),
|
||||
IFNULL( LastDayPositionPremiumNetCash, '' ),
|
||||
IFNULL( WinLoss, '' ),
|
||||
IFNULL( AdditionalMargin, '' ),
|
||||
IFNULL( InFundOther, '' ),
|
||||
IFNULL( OutFundOther, '' ),
|
||||
IFNULL( OtherFund, '' ),
|
||||
IFNULL( DailyPnl, '' ),
|
||||
IFNULL( NetFundSum, '' ),
|
||||
IFNULL( OtherFundSum, '' ),
|
||||
IFNULL( OptionPremiumSum, '' ),
|
||||
IFNULL( SettlementBalanceSum, '' ),
|
||||
IFNULL( CashInCashOutProductChangeSum, '' ),
|
||||
IFNULL( WinLossSum, '' ),
|
||||
IFNULL( ClientSellPositionPnl, '' ),
|
||||
IFNULL( SellPv, '' ),
|
||||
IFNULL( UnwindBalanceSum, '' ),
|
||||
IFNULL( ExerciseBalanceSum, '' ),
|
||||
IFNULL( UnwindBalance, '' ),
|
||||
IFNULL( ExerciseBalance, '' ),
|
||||
IFNULL( SellTradePrice, '' ),
|
||||
IFNULL( InFundSum, '' ),
|
||||
IFNULL( OutFundSum, '' ),
|
||||
IFNULL( IsPayableMarginManual, '' ),
|
||||
IFNULL( TwoSideMargin, '' ),
|
||||
IFNULL( OtherSideMargin, '' ),
|
||||
IFNULL( Coupon, '' ),
|
||||
IFNULL( CouponSum, '' ),
|
||||
IFNULL( SwapBalance, '' ),
|
||||
IFNULL( SwapBalanceSum, '' ),
|
||||
IFNULL( MySideMargin, '' )
|
||||
)) AS md5_expect
|
||||
FROM uat_ylcms.clientbalancedaily WHERE BalanceDate >= '2020-11-02' ) t1
|
||||
join ( SELECT ClientId,BalanceDate,
|
||||
MD5(CONCAT(
|
||||
IFNULL( ToDayRemainFund, '' ),
|
||||
IFNULL( LastDayRemainFund, '' ),
|
||||
IFNULL( InFund, '' ),
|
||||
IFNULL( OutFund, '' ),
|
||||
IFNULL( DayGainLoss, '' ),
|
||||
IFNULL( State, '' ),
|
||||
IFNULL( CashDeposit, '' ),
|
||||
IFNULL( OptionPremium, '' ),
|
||||
IFNULL( SettlementBalance, '' ),
|
||||
IFNULL( Margin, '' ),
|
||||
IFNULL( NetFund, '' ),
|
||||
IFNULL( MarginBalance, '' ),
|
||||
IFNULL( FrozenPremium, '' ),
|
||||
IFNULL( FrozenBalance, '' ),
|
||||
IFNULL( CopeWithExpirePremium, '' ),
|
||||
IFNULL( CopeWithLastPremium, '' ),
|
||||
IFNULL( Pv, '' ),
|
||||
IFNULL( TotalNominal, '' ),
|
||||
IFNULL( PayableMargin, '' ),
|
||||
IFNULL( AdvisableMargin, '' ),
|
||||
IFNULL( Credit, '' ),
|
||||
IFNULL( TodayRemianFundProduct, '' ),
|
||||
IFNULL( CashInCashOutProductChange, '' ),
|
||||
IFNULL( PotentialSurpluses, '' ),
|
||||
IFNULL( FrozenOutFund, '' ),
|
||||
IFNULL( FrozenRedeemFunds, '' ),
|
||||
IFNULL( FrozenMarginMoney, '' ),
|
||||
IFNULL( TotalPnl, '' ),
|
||||
IFNULL( PositionPnL, '' ),
|
||||
IFNULL( IsTradeCredit, '' ),
|
||||
IFNULL( RoundedPv, '' ),
|
||||
IFNULL( RoundedPositionPnl, '' ),
|
||||
IFNULL( PositionPremiumNetCash, '' ),
|
||||
IFNULL( LastDayPositionPremiumNetCash, '' ),
|
||||
IFNULL( WinLoss, '' ),
|
||||
IFNULL( AdditionalMargin, '' ),
|
||||
IFNULL( InFundOther, '' ),
|
||||
IFNULL( OutFundOther, '' ),
|
||||
IFNULL( OtherFund, '' ),
|
||||
IFNULL( DailyPnl, '' ),
|
||||
IFNULL( NetFundSum, '' ),
|
||||
IFNULL( OtherFundSum, '' ),
|
||||
IFNULL( OptionPremiumSum, '' ),
|
||||
IFNULL( SettlementBalanceSum, '' ),
|
||||
IFNULL( CashInCashOutProductChangeSum, '' ),
|
||||
IFNULL( WinLossSum, '' ),
|
||||
IFNULL( ClientSellPositionPnl, '' ),
|
||||
IFNULL( SellPv, '' ),
|
||||
IFNULL( UnwindBalanceSum, '' ),
|
||||
IFNULL( ExerciseBalanceSum, '' ),
|
||||
IFNULL( UnwindBalance, '' ),
|
||||
IFNULL( ExerciseBalance, '' ),
|
||||
IFNULL( SellTradePrice, '' ),
|
||||
IFNULL( InFundSum, '' ),
|
||||
IFNULL( OutFundSum, '' ),
|
||||
IFNULL( IsPayableMarginManual, '' ),
|
||||
IFNULL( TwoSideMargin, '' ),
|
||||
IFNULL( OtherSideMargin, '' ),
|
||||
IFNULL( Coupon, '' ),
|
||||
IFNULL( CouponSum, '' ),
|
||||
IFNULL( SwapBalance, '' ),
|
||||
IFNULL( SwapBalanceSum, '' ),
|
||||
IFNULL( MySideMargin, '' )
|
||||
) ) AS md5_compare
|
||||
FROM uat_ylcms2.clientbalancedaily WHERE BalanceDate >= '2020-11-02' )t2
|
||||
on t1.ClientId=t2.ClientId and t1.BalanceDate=t2.BalanceDate
|
||||
where STRCMP(t1.md5_expect,t2.md5_compare)<>0
|
||||
---------------------------------------------------------------------------------------
|
||||
select t1.ClientId, t1.ValueDate,t1.md5_expect,t2.md5_compare,STRCMP(t1.md5_expect,t2.md5_compare) cmp
|
||||
from (
|
||||
SELECT ClientId,ValueDate,
|
||||
MD5(CONCAT(
|
||||
IFNULL(Spv1,''),
|
||||
IFNULL(Spv2,''),
|
||||
IFNULL(Spv3,''),
|
||||
IFNULL(Spv4,''),
|
||||
IFNULL(WorstCastClientPayable,''),
|
||||
IFNULL(VariationMargin,''),
|
||||
IFNULL(SpanType,''),
|
||||
IFNULL(AdditionalWorstCastClientPayable,''),
|
||||
IFNULL(RiskExposure,''),
|
||||
IFNULL(ModifiedFlag,''),
|
||||
IFNULL(TwoSideMargin,''),
|
||||
IFNULL(OtherSideMargin,''),
|
||||
IFNULL(Spv5,''),
|
||||
IFNULL(Spv6,''),
|
||||
IFNULL(Spv7,''),
|
||||
IFNULL(Spv8,''),
|
||||
IFNULL(MySideMargin,'')
|
||||
)) AS md5_expect
|
||||
FROM uat_ylcms.client_span WHERE ValueDate >= '2020-11-02' ) t1
|
||||
join ( SELECT ClientId,ValueDate,
|
||||
MD5(CONCAT(
|
||||
IFNULL(Spv1,''),
|
||||
IFNULL(Spv2,''),
|
||||
IFNULL(Spv3,''),
|
||||
IFNULL(Spv4,''),
|
||||
IFNULL(WorstCastClientPayable,''),
|
||||
IFNULL(VariationMargin,''),
|
||||
IFNULL(SpanType,''),
|
||||
IFNULL(AdditionalWorstCastClientPayable,''),
|
||||
IFNULL(RiskExposure,''),
|
||||
IFNULL(ModifiedFlag,''),
|
||||
IFNULL(TwoSideMargin,''),
|
||||
IFNULL(OtherSideMargin,''),
|
||||
IFNULL(Spv5,''),
|
||||
IFNULL(Spv6,''),
|
||||
IFNULL(Spv7,''),
|
||||
IFNULL(Spv8,''),
|
||||
IFNULL(MySideMargin,'')
|
||||
) ) AS md5_compare
|
||||
FROM uat_ylcms2.client_span WHERE ValueDate >= '2020-11-02' ) t2
|
||||
on t1.ClientId=t2.ClientId and t1.ValueDate=t2.ValueDate
|
||||
where STRCMP(t1.md5_expect,t2.md5_compare)<>0
|
||||
|
||||
---------------------------------------------------------------------------------------
|
||||
|
||||
select * from uat_ylcms.client_span where ValueDate='2020-11-23' and ClientID in (7)
|
||||
union all
|
||||
select * from uat_ylcms2.client_span where ValueDate='2020-11-23' and ClientID in (7)
|
||||
|
||||
---------------------------------------------------------------------------------------
|
||||
select t1.TradeId, t1.ValueDate,t1.md5_expect,t2.md5_compare,STRCMP(t1.md5_expect,t2.md5_compare) cmp
|
||||
from (
|
||||
SELECT TradeId,ValueDate,
|
||||
MD5(CONCAT(
|
||||
IFNULL(Spv1,''),
|
||||
IFNULL(Spv2,''),
|
||||
IFNULL(Spv3,''),
|
||||
IFNULL(Spv4,''),
|
||||
IFNULL(WorstCastClientPayable,''),
|
||||
IFNULL(ClientId,''),
|
||||
IFNULL(RiskExposure,''),
|
||||
IFNULL(Margin,''),
|
||||
IFNULL(CashDeposit,''),
|
||||
IFNULL(TwoSideMargin,''),
|
||||
IFNULL(Spv5,''),
|
||||
IFNULL(Spv6,''),
|
||||
IFNULL(Spv7,''),
|
||||
IFNULL(Spv8,''),
|
||||
IFNULL(Delta,''),
|
||||
IFNULL(DeltaMargin,''),
|
||||
IFNULL(UnderlyingPrice,''),
|
||||
IFNULL(VarietyId,''),
|
||||
IFNULL(Spv,''),
|
||||
IFNULL(PositionWin,''),
|
||||
IFNULL(IsSingleMargin,'')
|
||||
)) AS md5_expect
|
||||
FROM uat_ylcms.trade_span WHERE ValueDate >= '2020-11-02' ) t1
|
||||
join ( SELECT TradeId,ValueDate,
|
||||
MD5(CONCAT(
|
||||
IFNULL(Spv1,''),
|
||||
IFNULL(Spv2,''),
|
||||
IFNULL(Spv3,''),
|
||||
IFNULL(Spv4,''),
|
||||
IFNULL(WorstCastClientPayable,''),
|
||||
IFNULL(ClientId,''),
|
||||
IFNULL(RiskExposure,''),
|
||||
IFNULL(Margin,''),
|
||||
IFNULL(CashDeposit,''),
|
||||
IFNULL(TwoSideMargin,''),
|
||||
IFNULL(Spv5,''),
|
||||
IFNULL(Spv6,''),
|
||||
IFNULL(Spv7,''),
|
||||
IFNULL(Spv8,''),
|
||||
IFNULL(Delta,''),
|
||||
IFNULL(DeltaMargin,''),
|
||||
IFNULL(UnderlyingPrice,''),
|
||||
IFNULL(VarietyId,''),
|
||||
IFNULL(Spv,''),
|
||||
IFNULL(PositionWin,''),
|
||||
IFNULL(IsSingleMargin,'')
|
||||
) ) AS md5_compare
|
||||
FROM uat_ylcms2.trade_span WHERE ValueDate >= '2020-11-02' ) t2
|
||||
on t1.TradeId=t2.TradeId and t1.ValueDate=t2.ValueDate
|
||||
where STRCMP(t1.md5_expect,t2.md5_compare)<>0
|
||||
---------------------------------------------------------------------------------------
|
||||
|
||||
select t1.ValueDate, t1.ccnt,t2.ccnt
|
||||
from (
|
||||
SELECT ValueDate,Count(1) as ccnt
|
||||
FROM uat_ylcms.eod_trade_risk er
|
||||
WHERE ValueDate between '2020-11-02' and '2020-11-23' and (er.TradeId=0 || not EXISTS(SELECT * from trade where id=er.TradeId and TradeType='结构化交易'))
|
||||
GROUP BY ValueDate
|
||||
) t1
|
||||
join ( SELECT ValueDate,Count(1) as ccnt
|
||||
FROM uat_ylcms2.eod_trade_risk WHERE ValueDate between '2020-11-02' and '2020-11-23' ) t2
|
||||
on t1.ValueDate=t2.ValueDate
|
||||
where t1.ccnt<>t2.ccnt;
|
||||
|
||||
---------------------------------------------------------------------------------------
|
||||
|
||||
select t1.TradeId, t1.ValueDate,t1.md5_expect,t2.md5_compare,STRCMP(t1.md5_expect,t2.md5_compare) cmp
|
||||
from (
|
||||
SELECT TradeId,ValueDate,
|
||||
MD5(CONCAT(
|
||||
IFNULL(BookId,''),
|
||||
IFNULL(ClientId,''),
|
||||
IFNULL(Pv,''),
|
||||
IFNULL(Delta,''),
|
||||
IFNULL(Gamma,''),
|
||||
IFNULL(Vega,''),
|
||||
IFNULL(Theta,''),
|
||||
IFNULL(Rho,''),
|
||||
IFNULL(DeltaCash,''),
|
||||
IFNULL(GammaCash,''),
|
||||
IFNULL(Exposure,''),
|
||||
IFNULL(Vol,''),
|
||||
IFNULL(HedgeUniqueCode,''),
|
||||
/*
|
||||
IFNULL(VarietyId,''),
|
||||
IFNULL(Spv,''),
|
||||
IFNULL(PositionWin,''),
|
||||
IFNULL(IsSingleMargin,'')
|
||||
*/
|
||||
IFNULL(OtherRisks,'')
|
||||
)) AS md5_expect
|
||||
FROM uat_ylcms.eod_trade_risk WHERE ValueDate between '2020-11-02' and '2020-11-23' ) t1
|
||||
join ( SELECT TradeId,ValueDate,
|
||||
MD5(CONCAT(
|
||||
IFNULL(BookId,''),
|
||||
IFNULL(ClientId,''),
|
||||
IFNULL(Pv,''),
|
||||
IFNULL(Delta,''),
|
||||
IFNULL(Gamma,''),
|
||||
IFNULL(Vega,''),
|
||||
IFNULL(Theta,''),
|
||||
IFNULL(Rho,''),
|
||||
IFNULL(DeltaCash,''),
|
||||
IFNULL(GammaCash,''),
|
||||
IFNULL(Exposure,''),
|
||||
IFNULL(Vol,''),
|
||||
IFNULL(HedgeUniqueCode,''),
|
||||
/*
|
||||
IFNULL(VarietyId,''),
|
||||
IFNULL(Spv,''),
|
||||
IFNULL(PositionWin,''),
|
||||
IFNULL(IsSingleMargin,'')
|
||||
*/
|
||||
IFNULL(OtherRisks,'')
|
||||
) ) AS md5_compare
|
||||
FROM uat_ylcms2.eod_trade_risk WHERE ValueDate between '2020-11-02' and '2020-11-23' ) t2
|
||||
on t1.TradeId=t2.TradeId and t1.ValueDate=t2.ValueDate
|
||||
where STRCMP(t1.md5_expect,t2.md5_compare)<>0
|
||||
---------------------------------------------------------------------------------------
|
||||
|
||||
select t1.ValueDate, t1.ccnt,t2.ccnt
|
||||
from (
|
||||
SELECT ValueDate,Count(1) as ccnt
|
||||
FROM uat_ylcms.eod_trade_position er
|
||||
WHERE ValueDate between '2020-11-02' and '2020-11-23' and (er.TradeId=0 || not EXISTS(SELECT * from trade where id=er.TradeId and TradeType='结构化交易'))
|
||||
GROUP BY ValueDate
|
||||
) t1
|
||||
join ( SELECT ValueDate,Count(1) as ccnt
|
||||
FROM uat_ylcms2.eod_trade_position WHERE ValueDate between '2020-11-02' and '2020-11-23' ) t2
|
||||
on t1.ValueDate=t2.ValueDate
|
||||
where t1.ccnt<>t2.ccnt;
|
||||
|
||||
---------------------------------------------------------------------------------------
|
||||
|
||||
SELECT t1.TradeId,t1.HedgeUniqueCode, t1.ValueDate,STRCMP(t1.md5_expect,t2.md5_compare) cmp
|
||||
FROM (
|
||||
SELECT TradeId,HedgeUniqueCode,ValueDate,
|
||||
MD5(CONCAT(
|
||||
IFNULL(TradeType,''),
|
||||
IFNULL(PositionType,''),
|
||||
IFNULL(BookId,''),
|
||||
IFNULL(ClientId,''),
|
||||
IFNULL(UnderlyingCode,''),
|
||||
ROUND(Amount*1e5),
|
||||
-- ROUND(Cost*1e5),
|
||||
ROUND(LastPv*1e5),
|
||||
ROUND(Pv*1e5),
|
||||
ROUND(DailyPnL*1e5),
|
||||
ROUND(TotalPnL*1e5),
|
||||
ROUND(Margin*1e5),
|
||||
IFNULL(UnderlyingId,''),
|
||||
IFNULL(HedgeUniqueCode,''),
|
||||
IFNULL(ExchangeOptionCode,''),
|
||||
ROUND(Commission*1e5),
|
||||
ROUND(PositionPnL*1e5),
|
||||
ROUND(RoundedPv*1e5),
|
||||
ROUND(RoundedPositionPnl*1e5),
|
||||
ROUND(AccruedTotalPnl*1e5),
|
||||
IFNULL(ParentTradeId,'')
|
||||
)) AS md5_expect
|
||||
FROM uat_ylcms.eod_trade_position WHERE ValueDate BETWEEN '2020-11-02' AND '2020-11-23' ) t1
|
||||
JOIN ( SELECT TradeId,HedgeUniqueCode,ValueDate,
|
||||
MD5(CONCAT(
|
||||
IFNULL(TradeType,''),
|
||||
IFNULL(PositionType,''),
|
||||
IFNULL(BookId,''),
|
||||
IFNULL(ClientId,''),
|
||||
IFNULL(UnderlyingCode,''),
|
||||
ROUND(Amount*1e5),
|
||||
-- ROUND(Cost*1e5),
|
||||
ROUND(LastPv*1e5),
|
||||
ROUND(Pv*1e5),
|
||||
ROUND(DailyPnL*1e5),
|
||||
ROUND(TotalPnL*1e5),
|
||||
ROUND(Margin*1e5),
|
||||
IFNULL(UnderlyingId,''),
|
||||
IFNULL(HedgeUniqueCode,''),
|
||||
IFNULL(ExchangeOptionCode,''),
|
||||
ROUND(Commission*1e5),
|
||||
ROUND(PositionPnL*1e5),
|
||||
ROUND(RoundedPv*1e5),
|
||||
ROUND(RoundedPositionPnl*1e5),
|
||||
ROUND(AccruedTotalPnl*1e5),
|
||||
IFNULL(ParentTradeId,'')
|
||||
|
||||
) ) AS md5_compare
|
||||
FROM uat_ylcms2.eod_trade_position WHERE ValueDate BETWEEN '2020-11-02' AND '2020-11-23' ) t2
|
||||
ON t1.ValueDate=t2.ValueDate AND ( (t1.TradeId<>0 AND t1.TradeId=t2.TradeId) OR (t1.TradeId=0 AND t1.HedgeUniqueCode=t2.HedgeUniqueCode))
|
||||
WHERE STRCMP(t1.md5_expect,t2.md5_compare)<>0
|
||||
|
||||
---------------------------------------------------------------------------------------
|
||||
|
||||
select id, TradeId, ValueDate, TradeType, PositionType, BookId, ClientId, UnderlyingCode, Amount, Cost, LastPv, Pv, DailyPnL, TotalPnL, Margin, UnderlyingId, HedgeUniqueCode, ExchangeOptionCode, Commission, PositionPnL, RoundedPv, RoundedPositionPnl, AccruedTotalPnl, ParentTradeId
|
||||
from uat_ylcms.eod_trade_position where ValueDate='2020-11-23' and tradeid in (12)
|
||||
union all
|
||||
select id, TradeId, ValueDate, TradeType, PositionType, BookId, ClientId, UnderlyingCode, Amount, Cost, LastPv, Pv, DailyPnL, TotalPnL, Margin, UnderlyingId, HedgeUniqueCode, ExchangeOptionCode, Commission, PositionPnL, RoundedPv, RoundedPositionPnl, AccruedTotalPnl, ParentTradeId
|
||||
from uat_ylcms2.eod_trade_position where ValueDate='2020-11-23' and tradeid in (12)
|
||||
@@ -1,292 +0,0 @@
|
||||
//trade类型
|
||||
{
|
||||
"UnderlyingInstrumentTypeCn": "股票",
|
||||
"ExerciseModeCn": "美式",
|
||||
"SummaryType": "美式二元看跌",
|
||||
"trade_forward":
|
||||
{
|
||||
"id": 0,
|
||||
"TradeId": 0,
|
||||
"OpenCommission": 0.0,
|
||||
"AnnualMarginRate": 0.0,
|
||||
"AnnualStoragePrice": 0.0,
|
||||
"ForwardValue": 0.0,
|
||||
"EncryptId": "D1k5faKQ2YC4qnUw579Wig"
|
||||
},
|
||||
"trade_asian_option":
|
||||
{
|
||||
"StrikeGearingFactor": 1.0,
|
||||
"StrikeTypeCn": "",
|
||||
"PayoffTypeCn": "",
|
||||
"id": 0,
|
||||
"TradeId": 0,
|
||||
"EncryptId": "D1k5faKQ2YC4qnUw579Wig"
|
||||
},
|
||||
"trade_rainbow_option":
|
||||
{
|
||||
"Vol2": 0.0,
|
||||
"UnderlyingCodes":
|
||||
[
|
||||
null,
|
||||
null
|
||||
],
|
||||
"Strikes":
|
||||
[
|
||||
0.0,
|
||||
0.0
|
||||
],
|
||||
"SpotPrices":
|
||||
[
|
||||
0.0,
|
||||
0.0
|
||||
],
|
||||
"id": 0,
|
||||
"TradeId": 0,
|
||||
"EncryptId": "D1k5faKQ2YC4qnUw579Wig"
|
||||
},
|
||||
"trade_barrier_option":
|
||||
{
|
||||
"KnockInOutStatusCn": "观察中",
|
||||
"IsDiscrete": false,
|
||||
"RebateAnnualizedAtKO": false,
|
||||
"RebateTypeCn": "",
|
||||
"id": 0,
|
||||
"TradeId": 0,
|
||||
"EncryptId": "D1k5faKQ2YC4qnUw579Wig"
|
||||
},
|
||||
"trade_binary_option":
|
||||
{
|
||||
"RebateTypeCn": "",
|
||||
"PayoffType": "",
|
||||
"RebateAnnualizedAtKO": false,
|
||||
"UpperBarrierRelative": "0",
|
||||
"IsDiscreteMonitored": false,
|
||||
"id": 0,
|
||||
"TradeId": 0,
|
||||
"EncryptId": "D1k5faKQ2YC4qnUw579Wig"
|
||||
},
|
||||
"trade_spread_option":
|
||||
{
|
||||
"Payoff": "S1-S2",
|
||||
"id": 0,
|
||||
"TradeId": 0,
|
||||
"EncryptId": "D1k5faKQ2YC4qnUw579Wig"
|
||||
},
|
||||
"trade_double_sharkfin_option":
|
||||
{
|
||||
"KnockInOutStatusCn": "观察中",
|
||||
"IsDiscrete": false,
|
||||
"BarrierHigh": 0.0,
|
||||
"BarrierLow": 0.0,
|
||||
"id": 0,
|
||||
"TradeId": 0,
|
||||
"EncryptId": "D1k5faKQ2YC4qnUw579Wig"
|
||||
},
|
||||
"trade_autocall":
|
||||
{
|
||||
"KnockInOutStatusCn": "观察中",
|
||||
"KOBarrier": 0.0,
|
||||
"KIBarrier": 0.0,
|
||||
"CouponBarrier": 0.0,
|
||||
"Coupon": 0.0,
|
||||
"IsFixedCoupon": false,
|
||||
"CouponPayType": 0,
|
||||
"CouponPayAtMaturity": false,
|
||||
"IncludeCouponAfterKI": false,
|
||||
"IsAnnualized2": false,
|
||||
"CouponDayCount": "Act365",
|
||||
"KIPayoffType": 0,
|
||||
"id": 0,
|
||||
"TradeId": 0,
|
||||
"EncryptId": "D1k5faKQ2YC4qnUw579Wig"
|
||||
},
|
||||
"trade_snowball":
|
||||
{
|
||||
"KnockInOutStatusCn": "观察中",
|
||||
"KOBarrier": 0.0,
|
||||
"KIBarrier": 0.0,
|
||||
"Coupon": 0.0,
|
||||
"KORebate": 0.0,
|
||||
"KORebateType": 0,
|
||||
"IsFixedCoupon": false,
|
||||
"KOPayoffType": 0,
|
||||
"KIPayoffType": 0,
|
||||
"IsAnnualized2": false,
|
||||
"CouponDayCount": "Act365",
|
||||
"KOBarrierAdjustStep": 0.0,
|
||||
"id": 0,
|
||||
"TradeId": 0,
|
||||
"EncryptId": "D1k5faKQ2YC4qnUw579Wig"
|
||||
},
|
||||
"trade_rangeaccrual":
|
||||
{
|
||||
"LowerRange": 0.0,
|
||||
"UpperRange": 0.0,
|
||||
"BonusRate": 0.0,
|
||||
"id": 0,
|
||||
"TradeId": 0,
|
||||
"EncryptId": "D1k5faKQ2YC4qnUw579Wig"
|
||||
},
|
||||
"trade_airbag":
|
||||
{
|
||||
"KnockInOutStatusCn": "观察中",
|
||||
"HighStrike": 0.0,
|
||||
"HasPayoffLimit": false,
|
||||
"Barrier": 0.0,
|
||||
"KIParticipationRate": 0.0,
|
||||
"IsDiscreteMonitored": false,
|
||||
"id": 0,
|
||||
"TradeId": 0,
|
||||
"EncryptId": "D1k5faKQ2YC4qnUw579Wig"
|
||||
},
|
||||
"trade_accumulator_option":
|
||||
{
|
||||
"EarlyTerminate": false,
|
||||
"PayCoupon": false,
|
||||
"Barrier": 0.0,
|
||||
"Coupon": 0.0,
|
||||
"id": 0,
|
||||
"TradeId": 0,
|
||||
"EncryptId": "D1k5faKQ2YC4qnUw579Wig"
|
||||
},
|
||||
"trade_swap":
|
||||
{
|
||||
"IsGetFloatingProfit": false,
|
||||
"GetSwapRate": 0.0,
|
||||
"GetMarginRate": 0.0,
|
||||
"IsPayFloatingProfit": false,
|
||||
"PaySwapRate": 0.0,
|
||||
"PayMarginRate": 0.0,
|
||||
"GetCountRatio": 0.0,
|
||||
"PayCountRatio": 0.0,
|
||||
"id": 0,
|
||||
"TradeId": 0,
|
||||
"EncryptId": "D1k5faKQ2YC4qnUw579Wig"
|
||||
},
|
||||
"get_trade_swap_details":
|
||||
[
|
||||
],
|
||||
"pay_trade_swap_details":
|
||||
[
|
||||
],
|
||||
"trade_underlying_enhance":
|
||||
{
|
||||
"AnnualizedEnhanceRate": 0.0,
|
||||
"id": 0,
|
||||
"TradeId": 0,
|
||||
"EncryptId": "D1k5faKQ2YC4qnUw579Wig"
|
||||
},
|
||||
"trade_cashflow":
|
||||
{
|
||||
"ProfitRate": 0.0,
|
||||
"RateType": 0,
|
||||
"DepositType": 0,
|
||||
"ProfitDayCount": "Act365",
|
||||
"id": 0,
|
||||
"TradeId": 0,
|
||||
"EncryptId": "D1k5faKQ2YC4qnUw579Wig"
|
||||
},
|
||||
"MaturityWorkDay": 180,
|
||||
"ShowNotional": -1.0,
|
||||
"MaturityDay": 270,
|
||||
"TradeOpenVolatilityString": "23.00%",
|
||||
"ExerciseDateString": "2021-12-06",
|
||||
"ActualStrike": 6275.43,
|
||||
"StrikeString": "6275.4300",
|
||||
"TradeSinglePriceString": "1.7380%",
|
||||
"TradeDateString": "2021-03-05",
|
||||
"StockEqvNotionalToShow": 11690000.0,
|
||||
"SettlementTypeDesc": "收盘价",
|
||||
"StrikeToShow": "98.0000%",
|
||||
"CurNotional": 0.0,
|
||||
"LastDayNotional": 0.0,
|
||||
"UnWindTimes": 0,
|
||||
"IsObservationDay": false,
|
||||
"DividendRatio": 0.0,
|
||||
"TradeType": "二元期权",
|
||||
"TradeSavedVol": 0.23,
|
||||
"CreateDate": "2021-03-05 15:10:03",
|
||||
"PairTrade": "",
|
||||
"TradeSinglePrice": 111.29283,
|
||||
"GroupName": "",
|
||||
"NumOfSmoothingDays": 10,
|
||||
"ParentTradeId": 0,
|
||||
"TradeCloseVolatility": 0.2,
|
||||
"TradeOpenVolatility": 0.23,
|
||||
"CheckTradeUpdate": 1,
|
||||
"InitialSpotPriceState": "期初价格已确认",
|
||||
"InitialSpotPrice": 6403.5,
|
||||
"IsMoneynessOption": "是",
|
||||
"TradeAmount": 1380.4265860600635,
|
||||
"TradeUnit": "",
|
||||
"StockEqvNotional": 11690000.0,
|
||||
"StockEqvNotionalMax": 11690000.0,
|
||||
"StockEqvNotionalReal": 8839561.6438356172,
|
||||
"VolType": "交易",
|
||||
"UnderlyingInstrumentType": "Stock",
|
||||
"ExerciseDate": "2021-12-06 00:00:00",
|
||||
"TraderName": "交易员",
|
||||
"TraderId": 1,
|
||||
"Strike": 0.98,
|
||||
"UnderlyingId": 682,
|
||||
"AssetBookName": "otc",
|
||||
"AssetId": 2,
|
||||
"Notional": 1.0,
|
||||
"OptionType": "看跌",
|
||||
"ExerciseMode": "American",
|
||||
"NoRiskRate": 0.025,
|
||||
"SpotPrice": 6403.5,
|
||||
"TradeNumber": "HYZBOTC2021254148-4",
|
||||
"ClientId": 20,
|
||||
"ClientName": "招商银行股份有限公司大连分行",
|
||||
"UnderlyingCode": "000905.SH",
|
||||
"UnderlyingAssetClass": "中证500指数",
|
||||
"TradeDate": "2021-03-05 00:00:00",
|
||||
"BuySell": "卖出",
|
||||
"StartDate": "2021-03-05 00:00:00",
|
||||
"MaturityDate": "2021-12-06 00:00:00",
|
||||
"TradePrice": 153631.58,
|
||||
"TradeStatus": "确认成交",
|
||||
"ProcessStatus": "通过审批",
|
||||
"ProcessOrderId": -2,
|
||||
"ProcessOptDate": "2021-03-08 19:06:40",
|
||||
"SettlementType": 0,
|
||||
"ValidState": "Valid",
|
||||
"Lots": 13.804265860600635,
|
||||
"OriginalNotional": 1380.4265860600635,
|
||||
"TradeSource": "系统交易",
|
||||
"OriginalStockEqvNotional": 11690000.0,
|
||||
"OriginalStockEqvNotionalV2": 11690000.0,
|
||||
"IsUsePremiumRate": true,
|
||||
"IsTradePricePayType": false,
|
||||
"IsAnnualized": true,
|
||||
"AnnualizeFactor": 0.75616438356164384,
|
||||
"DividendRate": 0.0,
|
||||
"ParticipationRate": 1.0,
|
||||
"PrincipalRate": 0.0,
|
||||
"SettlementDate": "2021-12-06 00:00:00",
|
||||
"CalcFlag": 0,
|
||||
"PremiumPayDate": "2021-03-05 00:00:00",
|
||||
"PremiumRate": 0.01738,
|
||||
"UnderlyingAssetName": "中证500",
|
||||
"DurationDays": 277,
|
||||
"InitialMargin": 0.0,
|
||||
"MarginTemplateName": "系统默认",
|
||||
"MarginType": 0,
|
||||
"MarginRate": 0.0,
|
||||
"PositionMarginRate": 0.0,
|
||||
"OptId": 4,
|
||||
"OptName": "管理员",
|
||||
"OptDate": "2021-03-08 19:06:40",
|
||||
"Warning": false,
|
||||
"DividendDate": "0001-01-01 00:00:00",
|
||||
"CallPut": "Put",
|
||||
"IsMoneynessOptionData": true,
|
||||
"MetaDic":
|
||||
{
|
||||
},
|
||||
"TradeMultipleType": "美式二元看跌",
|
||||
"HasUnderlying": true,
|
||||
"id": 343,
|
||||
"EncryptId": "uyn6mx0O0W33upi0NpN4zg"
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
{
|
||||
"TradeParam":
|
||||
{
|
||||
"tradeType": "二元期权",
|
||||
"optionType": 1,
|
||||
"payoffType": "DownOneTouch",
|
||||
"upperBarrier": "NaN",
|
||||
"cashOrNothingAmount": 204.912,
|
||||
"cashOrNothingAmountHigh": 0.0,
|
||||
"isDiscreteMonitored": true,
|
||||
"observationDateStr": "2021-04-01,2021-04-29,2021-06-03,2021-07-01,2021-08-03,2021-09-02,2021-09-29,2021-11-03,2021-12-02",
|
||||
"binaryRebateType": "AtHit",
|
||||
"binaryOptionReplicationStrategy": "None",
|
||||
"replicationShiftSize": 0.0098,
|
||||
"rebateAnnualizedAtKO": true,
|
||||
"underlyingTickers":
|
||||
[
|
||||
"000905.SH"
|
||||
],
|
||||
"strike": 0.98,
|
||||
"startDate":
|
||||
{
|
||||
"DateTime": "2021-03-05 00:00:00"
|
||||
},
|
||||
"tradeDate":
|
||||
{
|
||||
"DateTime": "2021-03-05 00:00:00"
|
||||
},
|
||||
"endDate":
|
||||
{
|
||||
"DateTime": "2021-12-06 00:00:00"
|
||||
},
|
||||
"exerciseDate":
|
||||
{
|
||||
"DateTime": "2021-12-06 00:00:00"
|
||||
},
|
||||
"settlementDate":
|
||||
{
|
||||
"DateTime": "2021-12-06 00:00:00"
|
||||
},
|
||||
"exerciseType": "American",
|
||||
"buysell": "Sell",
|
||||
"riskFreeRate": 0.025,
|
||||
"dividendRate": 0.0,
|
||||
"underlyingInstrumentType": "Stock",
|
||||
"notional": 1380.4265860600635,
|
||||
"isMoneynessOption": true,
|
||||
"initialSpotPrice": 6403.5,
|
||||
"hasNightMarket": false,
|
||||
"participationRate": 1.0,
|
||||
"principalRate": 0.0,
|
||||
"isAnnualized": true,
|
||||
"annualizedFactor": 0.75616438356164384,
|
||||
"commodityFuturesPreciseTimeMode": true,
|
||||
"tradeId": "1_343",
|
||||
"timeToMaturityDays": "NaN",
|
||||
"volSurfaceNames":
|
||||
[
|
||||
"1_343"
|
||||
],
|
||||
"isForwardTrade": false
|
||||
},
|
||||
"calcVersion": 2,
|
||||
"spotPrices":
|
||||
[
|
||||
6158.6371
|
||||
],
|
||||
"pricingRequest": 4398046515073,
|
||||
"quadratureFastMode": false,
|
||||
"CalcDeltaT1": false,
|
||||
"underlyingTickers":
|
||||
[
|
||||
"000905.SH"
|
||||
],
|
||||
"volSurfaceNames":
|
||||
[
|
||||
"1_343"
|
||||
]
|
||||
}
|
||||
@@ -1,364 +0,0 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using YLErp.DBModels;
|
||||
using YLErp.Modules;
|
||||
using Dapper;
|
||||
using System.Text;
|
||||
using System.Linq;
|
||||
using YLErp.BLL;
|
||||
|
||||
namespace YLErp
|
||||
{
|
||||
[TestClass]
|
||||
public class UnitTestBase
|
||||
{
|
||||
protected OptUserInfo CurUser
|
||||
{
|
||||
get { return new OptUserInfo(0, "UnitTest"); }
|
||||
}
|
||||
|
||||
[AssemblyInitialize()]
|
||||
public static void Initialize(TestContext context)
|
||||
{
|
||||
if (AppContext.TryGetSwitch("UnitTest", out _))
|
||||
{
|
||||
throw new Exception("这个方法应该只运行一次才对,否则想办法解决");
|
||||
}
|
||||
AppContext.SetSwitch("UnitTest", true);
|
||||
AppManager.Initialize(Enums.SubSystemName.UnitTest);
|
||||
Modules.DataCacheModule.DataCacheManager.StartUpdate(600 * 1000);
|
||||
Thread.Sleep(2000);
|
||||
}
|
||||
|
||||
protected static string ReadResourceFile(string fileName)
|
||||
{
|
||||
var path = Path.Combine(AppContext.BaseDirectory, "Resources\\" + fileName);
|
||||
return File.ReadAllText(path);
|
||||
}
|
||||
}
|
||||
|
||||
public class YLUnitTestBase : YLBaseService
|
||||
{
|
||||
bool _disposed = false;
|
||||
|
||||
readonly StringBuilder _clearSQL;
|
||||
|
||||
public YLUnitTestBase() : base(new OptUserInfo(0, "UnitTest"))
|
||||
{
|
||||
_clearSQL = new StringBuilder();
|
||||
}
|
||||
|
||||
public YLUnitTestBase(YLBaseService baseService) : base(baseService)
|
||||
{
|
||||
_clearSQL = new StringBuilder();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 生成标的代码为CESHI99X的标的或者RB00(长期固定代码)
|
||||
/// </summary>
|
||||
protected underlying_manager GetUnderlyingManager(bool isRB00 = false)
|
||||
{
|
||||
var underlyingCode = isRB00 ? "RB00" : "RBTST";
|
||||
|
||||
var un = DbContext.underlying_manager.AsNoTracking().FirstOrDefault(n => n.UnderlyingCode == underlyingCode);
|
||||
|
||||
if (un == null)
|
||||
{
|
||||
var va = GetVariety(true);
|
||||
un = new underlying_manager
|
||||
{
|
||||
CommodityCode = "RB",
|
||||
ContractSize = 10,
|
||||
CountRatio = 1,
|
||||
Desc = underlyingCode,
|
||||
DividendRate = 0,
|
||||
LaunchState = "1",
|
||||
MarginRate = 0.06,
|
||||
MarketCode = "SHFE",
|
||||
MarketName = "上海期货交易所",
|
||||
MaturityDate = new DateTime(2030, 1, 1),
|
||||
OpenDate = new DateTime(2020, 1, 1),
|
||||
OptDate = DateTime.Now,
|
||||
OptId = UserId,
|
||||
OptName = UserName,
|
||||
VolatilityRate = "1%",
|
||||
Beta = "",
|
||||
LinkTo = "",
|
||||
Block1 = 0,
|
||||
Block2 = 0,
|
||||
Block3 = 0,
|
||||
Block4 = 0,
|
||||
Block5 = 0,
|
||||
IsMainContract = false,
|
||||
LastUpdateTime = DateTime.Now,
|
||||
PrevClosePrice = 3555,
|
||||
Price = 3600,
|
||||
PriceTick = 0.1,
|
||||
TradeUnit = "10吨/手",
|
||||
QuoteUnit = "元(人民币)/吨",
|
||||
TradeCode = underlyingCode,
|
||||
UnderlyingCode = underlyingCode,
|
||||
UnderlyingName = isRB00 ? "RB连续合约" : underlyingCode,
|
||||
UnderlyingInstrumentType = ConsGlobal.InstrumentType.CommodityFutures,
|
||||
UnderlyingState = "Live",
|
||||
UnderlyingStatus = "正常运行",
|
||||
UnderlyingTypeId = va.id,
|
||||
UnderlyingType = "螺纹钢",
|
||||
UpDownLimit = "10%"
|
||||
};
|
||||
DbContext.underlying_manager.Add(un);
|
||||
DbContext.SaveChanges();
|
||||
if (!isRB00)
|
||||
{
|
||||
AddClearSQL<underlying_manager>("UnderlyingCode='{0}'", underlyingCode);
|
||||
}
|
||||
}
|
||||
|
||||
return un;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 生成标的代码为CESHI99X的标的
|
||||
/// </summary>
|
||||
protected Variety GetVariety(bool isRB = false)
|
||||
{
|
||||
var varietyCode = isRB ? "RB" : "TSTVA";
|
||||
|
||||
var va = DbContext.variety.AsNoTracking().FirstOrDefault(n => n.VarietyCode == varietyCode);
|
||||
|
||||
if (va == null)
|
||||
{
|
||||
var market = DbContext.market.AsNoTracking().FirstOrDefault(n => n.ExchangeNo == "SHFE");
|
||||
va = new Variety
|
||||
{
|
||||
AssetType = "黑色系",
|
||||
CloseTodayCommission = null,
|
||||
CloseTodayCommissionType = "固定",
|
||||
CloseTodayContractRule = "",
|
||||
Commission = null,
|
||||
CommissionType = "固定",
|
||||
ContractMonth = "1-12月",
|
||||
DeliveryGrade = "",
|
||||
DeliveryPlace = "交易所指定交割仓库",
|
||||
DeliveryType = "实物交割",
|
||||
Description = "",
|
||||
DownLimit = "6%",
|
||||
HasFieldOptions = false,
|
||||
HasNightMarket = false,
|
||||
IsVarietyOpenLimitPercent = false,
|
||||
Margin = 0.07,
|
||||
MiniDeliveryUnit = null,
|
||||
OptDate = OptDate,
|
||||
OptId = UserId,
|
||||
OptName = UserName,
|
||||
MinPriceChange = "1元/吨",
|
||||
QuoteUnit = "元(人民币)/吨",
|
||||
TradeUnit = "10吨/手",
|
||||
VarietyCode = varietyCode,
|
||||
VarietyName = "螺纹钢",
|
||||
ShortName = varietyCode,
|
||||
TradedOptionCommissionType = null,
|
||||
TradeTimeSlot = null,
|
||||
UpLimit = "6%",
|
||||
VolatilityRate = "6%",
|
||||
VarietyOpenLimit = null,
|
||||
TradingMarketId = market.id,
|
||||
TradingMarket = "上海期货交易所"
|
||||
};
|
||||
|
||||
DbContext.variety.Add(va);
|
||||
DbContext.SaveChanges();
|
||||
|
||||
if (!isRB)
|
||||
{
|
||||
AddClearSQL<Variety>("id=" + va.id);
|
||||
}
|
||||
}
|
||||
|
||||
return va;
|
||||
}
|
||||
|
||||
AssetUnit _assetunit;
|
||||
|
||||
/// <summary>
|
||||
/// 获取test1簿记
|
||||
/// </summary>
|
||||
protected AssetUnit GetAssetUnit()
|
||||
{
|
||||
if (_assetunit != null)
|
||||
{
|
||||
return _assetunit;
|
||||
}
|
||||
_assetunit = DbContext.assetunit.AsNoTracking().FirstOrDefault(n => n.Name == "test1");
|
||||
if (_assetunit == null)
|
||||
{
|
||||
_assetunit = new AssetUnit
|
||||
{
|
||||
Name = "test1",
|
||||
BaseCurrency = "人民币CNY",
|
||||
InitialMoney = null,
|
||||
OptDate = OptDate,
|
||||
OptId = UserId,
|
||||
OptName = UserName,
|
||||
Remark = "单元测试生成",
|
||||
TraderIds = "1,2,3,4,5,6,7,8,9,10",
|
||||
TraderNames = "",
|
||||
UserGroup = null
|
||||
};
|
||||
DbContext.assetunit.Add(_assetunit);
|
||||
DbContext.SaveChanges();
|
||||
}
|
||||
return _assetunit;
|
||||
}
|
||||
|
||||
Client _client;
|
||||
|
||||
/// <summary>
|
||||
/// 获取test1客户
|
||||
/// </summary>
|
||||
protected Client GetClient()
|
||||
{
|
||||
if (_client != null)
|
||||
{
|
||||
return _client;
|
||||
}
|
||||
var db = DbContextFactory.GetClientDbContext(OptUser);
|
||||
_client = db.client.AsNoTracking().FirstOrDefault(n => n.Name == "test1");
|
||||
if (_client == null)
|
||||
{
|
||||
_client = new Client
|
||||
{
|
||||
Name = "test1",
|
||||
OptDate = OptDate,
|
||||
OptId = UserId,
|
||||
OptName = UserName,
|
||||
Remark = "单元测试生成",
|
||||
Abbreviation = "单元测试",
|
||||
AcceptableLoss = "很多",
|
||||
ActualBeneficiary = "单元测试",
|
||||
ActualController = "单元测试",
|
||||
Address = "单元测试",
|
||||
AdminFullName = "单元测试",
|
||||
AdminRegisteredNum = "单元测试",
|
||||
AppropriatenessAssessor = 0,
|
||||
AppropriatenessDegree = 5,
|
||||
BadFaithRecord = 0,
|
||||
BookTime = null,
|
||||
BusinessScope = 0,
|
||||
BusinessType = "单元测试",
|
||||
Capitalbalance = 0,
|
||||
ChangeReasonAndEvaluationResults = "",
|
||||
ClientType = "",
|
||||
Code = "",
|
||||
CreditDeadline = null,
|
||||
CreditDirection = "",
|
||||
CreditName = "",
|
||||
CreditTemp = 0,
|
||||
CreditTempDeadline = null,
|
||||
CreditYear = null,
|
||||
CurrentContractNo = 0,
|
||||
CustomerManager = "",
|
||||
CustomerManagerId = 0,
|
||||
CustomerNature = 0,
|
||||
CustomerNature1 = "",
|
||||
CustomerNature2 = "",
|
||||
DefaultLoginName = "",
|
||||
DerivativesInvestmentVarieties = "",
|
||||
DisbeliefRecord = "",
|
||||
Email = "",
|
||||
EndureLevel = "",
|
||||
EvaluateDate = null,
|
||||
EvaluateOfValidity = "",
|
||||
ExpectedReturn = 0,
|
||||
ExpectedReturn2 = "",
|
||||
FinancialSituation = "",
|
||||
FundsSource = 0,
|
||||
Guid = Guid.NewGuid().ToString("N"),
|
||||
MarginOptionType = 0,
|
||||
IdentificationNumber = "unit-test-001",
|
||||
InstitutionalAttributes = "",
|
||||
InvestmentExperience = "",
|
||||
InvestmentTerm = 0,
|
||||
InvestorType = 0,
|
||||
IsAcceptHighRiskService = 0,
|
||||
IsAssessmentResultChange = 0,
|
||||
IsAutoReback = 0,
|
||||
IsCreditOn = 0,
|
||||
IsEvaluate = 0,
|
||||
IsIndustryConnectVariety = 0,
|
||||
IsRealControl = 0,
|
||||
IsRequireConversionTypes = 0,
|
||||
IsTradeCredit = 0,
|
||||
Level = "",
|
||||
LevelId = 0,
|
||||
LicenseCode = "",
|
||||
LicenseCodeDate = null,
|
||||
LicenseType = "",
|
||||
Number = "unit-test-001",
|
||||
PendingMarginCallPayment = 0,
|
||||
Phone = "",
|
||||
PostalAddress = "",
|
||||
PostalCode = "",
|
||||
PrivateFundProductInformation = "",
|
||||
ProcessOptDate = null,
|
||||
ProcessOrderId = 0,
|
||||
ProcessStatus = "",
|
||||
ProductNumber = "",
|
||||
ProperClientClass = "",
|
||||
ProtocolSignDate = null,
|
||||
ProtocolSignVersion = "",
|
||||
Pwd = "",
|
||||
Region = "",
|
||||
QuestionnaireScore = 0,
|
||||
RegisteredAddress = "",
|
||||
RegisteredCapital = "",
|
||||
RejectOrderId = 0,
|
||||
RightProtocolSignDate = null,
|
||||
RiskPreference = "",
|
||||
RiskServiceDegree = 5,
|
||||
SalesDepartment = "",
|
||||
SalesDepartmentId = 0,
|
||||
SamePeer = 0,
|
||||
Seller = "",
|
||||
TradingInstType = DBModels.Enums.TradingInstTypeEnum.All,
|
||||
TransactionTarget = "",
|
||||
Type = ""
|
||||
};
|
||||
db.client.Add(_client);
|
||||
DbContext.SaveChanges();
|
||||
}
|
||||
return _client;
|
||||
}
|
||||
|
||||
protected void AddClearSQL<TEntity>(string whereFormat, params object[] args) where TEntity : class
|
||||
{
|
||||
var tableName = DbContext.GetTableName<TEntity>();
|
||||
|
||||
_clearSQL.Append("delete from ").Append(tableName)
|
||||
.Append(" where ").AppendFormat(whereFormat, args).AppendLine(";");
|
||||
}
|
||||
|
||||
[ClassCleanup]
|
||||
public override void Dispose()
|
||||
{
|
||||
if (_disposed) return;
|
||||
|
||||
_disposed = true;
|
||||
|
||||
try
|
||||
{
|
||||
if (_clearSQL.Length > 0)
|
||||
{
|
||||
DbContext.Database.Connection.Execute(_clearSQL.ToString());
|
||||
_clearSQL.Clear();
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
DbContext.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,283 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="..\packages\EntityFramework.6.4.4\build\EntityFramework.props" Condition="Exists('..\packages\EntityFramework.6.4.4\build\EntityFramework.props')" />
|
||||
<Import Project="..\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.props" Condition="Exists('..\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.props')" />
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{12BAF174-CB2F-4A92-9C82-B7AE28C1BAD9}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>YLErp</RootNamespace>
|
||||
<AssemblyName>YLErpUnitTest</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">15.0</VisualStudioVersion>
|
||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
|
||||
<IsCodedUITest>False</IsCodedUITest>
|
||||
<TestProjectType>UnitTest</TestProjectType>
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="AutoMapper, Version=10.0.0.0, Culture=neutral, PublicKeyToken=be96cd2c38ef1005, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\AutoMapper.10.0.0\lib\net461\AutoMapper.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="ClosedXML, Version=0.95.3.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\ClosedXML.0.95.3\lib\net46\ClosedXML.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Dapper, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Dapper.2.0.35\lib\net461\Dapper.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="DocumentFormat.OpenXml, Version=2.11.3.0, Culture=neutral, PublicKeyToken=8fb06cb64d019a17, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\DocumentFormat.OpenXml.2.11.3\lib\net46\DocumentFormat.OpenXml.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\EntityFramework.6.4.4\lib\net45\EntityFramework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\EntityFramework.6.4.4\lib\net45\EntityFramework.SqlServer.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="ExcelDataReader, Version=3.6.0.0, Culture=neutral, PublicKeyToken=93517dbe6a4012fa, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\ExcelDataReader.3.6.0\lib\net45\ExcelDataReader.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="ExcelDataReader.DataSet, Version=3.6.0.0, Culture=neutral, PublicKeyToken=93517dbe6a4012fa, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\ExcelDataReader.DataSet.3.6.0\lib\net35\ExcelDataReader.DataSet.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="ExcelNumberFormat, Version=1.0.10.0, Culture=neutral, PublicKeyToken=23c6f5d73be07eca, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\ExcelNumberFormat.1.0.10\lib\net20\ExcelNumberFormat.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="KellermanSoftware.Compare-NET-Objects, Version=4.66.0.0, Culture=neutral, PublicKeyToken=d970ace04cc85217, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\CompareNETObjects.4.66.0\lib\net472\KellermanSoftware.Compare-NET-Objects.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\MSTest.TestFramework.2.1.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\MSTest.TestFramework.2.1.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="MySql.Data, Version=6.10.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\MySql.Data.6.10.9\lib\net452\MySql.Data.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="MySql.Data.Entity.EF6, Version=6.10.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\MySql.Data.Entity.6.10.9\lib\net452\MySql.Data.Entity.EF6.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Qdp.ComputeService.Data.CommonModels, Version=4.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\DLL\Qdp\Qdp.ComputeService.Data.CommonModels.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Qdp.ComputeServiceV2.Data.CommonModels, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\DLL\Qdp\Qdp.ComputeServiceV2.Data.CommonModels.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Qdp.Foundation">
|
||||
<HintPath>..\DLL\Qdp\Qdp.Foundation.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Qdp.Pricing.Base">
|
||||
<HintPath>..\DLL\Qdp\Qdp.Pricing.Base.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Qdp.Pricing.Ecosystem, Version=4.1.0.0, Culture=neutral, PublicKeyToken=null" />
|
||||
<Reference Include="Qdp.Pricing.Library.Base">
|
||||
<HintPath>..\DLL\Qdp\Qdp.Pricing.Library.Base.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Qdp.Pricing.Library.Common, Version=4.1.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\DLL\Qdp\Qdp.Pricing.Library.Common.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Qdp.Pricing.Library.Equity, Version=4.1.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\DLL\Qdp\Qdp.Pricing.Library.Equity.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Qdp.Pricing.Library.Options, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\DLL\Qdp\Qdp.Pricing.Library.Options.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.ComponentModel" />
|
||||
<Reference Include="System.ComponentModel.DataAnnotations" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Configuration.Install" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Drawing.Design" />
|
||||
<Reference Include="System.IO.Compression" />
|
||||
<Reference Include="System.IO.FileSystem.Primitives, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.IO.FileSystem.Primitives.4.3.0\lib\net46\System.IO.FileSystem.Primitives.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.IO.Packaging, Version=4.0.5.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.IO.Packaging.4.7.0\lib\net46\System.IO.Packaging.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Management" />
|
||||
<Reference Include="System.Security" />
|
||||
<Reference Include="System.Transactions" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="WindowsBase" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="CoreTests\OtcFormatTest.cs" />
|
||||
<Compile Include="ExternalLibTests\AutoMapperTest.cs" />
|
||||
<Compile Include="ExternalLibTests\DbfReaderTest.cs" />
|
||||
<Compile Include="CoreTests\BaseTest.cs" />
|
||||
<Compile Include="Helpers\InnerExchangeTradeCommissionCalc.cs" />
|
||||
<Compile Include="Helpers\InnerExchangeOptionPriceProvider.cs" />
|
||||
<Compile Include="Helpers\InnerTradeCommissionResult.cs" />
|
||||
<Compile Include="Helpers\InnerUnderlyingDataProvider.cs" />
|
||||
<Compile Include="Helpers\InnerUnderlyingPriceProvider.cs" />
|
||||
<Compile Include="Modules\BaseModule\OtcFormatTest.cs" />
|
||||
<Compile Include="Modules\CalculationModule\ForwardradeCalcServiceTest.cs" />
|
||||
<Compile Include="Modules\CalculationModule\HedgePnlCalcTest.cs" />
|
||||
<Compile Include="Modules\CalculationModule\OptionCaclTest.cs" />
|
||||
<Compile Include="Modules\CalculationModule\OptionCalculatorCompare.cs" />
|
||||
<Compile Include="Modules\CalculationModule\SSpreadOptionCalcTest.cs" />
|
||||
<Compile Include="Modules\CalculationModule\V1\OptionCalculatorV1.cs" />
|
||||
<Compile Include="Modules\DataProviderModule\EodExchangeOptionPriceProviderTest.cs" />
|
||||
<Compile Include="Modules\DataProviderModule\ExchangeOptionPriceProviderTest.cs" />
|
||||
<Compile Include="Modules\DataProviderModule\TradeHisDataProviderTest.cs" />
|
||||
<Compile Include="Modules\EodModule\EodSettlementServiceTest.cs" />
|
||||
<Compile Include="Modules\UnderlyingModule\ApiModuleTest.cs" />
|
||||
<Compile Include="Modules\UnderlyingModule\MarginParamsImportServiceTest.cs" />
|
||||
<Compile Include="Modules\TradeModule\OrderModule\OtcTradeSaveServiceTest.cs" />
|
||||
<Compile Include="Modules\TradeModule\TradeHisDataServiceTest.cs" />
|
||||
<Compile Include="Modules\VolatilityModule\VarietyVolServiceTest.cs" />
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="ExternalLibTests\ExcelDataReaderTest.cs" />
|
||||
<Compile Include="Modules\ClientModule\ClientPositionServiceTest.cs" />
|
||||
<Compile Include="Modules\DataCacheModule\DataCacheTest.cs" />
|
||||
<Compile Include="ExternalLibTests\EntityFrameworkTest .cs" />
|
||||
<Compile Include="Modules\MarginModule\MarginCalculation\Inner\CalculatorHelperOld.cs" />
|
||||
<Compile Include="Modules\MarginModule\MarginCalculation\Inner\eod_commodity_future_priceBLL.cs" />
|
||||
<Compile Include="Modules\MarginModule\MarginCalculation\ALQHMarginCalculation.cs" />
|
||||
<Compile Include="Modules\MarginModule\MarginCalculation\BHRSMarginCalculation.cs" />
|
||||
<Compile Include="Modules\MarginModule\MarginCalculation\BXMarginCalculation.cs" />
|
||||
<Compile Include="Modules\MarginModule\MarginCalculation\FDMarginCalculation.cs" />
|
||||
<Compile Include="Modules\MarginModule\MarginCalculation\GDGZMarginCalculation.cs" />
|
||||
<Compile Include="Modules\MarginModule\MarginCalculation\GLDHMarginCalculation.cs" />
|
||||
<Compile Include="Modules\MarginModule\MarginCalculation\GTJAMarginCalculation.cs" />
|
||||
<Compile Include="Modules\MarginModule\MarginCalculation\HaiTongMarginCalculation.cs" />
|
||||
<Compile Include="Modules\MarginModule\MarginCalculation\HongYuanMarginCalculation.cs" />
|
||||
<Compile Include="Modules\MarginModule\MarginCalculation\MaoChuanMarginCalculation.cs" />
|
||||
<Compile Include="Modules\MarginModule\MarginCalculation\MarginCalcException.cs" />
|
||||
<Compile Include="Modules\MarginModule\MarginCalculation\MarginCalculation.cs" />
|
||||
<Compile Include="Modules\MarginModule\MarginCalculation\MarginCalculationBase.cs" />
|
||||
<Compile Include="Modules\MarginModule\MarginCalculation\RDMarginCalculation.cs" />
|
||||
<Compile Include="Modules\MarginModule\MarginCalculation\SYWGMarginCalculation.cs" />
|
||||
<Compile Include="Modules\MarginModule\MarginCalculation\UniversalMarginCalculation.cs" />
|
||||
<Compile Include="Modules\MarginModule\BasicCalcTest.cs" />
|
||||
<Compile Include="Modules\MarginModule\GTJAMarginTest.cs" />
|
||||
<Compile Include="Modules\MarginModule\MarginParamsProviderTest.cs" />
|
||||
<Compile Include="Modules\SalesModule\SalesCommissionServiceTest.cs" />
|
||||
<Compile Include="Modules\TapconsoleModule\HaitongApiTest.cs" />
|
||||
<Compile Include="Modules\TradeModule\OtcTradeCloseServiceTest.cs" />
|
||||
<Compile Include="Modules\TradeModule\OtcTradeExportServiceTest.cs" />
|
||||
<Compile Include="Modules\TradeModule\OrderModule\OtcTradeImportServiceTest.cs" />
|
||||
<Compile Include="Modules\TradeModule\OrderModule\TradeAbstractServiceTest.cs" />
|
||||
<Compile Include="Modules\TradeModule\OtcTradeSaveServiceTest.cs" />
|
||||
<Compile Include="Modules\UnderlyingModule\HisDataServiceTest.cs" />
|
||||
<Compile Include="Modules\VolatilityModule\VolatilityBasicTest.cs" />
|
||||
<Compile Include="Modules\VolatilityModule\VolatilityQueryServiceTest.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<None Include="Resources\volatility.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<Compile Include="QdpModule\QdpCalendarTest.cs" />
|
||||
<Compile Include="UnitTestBase.cs" />
|
||||
<None Include="Resources\场外期权导入\场外期权交易导入%28凤凰%29.xlsx">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="Resources\场外期权导入\场外期权交易导入%28雪球%29.xlsx">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="Resources\期权计算\二元期权计算参数.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="Resources\期权计算\二元期权.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Framework\YieldChain.Core\YieldChain.Core.csproj">
|
||||
<Project>{7739DB31-DFEB-4995-97DE-58AD0AEE27CB}</Project>
|
||||
<Name>YieldChain.Core</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Framework\YLErp.Core\YLErp.Core.csproj">
|
||||
<Project>{BBE242B4-3BC6-4D19-BF16-47BB3AA79CD9}</Project>
|
||||
<Name>YLErp.Core</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Framework\YLErp.Office\YLErp.Office.csproj">
|
||||
<Project>{6ff75ad7-6150-43ca-b603-c085a4e5348c}</Project>
|
||||
<Name>YLErp.Office</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\YLErpDAL\YLErpDAL.csproj">
|
||||
<Project>{e398d3c7-d608-43bf-a8dd-9698aead0593}</Project>
|
||||
<Name>YLErpDAL</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Data\Calendars\chn.txt">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Resources\日终结算\Eod表更新.sql" />
|
||||
<Content Include="Resources\日终结算\查询结算数据.sql" />
|
||||
<Content Include="Resources\日终结算\结算数据比较.sql" />
|
||||
<Content Include="Resources\日终结算\清空结算数据.sql" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Resources\导出模板\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.props'))" />
|
||||
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.targets'))" />
|
||||
<Error Condition="!Exists('..\packages\EntityFramework.6.4.4\build\EntityFramework.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\EntityFramework.6.4.4\build\EntityFramework.props'))" />
|
||||
<Error Condition="!Exists('..\packages\EntityFramework.6.4.4\build\EntityFramework.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\EntityFramework.6.4.4\build\EntityFramework.targets'))" />
|
||||
</Target>
|
||||
<Import Project="..\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.targets" Condition="Exists('..\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.targets')" />
|
||||
<Import Project="..\packages\EntityFramework.6.4.4\build\EntityFramework.targets" Condition="Exists('..\packages\EntityFramework.6.4.4\build\EntityFramework.targets')" />
|
||||
</Project>
|
||||
@@ -1,113 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<configSections>
|
||||
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
|
||||
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
|
||||
</configSections>
|
||||
<connectionStrings>
|
||||
<add name="单元测试" connectionString="" />
|
||||
<add name="ERPBase" connectionString="server=101.133.141.207;uid=roottest;pooling=true;port=20306;pwd=YieldChain!@#$2020;database=dev_admin;charset=utf8;Allow User Variables=True;" providerName="MySql.Data.MySqlClient" />
|
||||
<add name="xray" connectionString="server=101.133.141.207;uid=roottest;pooling=true;port=20306;pwd=YieldChain!@#$2020;database=dev_ylcms;charset=utf8;Allow User Variables=True;" providerName="MySql.Data.MySqlClient" />
|
||||
<add name="ERPBaseClient" connectionString="server=101.133.141.207;uid=roottest;pooling=true;port=20306;pwd=YieldChain!@#$2020;database=dev_client;charset=utf8;Allow User Variables=True;" providerName="MySql.Data.MySqlClient" />
|
||||
</connectionStrings>
|
||||
<!--<connectionStrings>
|
||||
<add name="国君" connectionString="" />
|
||||
<add name="ERPBase" connectionString="server=101.133.141.207;uid=roottest;pooling=true;port=20306;pwd=YieldChain!@#$2020;database=dev_admin;charset=utf8;Allow User Variables=True;" providerName="MySql.Data.MySqlClient" />
|
||||
<add name="xray" connectionString="server=101.133.141.207;uid=roottest;pooling=true;port=20306;pwd=YieldChain!@#$2020;database=dev_ylcms;charset=utf8;Allow User Variables=True;" providerName="MySql.Data.MySqlClient" />
|
||||
<add name="ERPBaseClient" connectionString="server=101.133.141.207;uid=roottest;pooling=true;port=20306;pwd=YieldChain!@#$2020;database=dev_client;charset=utf8;Allow User Variables=True;" providerName="MySql.Data.MySqlClient" />
|
||||
</connectionStrings>-->
|
||||
<appSettings>
|
||||
<add key="ServiceApi" value="http://gtja-api.yiliantech.com/" />
|
||||
</appSettings>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.2.0.1" newVersion="4.2.0.1" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="ICSharpCode.SharpZipLib" publicKeyToken="1b03e6acf1164f73" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-1.2.0.246" newVersion="1.2.0.246" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.1.4.0" newVersion="4.1.4.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.6.0" newVersion="4.0.6.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="ExcelNumberFormat" publicKeyToken="23c6f5d73be07eca" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-1.0.10.0" newVersion="1.0.10.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="FastMember.Signed" publicKeyToken="9e8f22703bef9a29" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-1.5.0.0" newVersion="1.5.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Linq.Dynamic.Core" publicKeyToken="0f07ec44de6ac832" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-1.1.8.0" newVersion="1.1.8.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="EPPlus" publicKeyToken="ea159fdaa78159a1" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.5.3.3" newVersion="4.5.3.3" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="DocumentFormat.OpenXml" publicKeyToken="8fb06cb64d019a17" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.11.3.0" newVersion="2.11.3.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="MoreLinq" publicKeyToken="384d532d7e88985d" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-3.3.2.0" newVersion="3.3.2.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="AutoMapper" publicKeyToken="be96cd2c38ef1005" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-10.0.0.0" newVersion="10.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Collections.Immutable" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-1.2.5.0" newVersion="1.2.5.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Reflection.Metadata" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-1.4.5.0" newVersion="1.4.5.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Text.Encoding.CodePages" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.1.3.0" newVersion="4.1.3.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="NPOI" publicKeyToken="0df73ec7942b34e1" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.5.1.0" newVersion="2.5.1.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="NPOI.OOXML" publicKeyToken="0df73ec7942b34e1" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.5.1.0" newVersion="2.5.1.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="BouncyCastle.Crypto" publicKeyToken="0e99375e54769942" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-1.8.6.0" newVersion="1.8.6.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
<entityFramework>
|
||||
<providers>
|
||||
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
|
||||
<provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6, Version=6.10.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d">
|
||||
</provider>
|
||||
</providers>
|
||||
</entityFramework>
|
||||
</configuration>
|
||||
@@ -1,20 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="AutoMapper" version="10.0.0" targetFramework="net472" />
|
||||
<package id="ClosedXML" version="0.95.3" targetFramework="net472" />
|
||||
<package id="CompareNETObjects" version="4.66.0" targetFramework="net472" />
|
||||
<package id="Dapper" version="2.0.35" targetFramework="net472" />
|
||||
<package id="DocumentFormat.OpenXml" version="2.11.3" targetFramework="net472" />
|
||||
<package id="EntityFramework" version="6.4.4" targetFramework="net472" />
|
||||
<package id="ExcelDataReader" version="3.6.0" targetFramework="net472" />
|
||||
<package id="ExcelDataReader.DataSet" version="3.6.0" targetFramework="net472" />
|
||||
<package id="ExcelNumberFormat" version="1.0.10" targetFramework="net472" />
|
||||
<package id="Microsoft.CSharp" version="4.7.0" targetFramework="net472" />
|
||||
<package id="MSTest.TestAdapter" version="2.1.2" targetFramework="net472" />
|
||||
<package id="MSTest.TestFramework" version="2.1.2" targetFramework="net472" />
|
||||
<package id="MySql.Data" version="6.10.9" targetFramework="net472" />
|
||||
<package id="MySql.Data.Entity" version="6.10.9" targetFramework="net472" />
|
||||
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net472" />
|
||||
<package id="System.IO.FileSystem.Primitives" version="4.3.0" targetFramework="net472" />
|
||||
<package id="System.IO.Packaging" version="4.7.0" targetFramework="net472" />
|
||||
</packages>
|
||||
Reference in New Issue
Block a user