diff --git a/YLErpUnitTest/CoreTests/BaseTest.cs b/YLErpUnitTest/CoreTests/BaseTest.cs deleted file mode 100644 index e23bac9a..00000000 --- a/YLErpUnitTest/CoreTests/BaseTest.cs +++ /dev/null @@ -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"); - - } - } -} diff --git a/YLErpUnitTest/CoreTests/OtcFormatTest.cs b/YLErpUnitTest/CoreTests/OtcFormatTest.cs deleted file mode 100644 index 0ce5af2c..00000000 --- a/YLErpUnitTest/CoreTests/OtcFormatTest.cs +++ /dev/null @@ -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"); - } - } -} diff --git a/YLErpUnitTest/Data/Calendars/chn.txt b/YLErpUnitTest/Data/Calendars/chn.txt deleted file mode 100644 index 43479215..00000000 --- a/YLErpUnitTest/Data/Calendars/chn.txt +++ /dev/null @@ -1,7270 +0,0 @@ -{ -"HolidayList":[ -"2000,01,01", -"2000,01,02", -"2000,01,08", -"2000,01,09", -"2000,01,15", -"2000,01,16", -"2000,01,22", -"2000,01,23", -"2000,01,29", -"2000,01,30", -"2000,02,04", -"2000,02,05", -"2000,02,06", -"2000,02,07", -"2000,02,08", -"2000,02,09", -"2000,02,10", -"2000,02,12", -"2000,02,13", -"2000,02,19", -"2000,02,20", -"2000,02,26", -"2000,02,27", -"2000,03,04", -"2000,03,05", -"2000,03,11", -"2000,03,12", -"2000,03,18", -"2000,03,19", -"2000,03,25", -"2000,03,26", -"2000,04,01", -"2000,04,02", -"2000,04,08", -"2000,04,09", -"2000,04,15", -"2000,04,16", -"2000,04,22", -"2000,04,23", -"2000,04,29", -"2000,04,30", -"2000,05,01", -"2000,05,02", -"2000,05,03", -"2000,05,04", -"2000,05,05", -"2000,05,06", -"2000,05,07", -"2000,05,13", -"2000,05,14", -"2000,05,20", -"2000,05,21", -"2000,05,27", -"2000,05,28", -"2000,06,03", -"2000,06,04", -"2000,06,10", -"2000,06,11", -"2000,06,17", -"2000,06,18", -"2000,06,24", -"2000,06,25", -"2000,07,01", -"2000,07,02", -"2000,07,08", -"2000,07,09", -"2000,07,15", -"2000,07,16", -"2000,07,22", -"2000,07,23", -"2000,07,29", -"2000,07,30", -"2000,08,05", -"2000,08,06", -"2000,08,12", -"2000,08,13", -"2000,08,19", -"2000,08,20", -"2000,08,26", -"2000,08,27", -"2000,09,02", -"2000,09,03", -"2000,09,09", -"2000,09,10", -"2000,09,16", -"2000,09,17", -"2000,09,23", -"2000,09,24", -"2000,09,30", -"2000,10,01", -"2000,10,02", -"2000,10,03", -"2000,10,04", -"2000,10,05", -"2000,10,06", -"2000,10,07", -"2000,10,08", -"2000,10,14", -"2000,10,15", -"2000,10,21", -"2000,10,22", -"2000,10,28", -"2000,10,29", -"2000,11,04", -"2000,11,05", -"2000,11,11", -"2000,11,12", -"2000,11,18", -"2000,11,19", -"2000,11,25", -"2000,11,26", -"2000,12,02", -"2000,12,03", -"2000,12,09", -"2000,12,10", -"2000,12,16", -"2000,12,17", -"2000,12,23", -"2000,12,24", -"2000,12,30", -"2000,12,31", -"2001,01,01", -"2001,01,06", -"2001,01,07", -"2001,01,13", -"2001,01,14", -"2001,01,20", -"2001,01,21", -"2001,01,24", -"2001,01,25", -"2001,01,26", -"2001,01,27", -"2001,01,28", -"2001,01,29", -"2001,01,30", -"2001,02,03", -"2001,02,04", -"2001,02,10", -"2001,02,11", -"2001,02,17", -"2001,02,18", -"2001,02,24", -"2001,02,25", -"2001,03,03", -"2001,03,04", -"2001,03,10", -"2001,03,11", -"2001,03,17", -"2001,03,18", -"2001,03,24", -"2001,03,25", -"2001,03,31", -"2001,04,01", -"2001,04,07", -"2001,04,08", -"2001,04,14", -"2001,04,15", -"2001,04,21", -"2001,04,22", -"2001,04,28", -"2001,04,29", -"2001,05,01", -"2001,05,02", -"2001,05,03", -"2001,05,04", -"2001,05,05", -"2001,05,06", -"2001,05,07", -"2001,05,12", -"2001,05,13", -"2001,05,19", -"2001,05,20", -"2001,05,26", -"2001,05,27", -"2001,06,02", -"2001,06,03", -"2001,06,09", -"2001,06,10", -"2001,06,16", -"2001,06,17", -"2001,06,23", -"2001,06,24", -"2001,06,30", -"2001,07,01", -"2001,07,07", -"2001,07,08", -"2001,07,14", -"2001,07,15", -"2001,07,21", -"2001,07,22", -"2001,07,28", -"2001,07,29", -"2001,08,04", -"2001,08,05", -"2001,08,11", -"2001,08,12", -"2001,08,18", -"2001,08,19", -"2001,08,25", -"2001,08,26", -"2001,09,01", -"2001,09,02", -"2001,09,08", -"2001,09,09", -"2001,09,15", -"2001,09,16", -"2001,09,22", -"2001,09,23", -"2001,09,29", -"2001,09,30", -"2001,10,01", -"2001,10,02", -"2001,10,03", -"2001,10,04", -"2001,10,05", -"2001,10,06", -"2001,10,07", -"2001,10,13", -"2001,10,14", -"2001,10,20", -"2001,10,21", -"2001,10,27", -"2001,10,28", -"2001,11,03", -"2001,11,04", -"2001,11,10", -"2001,11,11", -"2001,11,17", -"2001,11,18", -"2001,11,24", -"2001,11,25", -"2001,12,01", -"2001,12,02", -"2001,12,08", -"2001,12,09", -"2001,12,15", -"2001,12,16", -"2001,12,22", -"2001,12,23", -"2001,12,29", -"2001,12,30", -"2002,01,01", -"2002,01,02", -"2002,01,03", -"2002,01,05", -"2002,01,06", -"2002,01,12", -"2002,01,13", -"2002,01,19", -"2002,01,20", -"2002,01,26", -"2002,01,27", -"2002,02,02", -"2002,02,03", -"2002,02,09", -"2002,02,10", -"2002,02,12", -"2002,02,13", -"2002,02,14", -"2002,02,15", -"2002,02,16", -"2002,02,17", -"2002,02,18", -"2002,02,23", -"2002,02,24", -"2002,03,02", -"2002,03,03", -"2002,03,09", -"2002,03,10", -"2002,03,16", -"2002,03,17", -"2002,03,23", -"2002,03,24", -"2002,03,30", -"2002,03,31", -"2002,04,06", -"2002,04,07", -"2002,04,13", -"2002,04,14", -"2002,04,20", -"2002,04,21", -"2002,04,27", -"2002,04,28", -"2002,05,01", -"2002,05,02", -"2002,05,03", -"2002,05,04", -"2002,05,05", -"2002,05,06", -"2002,05,07", -"2002,05,11", -"2002,05,12", -"2002,05,18", -"2002,05,19", -"2002,05,25", -"2002,05,26", -"2002,06,01", -"2002,06,02", -"2002,06,08", -"2002,06,09", -"2002,06,15", -"2002,06,16", -"2002,06,22", -"2002,06,23", -"2002,06,29", -"2002,06,30", -"2002,07,06", -"2002,07,07", -"2002,07,13", -"2002,07,14", -"2002,07,20", -"2002,07,21", -"2002,07,27", -"2002,07,28", -"2002,08,03", -"2002,08,04", -"2002,08,10", -"2002,08,11", -"2002,08,17", -"2002,08,18", -"2002,08,24", -"2002,08,25", -"2002,08,31", -"2002,09,01", -"2002,09,07", -"2002,09,08", -"2002,09,14", -"2002,09,15", -"2002,09,21", -"2002,09,22", -"2002,09,28", -"2002,09,29", -"2002,10,01", -"2002,10,02", -"2002,10,03", -"2002,10,04", -"2002,10,05", -"2002,10,06", -"2002,10,07", -"2002,10,12", -"2002,10,13", -"2002,10,19", -"2002,10,20", -"2002,10,26", -"2002,10,27", -"2002,11,02", -"2002,11,03", -"2002,11,09", -"2002,11,10", -"2002,11,16", -"2002,11,17", -"2002,11,23", -"2002,11,24", -"2002,11,30", -"2002,12,01", -"2002,12,07", -"2002,12,08", -"2002,12,14", -"2002,12,15", -"2002,12,21", -"2002,12,22", -"2002,12,28", -"2002,12,29", -"2003,01,01", -"2003,01,02", -"2003,01,03", -"2003,01,04", -"2003,01,05", -"2003,01,11", -"2003,01,12", -"2003,01,18", -"2003,01,19", -"2003,01,25", -"2003,01,26", -"2003,02,01", -"2003,02,02", -"2003,02,03", -"2003,02,04", -"2003,02,05", -"2003,02,06", -"2003,02,07", -"2003,02,08", -"2003,02,09", -"2003,02,15", -"2003,02,16", -"2003,02,22", -"2003,02,23", -"2003,03,01", -"2003,03,02", -"2003,03,08", -"2003,03,09", -"2003,03,15", -"2003,03,16", -"2003,03,22", -"2003,03,23", -"2003,03,29", -"2003,03,30", -"2003,04,05", -"2003,04,06", -"2003,04,12", -"2003,04,13", -"2003,04,19", -"2003,04,20", -"2003,04,26", -"2003,04,27", -"2003,05,01", -"2003,05,02", -"2003,05,03", -"2003,05,04", -"2003,05,05", -"2003,05,06", -"2003,05,07", -"2003,05,10", -"2003,05,11", -"2003,05,17", -"2003,05,18", -"2003,05,24", -"2003,05,25", -"2003,05,31", -"2003,06,01", -"2003,06,07", -"2003,06,08", -"2003,06,14", -"2003,06,15", -"2003,06,21", -"2003,06,22", -"2003,06,28", -"2003,06,29", -"2003,07,05", -"2003,07,06", -"2003,07,12", -"2003,07,13", -"2003,07,19", -"2003,07,20", -"2003,07,26", -"2003,07,27", -"2003,08,02", -"2003,08,03", -"2003,08,09", -"2003,08,10", -"2003,08,16", -"2003,08,17", -"2003,08,23", -"2003,08,24", -"2003,08,30", -"2003,08,31", -"2003,09,06", -"2003,09,07", -"2003,09,13", -"2003,09,14", -"2003,09,20", -"2003,09,21", -"2003,09,27", -"2003,09,28", -"2003,10,01", -"2003,10,02", -"2003,10,03", -"2003,10,04", -"2003,10,05", -"2003,10,06", -"2003,10,07", -"2003,10,11", -"2003,10,12", -"2003,10,18", -"2003,10,19", -"2003,10,25", -"2003,10,26", -"2003,11,01", -"2003,11,02", -"2003,11,08", -"2003,11,09", -"2003,11,15", -"2003,11,16", -"2003,11,22", -"2003,11,23", -"2003,11,29", -"2003,11,30", -"2003,12,06", -"2003,12,07", -"2003,12,13", -"2003,12,14", -"2003,12,20", -"2003,12,21", -"2003,12,27", -"2003,12,28", -"2004,01,01", -"2004,01,02", -"2004,01,03", -"2004,01,04", -"2004,01,10", -"2004,01,11", -"2004,01,17", -"2004,01,18", -"2004,01,22", -"2004,01,23", -"2004,01,24", -"2004,01,25", -"2004,01,26", -"2004,01,27", -"2004,01,28", -"2004,01,31", -"2004,02,01", -"2004,02,07", -"2004,02,08", -"2004,02,10", -"2004,02,11", -"2004,02,12", -"2004,02,13", -"2004,02,14", -"2004,02,15", -"2004,02,21", -"2004,02,22", -"2004,02,28", -"2004,02,29", -"2004,03,06", -"2004,03,07", -"2004,03,13", -"2004,03,14", -"2004,03,20", -"2004,03,21", -"2004,03,27", -"2004,03,28", -"2004,04,03", -"2004,04,04", -"2004,04,10", -"2004,04,11", -"2004,04,17", -"2004,04,18", -"2004,04,24", -"2004,04,25", -"2004,05,01", -"2004,05,02", -"2004,05,03", -"2004,05,04", -"2004,05,05", -"2004,05,06", -"2004,05,07", -"2004,05,08", -"2004,05,09", -"2004,05,15", -"2004,05,16", -"2004,05,22", -"2004,05,23", -"2004,05,29", -"2004,05,30", -"2004,06,05", -"2004,06,06", -"2004,06,12", -"2004,06,13", -"2004,06,19", -"2004,06,20", -"2004,06,26", -"2004,06,27", -"2004,07,03", -"2004,07,04", -"2004,07,10", -"2004,07,11", -"2004,07,17", -"2004,07,18", -"2004,07,24", -"2004,07,25", -"2004,07,31", -"2004,08,01", -"2004,08,07", -"2004,08,08", -"2004,08,14", -"2004,08,15", -"2004,08,21", -"2004,08,22", -"2004,08,28", -"2004,08,29", -"2004,09,04", -"2004,09,05", -"2004,09,11", -"2004,09,12", -"2004,09,18", -"2004,09,19", -"2004,09,25", -"2004,09,26", -"2004,10,01", -"2004,10,02", -"2004,10,03", -"2004,10,04", -"2004,10,05", -"2004,10,06", -"2004,10,07", -"2004,10,09", -"2004,10,10", -"2004,10,16", -"2004,10,17", -"2004,10,23", -"2004,10,24", -"2004,10,30", -"2004,10,31", -"2004,11,06", -"2004,11,07", -"2004,11,13", -"2004,11,14", -"2004,11,20", -"2004,11,21", -"2004,11,27", -"2004,11,28", -"2004,12,04", -"2004,12,05", -"2004,12,11", -"2004,12,12", -"2004,12,18", -"2004,12,19", -"2004,12,25", -"2004,12,26", -"2005,01,01", -"2005,01,02", -"2005,01,03", -"2005,01,08", -"2005,01,09", -"2005,01,15", -"2005,01,16", -"2005,01,22", -"2005,01,23", -"2005,01,29", -"2005,01,30", -"2005,02,05", -"2005,02,06", -"2005,02,09", -"2005,02,10", -"2005,02,11", -"2005,02,12", -"2005,02,13", -"2005,02,14", -"2005,02,15", -"2005,02,19", -"2005,02,20", -"2005,02,26", -"2005,02,27", -"2005,03,05", -"2005,03,06", -"2005,03,12", -"2005,03,13", -"2005,03,19", -"2005,03,20", -"2005,03,26", -"2005,03,27", -"2005,04,02", -"2005,04,03", -"2005,04,09", -"2005,04,10", -"2005,04,16", -"2005,04,17", -"2005,04,23", -"2005,04,24", -"2005,04,30", -"2005,05,01", -"2005,05,02", -"2005,05,03", -"2005,05,04", -"2005,05,05", -"2005,05,06", -"2005,05,07", -"2005,05,08", -"2005,05,14", -"2005,05,15", -"2005,05,21", -"2005,05,22", -"2005,05,28", -"2005,05,29", -"2005,06,04", -"2005,06,05", -"2005,06,11", -"2005,06,12", -"2005,06,18", -"2005,06,19", -"2005,06,25", -"2005,06,26", -"2005,07,02", -"2005,07,03", -"2005,07,09", -"2005,07,10", -"2005,07,16", -"2005,07,17", -"2005,07,23", -"2005,07,24", -"2005,07,30", -"2005,07,31", -"2005,08,06", -"2005,08,07", -"2005,08,13", -"2005,08,14", -"2005,08,20", -"2005,08,21", -"2005,08,27", -"2005,08,28", -"2005,09,03", -"2005,09,04", -"2005,09,10", -"2005,09,11", -"2005,09,17", -"2005,09,18", -"2005,09,24", -"2005,09,25", -"2005,10,01", -"2005,10,02", -"2005,10,03", -"2005,10,04", -"2005,10,05", -"2005,10,06", -"2005,10,07", -"2005,10,08", -"2005,10,09", -"2005,10,15", -"2005,10,16", -"2005,10,22", -"2005,10,23", -"2005,10,29", -"2005,10,30", -"2005,11,05", -"2005,11,06", -"2005,11,12", -"2005,11,13", -"2005,11,19", -"2005,11,20", -"2005,11,26", -"2005,11,27", -"2005,12,03", -"2005,12,04", -"2005,12,10", -"2005,12,11", -"2005,12,17", -"2005,12,18", -"2005,12,24", -"2005,12,25", -"2005,12,31", -"2006,01,01", -"2006,01,02", -"2006,01,03", -"2006,01,07", -"2006,01,08", -"2006,01,14", -"2006,01,15", -"2006,01,21", -"2006,01,22", -"2006,01,28", -"2006,01,29", -"2006,01,30", -"2006,01,31", -"2006,02,01", -"2006,02,02", -"2006,02,03", -"2006,02,04", -"2006,02,05", -"2006,02,11", -"2006,02,12", -"2006,02,18", -"2006,02,19", -"2006,02,25", -"2006,02,26", -"2006,03,04", -"2006,03,05", -"2006,03,11", -"2006,03,12", -"2006,03,18", -"2006,03,19", -"2006,03,25", -"2006,03,26", -"2006,04,01", -"2006,04,02", -"2006,04,08", -"2006,04,09", -"2006,04,15", -"2006,04,16", -"2006,04,22", -"2006,04,23", -"2006,04,29", -"2006,04,30", -"2006,05,01", -"2006,05,02", -"2006,05,03", -"2006,05,04", -"2006,05,05", -"2006,05,06", -"2006,05,07", -"2006,05,13", -"2006,05,14", -"2006,05,20", -"2006,05,21", -"2006,05,27", -"2006,05,28", -"2006,06,03", -"2006,06,04", -"2006,06,10", -"2006,06,11", -"2006,06,17", -"2006,06,18", -"2006,06,24", -"2006,06,25", -"2006,07,01", -"2006,07,02", -"2006,07,08", -"2006,07,09", -"2006,07,15", -"2006,07,16", -"2006,07,22", -"2006,07,23", -"2006,07,29", -"2006,07,30", -"2006,08,05", -"2006,08,06", -"2006,08,12", -"2006,08,13", -"2006,08,19", -"2006,08,20", -"2006,08,26", -"2006,08,27", -"2006,09,02", -"2006,09,03", -"2006,09,09", -"2006,09,10", -"2006,09,16", -"2006,09,17", -"2006,09,23", -"2006,09,24", -"2006,09,30", -"2006,10,01", -"2006,10,02", -"2006,10,03", -"2006,10,04", -"2006,10,05", -"2006,10,07", -"2006,10,08", -"2006,10,14", -"2006,10,15", -"2006,10,21", -"2006,10,22", -"2006,10,28", -"2006,10,29", -"2006,11,04", -"2006,11,05", -"2006,11,11", -"2006,11,12", -"2006,11,18", -"2006,11,19", -"2006,11,25", -"2006,11,26", -"2006,12,02", -"2006,12,03", -"2006,12,09", -"2006,12,10", -"2006,12,16", -"2006,12,17", -"2006,12,23", -"2006,12,24", -"2006,12,30", -"2006,12,31", -"2007,01,01", -"2007,01,02", -"2007,01,03", -"2007,01,06", -"2007,01,07", -"2007,01,13", -"2007,01,14", -"2007,01,20", -"2007,01,21", -"2007,01,27", -"2007,01,28", -"2007,02,03", -"2007,02,04", -"2007,02,10", -"2007,02,11", -"2007,02,17", -"2007,02,18", -"2007,02,19", -"2007,02,20", -"2007,02,21", -"2007,02,22", -"2007,02,23", -"2007,02,24", -"2007,02,25", -"2007,03,03", -"2007,03,04", -"2007,03,10", -"2007,03,11", -"2007,03,17", -"2007,03,18", -"2007,03,24", -"2007,03,25", -"2007,03,31", -"2007,04,01", -"2007,04,07", -"2007,04,08", -"2007,04,14", -"2007,04,15", -"2007,04,21", -"2007,04,22", -"2007,04,28", -"2007,04,29", -"2007,05,01", -"2007,05,02", -"2007,05,03", -"2007,05,04", -"2007,05,05", -"2007,05,06", -"2007,05,07", -"2007,05,12", -"2007,05,13", -"2007,05,19", -"2007,05,20", -"2007,05,26", -"2007,05,27", -"2007,06,02", -"2007,06,03", -"2007,06,09", -"2007,06,10", -"2007,06,16", -"2007,06,17", -"2007,06,23", -"2007,06,24", -"2007,06,30", -"2007,07,01", -"2007,07,07", -"2007,07,08", -"2007,07,14", -"2007,07,15", -"2007,07,21", -"2007,07,22", -"2007,07,28", -"2007,07,29", -"2007,08,04", -"2007,08,05", -"2007,08,11", -"2007,08,12", -"2007,08,18", -"2007,08,19", -"2007,08,25", -"2007,08,26", -"2007,09,01", -"2007,09,02", -"2007,09,08", -"2007,09,09", -"2007,09,15", -"2007,09,16", -"2007,09,22", -"2007,09,23", -"2007,09,29", -"2007,09,30", -"2007,10,01", -"2007,10,02", -"2007,10,03", -"2007,10,04", -"2007,10,05", -"2007,10,06", -"2007,10,07", -"2007,10,13", -"2007,10,14", -"2007,10,20", -"2007,10,21", -"2007,10,27", -"2007,10,28", -"2007,11,03", -"2007,11,04", -"2007,11,10", -"2007,11,11", -"2007,11,17", -"2007,11,18", -"2007,11,24", -"2007,11,25", -"2007,12,01", -"2007,12,02", -"2007,12,08", -"2007,12,09", -"2007,12,15", -"2007,12,16", -"2007,12,22", -"2007,12,23", -"2007,12,29", -"2007,12,30", -"2007,12,31", -"2008,01,01", -"2008,01,05", -"2008,01,06", -"2008,01,12", -"2008,01,13", -"2008,01,19", -"2008,01,20", -"2008,01,26", -"2008,01,27", -"2008,02,02", -"2008,02,03", -"2008,02,06", -"2008,02,07", -"2008,02,08", -"2008,02,09", -"2008,02,10", -"2008,02,11", -"2008,02,12", -"2008,02,16", -"2008,02,17", -"2008,02,23", -"2008,02,24", -"2008,03,01", -"2008,03,02", -"2008,03,08", -"2008,03,09", -"2008,03,15", -"2008,03,16", -"2008,03,22", -"2008,03,23", -"2008,03,29", -"2008,03,30", -"2008,04,04", -"2008,04,05", -"2008,04,06", -"2008,04,12", -"2008,04,13", -"2008,04,19", -"2008,04,20", -"2008,04,26", -"2008,04,27", -"2008,05,01", -"2008,05,02", -"2008,05,03", -"2008,05,04", -"2008,05,10", -"2008,05,11", -"2008,05,17", -"2008,05,18", -"2008,05,24", -"2008,05,25", -"2008,05,31", -"2008,06,01", -"2008,06,07", -"2008,06,08", -"2008,06,09", -"2008,06,14", -"2008,06,15", -"2008,06,21", -"2008,06,22", -"2008,06,28", -"2008,06,29", -"2008,07,05", -"2008,07,06", -"2008,07,12", -"2008,07,13", -"2008,07,19", -"2008,07,20", -"2008,07,26", -"2008,07,27", -"2008,08,02", -"2008,08,03", -"2008,08,09", -"2008,08,10", -"2008,08,16", -"2008,08,17", -"2008,08,23", -"2008,08,24", -"2008,08,30", -"2008,08,31", -"2008,09,06", -"2008,09,07", -"2008,09,13", -"2008,09,14", -"2008,09,15", -"2008,09,20", -"2008,09,21", -"2008,09,27", -"2008,09,28", -"2008,09,29", -"2008,09,30", -"2008,10,01", -"2008,10,02", -"2008,10,03", -"2008,10,04", -"2008,10,05", -"2008,10,11", -"2008,10,12", -"2008,10,18", -"2008,10,19", -"2008,10,25", -"2008,10,26", -"2008,11,01", -"2008,11,02", -"2008,11,08", -"2008,11,09", -"2008,11,15", -"2008,11,16", -"2008,11,22", -"2008,11,23", -"2008,11,29", -"2008,11,30", -"2008,12,06", -"2008,12,07", -"2008,12,13", -"2008,12,14", -"2008,12,20", -"2008,12,21", -"2008,12,27", -"2008,12,28", -"2009,01,01", -"2009,01,02", -"2009,01,03", -"2009,01,04", -"2009,01,10", -"2009,01,11", -"2009,01,17", -"2009,01,18", -"2009,01,24", -"2009,01,25", -"2009,01,26", -"2009,01,27", -"2009,01,28", -"2009,01,29", -"2009,01,30", -"2009,01,31", -"2009,02,01", -"2009,02,07", -"2009,02,08", -"2009,02,14", -"2009,02,15", -"2009,02,21", -"2009,02,22", -"2009,02,28", -"2009,03,01", -"2009,03,07", -"2009,03,08", -"2009,03,14", -"2009,03,15", -"2009,03,21", -"2009,03,22", -"2009,03,28", -"2009,03,29", -"2009,04,04", -"2009,04,05", -"2009,04,06", -"2009,04,11", -"2009,04,12", -"2009,04,18", -"2009,04,19", -"2009,04,25", -"2009,04,26", -"2009,05,01", -"2009,05,02", -"2009,05,03", -"2009,05,09", -"2009,05,10", -"2009,05,16", -"2009,05,17", -"2009,05,23", -"2009,05,24", -"2009,05,28", -"2009,05,29", -"2009,05,30", -"2009,05,31", -"2009,06,06", -"2009,06,07", -"2009,06,13", -"2009,06,14", -"2009,06,20", -"2009,06,21", -"2009,06,27", -"2009,06,28", -"2009,07,04", -"2009,07,05", -"2009,07,11", -"2009,07,12", -"2009,07,18", -"2009,07,19", -"2009,07,25", -"2009,07,26", -"2009,08,01", -"2009,08,02", -"2009,08,08", -"2009,08,09", -"2009,08,15", -"2009,08,16", -"2009,08,22", -"2009,08,23", -"2009,08,29", -"2009,08,30", -"2009,09,05", -"2009,09,06", -"2009,09,12", -"2009,09,13", -"2009,09,19", -"2009,09,20", -"2009,09,26", -"2009,09,27", -"2009,10,01", -"2009,10,02", -"2009,10,03", -"2009,10,04", -"2009,10,05", -"2009,10,06", -"2009,10,07", -"2009,10,08", -"2009,10,10", -"2009,10,11", -"2009,10,17", -"2009,10,18", -"2009,10,24", -"2009,10,25", -"2009,10,31", -"2009,11,01", -"2009,11,07", -"2009,11,08", -"2009,11,14", -"2009,11,15", -"2009,11,21", -"2009,11,22", -"2009,11,28", -"2009,11,29", -"2009,12,05", -"2009,12,06", -"2009,12,12", -"2009,12,13", -"2009,12,19", -"2009,12,20", -"2009,12,26", -"2009,12,27", -"2010,01,01", -"2010,01,02", -"2010,01,03", -"2010,01,09", -"2010,01,10", -"2010,01,16", -"2010,01,17", -"2010,01,23", -"2010,01,24", -"2010,01,30", -"2010,01,31", -"2010,02,06", -"2010,02,07", -"2010,02,13", -"2010,02,14", -"2010,02,15", -"2010,02,16", -"2010,02,17", -"2010,02,18", -"2010,02,19", -"2010,02,20", -"2010,02,21", -"2010,02,27", -"2010,02,28", -"2010,03,06", -"2010,03,07", -"2010,03,13", -"2010,03,14", -"2010,03,20", -"2010,03,21", -"2010,03,27", -"2010,03,28", -"2010,04,03", -"2010,04,04", -"2010,04,05", -"2010,04,10", -"2010,04,11", -"2010,04,17", -"2010,04,18", -"2010,04,24", -"2010,04,25", -"2010,05,01", -"2010,05,02", -"2010,05,03", -"2010,05,08", -"2010,05,09", -"2010,05,15", -"2010,05,16", -"2010,05,22", -"2010,05,23", -"2010,05,29", -"2010,05,30", -"2010,06,05", -"2010,06,06", -"2010,06,12", -"2010,06,13", -"2010,06,14", -"2010,06,15", -"2010,06,16", -"2010,06,19", -"2010,06,20", -"2010,06,26", -"2010,06,27", -"2010,07,03", -"2010,07,04", -"2010,07,10", -"2010,07,11", -"2010,07,17", -"2010,07,18", -"2010,07,24", -"2010,07,25", -"2010,07,25", -"2010,07,31", -"2010,08,01", -"2010,08,07", -"2010,08,08", -"2010,08,14", -"2010,08,15", -"2010,08,21", -"2010,08,22", -"2010,08,28", -"2010,08,29", -"2010,09,04", -"2010,09,05", -"2010,09,11", -"2010,09,12", -"2010,09,18", -"2010,09,19", -"2010,09,22", -"2010,09,23", -"2010,09,24", -"2010,09,25", -"2010,09,26", -"2010,10,01", -"2010,10,02", -"2010,10,03", -"2010,10,04", -"2010,10,05", -"2010,10,06", -"2010,10,07", -"2010,10,09", -"2010,10,10", -"2010,10,16", -"2010,10,17", -"2010,10,23", -"2010,10,24", -"2010,10,30", -"2010,10,31", -"2010,11,06", -"2010,11,07", -"2010,11,13", -"2010,11,14", -"2010,11,20", -"2010,11,21", -"2010,11,27", -"2010,11,28", -"2010,12,04", -"2010,12,05", -"2010,12,11", -"2010,12,12", -"2010,12,18", -"2010,12,19", -"2010,12,25", -"2010,12,26", -"2011,01,01", -"2011,01,02", -"2011,01,03", -"2011,01,08", -"2011,01,09", -"2011,01,15", -"2011,01,16", -"2011,01,22", -"2011,01,23", -"2011,01,29", -"2011,01,30", -"2011,02,02", -"2011,02,03", -"2011,02,04", -"2011,02,05", -"2011,02,06", -"2011,02,07", -"2011,02,08", -"2011,02,12", -"2011,02,13", -"2011,02,19", -"2011,02,20", -"2011,02,26", -"2011,02,27", -"2011,03,05", -"2011,03,06", -"2011,03,12", -"2011,03,13", -"2011,03,19", -"2011,03,20", -"2011,03,26", -"2011,03,27", -"2011,04,02", -"2011,04,03", -"2011,04,04", -"2011,04,05", -"2011,04,09", -"2011,04,10", -"2011,04,16", -"2011,04,17", -"2011,04,23", -"2011,04,24", -"2011,04,30", -"2011,05,01", -"2011,05,02", -"2011,05,07", -"2011,05,08", -"2011,05,14", -"2011,05,15", -"2011,05,21", -"2011,05,22", -"2011,05,28", -"2011,05,29", -"2011,06,04", -"2011,06,05", -"2011,06,06", -"2011,06,11", -"2011,06,12", -"2011,06,18", -"2011,06,19", -"2011,06,25", -"2011,06,26", -"2011,07,02", -"2011,07,03", -"2011,07,09", -"2011,07,10", -"2011,07,16", -"2011,07,17", -"2011,07,23", -"2011,07,24", -"2011,07,30", -"2011,07,31", -"2011,08,06", -"2011,08,07", -"2011,08,13", -"2011,08,14", -"2011,08,20", -"2011,08,21", -"2011,08,27", -"2011,08,28", -"2011,09,03", -"2011,09,04", -"2011,09,10", -"2011,09,11", -"2011,09,12", -"2011,09,17", -"2011,09,18", -"2011,09,24", -"2011,09,25", -"2011,10,01", -"2011,10,02", -"2011,10,03", -"2011,10,04", -"2011,10,05", -"2011,10,06", -"2011,10,07", -"2011,10,08", -"2011,10,09", -"2011,10,15", -"2011,10,16", -"2011,10,22", -"2011,10,23", -"2011,10,29", -"2011,10,30", -"2011,11,05", -"2011,11,06", -"2011,11,12", -"2011,11,13", -"2011,11,19", -"2011,11,20", -"2011,11,26", -"2011,11,27", -"2011,12,03", -"2011,12,04", -"2011,12,10", -"2011,12,11", -"2011,12,17", -"2011,12,18", -"2011,12,24", -"2011,12,25", -"2011,12,31", -"2012,01,01", -"2012,01,02", -"2012,01,03", -"2012,01,07", -"2012,01,08", -"2012,01,14", -"2012,01,15", -"2012,01,21", -"2012,01,22", -"2012,01,23", -"2012,01,24", -"2012,01,25", -"2012,01,26", -"2012,01,27", -"2012,01,28", -"2012,01,29", -"2012,02,04", -"2012,02,05", -"2012,02,11", -"2012,02,12", -"2012,02,18", -"2012,02,19", -"2012,02,25", -"2012,02,26", -"2012,03,03", -"2012,03,04", -"2012,03,10", -"2012,03,11", -"2012,03,17", -"2012,03,18", -"2012,03,24", -"2012,03,25", -"2012,03,31", -"2012,04,01", -"2012,04,02", -"2012,04,03", -"2012,04,04", -"2012,04,07", -"2012,04,08", -"2012,04,14", -"2012,04,15", -"2012,04,21", -"2012,04,22", -"2012,04,28", -"2012,04,29", -"2012,04,30", -"2012,05,01", -"2012,05,05", -"2012,05,06", -"2012,05,12", -"2012,05,13", -"2012,05,19", -"2012,05,20", -"2012,05,26", -"2012,05,27", -"2012,06,02", -"2012,06,03", -"2012,06,09", -"2012,06,10", -"2012,06,16", -"2012,06,17", -"2012,06,22", -"2012,06,23", -"2012,06,24", -"2012,06,30", -"2012,07,01", -"2012,07,07", -"2012,07,08", -"2012,07,14", -"2012,07,15", -"2012,07,21", -"2012,07,22", -"2012,07,28", -"2012,07,29", -"2012,08,04", -"2012,08,05", -"2012,08,11", -"2012,08,12", -"2012,08,18", -"2012,08,19", -"2012,08,25", -"2012,08,26", -"2012,09,01", -"2012,09,02", -"2012,09,08", -"2012,09,09", -"2012,09,15", -"2012,09,16", -"2012,09,22", -"2012,09,23", -"2012,09,29", -"2012,09,30", -"2012,10,01", -"2012,10,02", -"2012,10,03", -"2012,10,04", -"2012,10,05", -"2012,10,06", -"2012,10,07", -"2012,10,13", -"2012,10,14", -"2012,10,20", -"2012,10,21", -"2012,10,27", -"2012,10,28", -"2012,11,03", -"2012,11,04", -"2012,11,10", -"2012,11,11", -"2012,11,17", -"2012,11,18", -"2012,11,24", -"2012,11,25", -"2012,12,01", -"2012,12,02", -"2012,12,08", -"2012,12,09", -"2012,12,15", -"2012,12,16", -"2012,12,22", -"2012,12,23", -"2012,12,29", -"2012,12,30", -"2013,01,01", -"2013,01,02", -"2013,01,03", -"2013,01,05", -"2013,01,06", -"2013,01,12", -"2013,01,13", -"2013,01,19", -"2013,01,20", -"2013,01,26", -"2013,01,27", -"2013,02,02", -"2013,02,03", -"2013,02,09", -"2013,02,10", -"2013,02,11", -"2013,02,12", -"2013,02,13", -"2013,02,14", -"2013,02,15", -"2013,02,16", -"2013,02,17", -"2013,02,23", -"2013,02,24", -"2013,03,02", -"2013,03,03", -"2013,03,09", -"2013,03,10", -"2013,03,16", -"2013,03,17", -"2013,03,23", -"2013,03,24", -"2013,03,30", -"2013,03,31", -"2013,04,04", -"2013,04,05", -"2013,04,06", -"2013,04,07", -"2013,04,13", -"2013,04,14", -"2013,04,20", -"2013,04,21", -"2013,04,27", -"2013,04,28", -"2013,04,29", -"2013,04,30", -"2013,05,01", -"2013,05,04", -"2013,05,05", -"2013,05,11", -"2013,05,12", -"2013,05,18", -"2013,05,19", -"2013,05,25", -"2013,05,26", -"2013,06,01", -"2013,06,02", -"2013,06,08", -"2013,06,09", -"2013,06,10", -"2013,06,11", -"2013,06,12", -"2013,06,15", -"2013,06,16", -"2013,06,22", -"2013,06,23", -"2013,06,29", -"2013,06,30", -"2013,07,06", -"2013,07,07", -"2013,07,13", -"2013,07,14", -"2013,07,20", -"2013,07,21", -"2013,07,27", -"2013,07,28", -"2013,08,03", -"2013,08,04", -"2013,08,10", -"2013,08,11", -"2013,08,17", -"2013,08,18", -"2013,08,24", -"2013,08,25", -"2013,08,31", -"2013,09,01", -"2013,09,07", -"2013,09,08", -"2013,09,14", -"2013,09,15", -"2013,09,19", -"2013,09,20", -"2013,09,21", -"2013,09,22", -"2013,09,28", -"2013,09,29", -"2013,10,01", -"2013,10,02", -"2013,10,03", -"2013,10,04", -"2013,10,05", -"2013,10,06", -"2013,10,07", -"2013,10,12", -"2013,10,13", -"2013,10,19", -"2013,10,20", -"2013,10,26", -"2013,10,27", -"2013,11,02", -"2013,11,03", -"2013,11,09", -"2013,11,10", -"2013,11,16", -"2013,11,17", -"2013,11,23", -"2013,11,24", -"2013,11,30", -"2013,12,01", -"2013,12,07", -"2013,12,08", -"2013,12,14", -"2013,12,15", -"2013,12,21", -"2013,12,22", -"2013,12,28", -"2013,12,29", -"2014,01,01", -"2014,01,04", -"2014,01,05", -"2014,01,11", -"2014,01,12", -"2014,01,18", -"2014,01,19", -"2014,01,25", -"2014,01,26", -"2014,01,31", -"2014,02,01", -"2014,02,02", -"2014,02,03", -"2014,02,04", -"2014,02,05", -"2014,02,06", -"2014,02,08", -"2014,02,09", -"2014,02,15", -"2014,02,16", -"2014,02,22", -"2014,02,23", -"2014,03,01", -"2014,03,02", -"2014,03,08", -"2014,03,09", -"2014,03,15", -"2014,03,16", -"2014,03,22", -"2014,03,23", -"2014,03,29", -"2014,03,30", -"2014,04,05", -"2014,04,06", -"2014,04,07", -"2014,04,12", -"2014,04,13", -"2014,04,19", -"2014,04,20", -"2014,04,26", -"2014,04,27", -"2014,05,01", -"2014,05,02", -"2014,05,03", -"2014,05,04", -"2014,05,10", -"2014,05,11", -"2014,05,17", -"2014,05,18", -"2014,05,24", -"2014,05,25", -"2014,05,31", -"2014,06,01", -"2014,06,02", -"2014,06,07", -"2014,06,08", -"2014,06,14", -"2014,06,15", -"2014,06,21", -"2014,06,22", -"2014,06,28", -"2014,06,29", -"2014,07,05", -"2014,07,06", -"2014,07,12", -"2014,07,13", -"2014,07,19", -"2014,07,20", -"2014,07,26", -"2014,07,27", -"2014,08,02", -"2014,08,03", -"2014,08,09", -"2014,08,10", -"2014,08,16", -"2014,08,17", -"2014,08,23", -"2014,08,24", -"2014,08,30", -"2014,08,31", -"2014,09,06", -"2014,09,07", -"2014,09,08", -"2014,09,13", -"2014,09,14", -"2014,09,20", -"2014,09,21", -"2014,09,27", -"2014,09,28", -"2014,10,01", -"2014,10,02", -"2014,10,03", -"2014,10,04", -"2014,10,05", -"2014,10,06", -"2014,10,07", -"2014,10,11", -"2014,10,12", -"2014,10,18", -"2014,10,19", -"2014,10,25", -"2014,10,26", -"2014,11,01", -"2014,11,02", -"2014,11,08", -"2014,11,09", -"2014,11,15", -"2014,11,16", -"2014,11,22", -"2014,11,23", -"2014,11,29", -"2014,11,30", -"2014,12,06", -"2014,12,07", -"2014,12,13", -"2014,12,14", -"2014,12,20", -"2014,12,21", -"2014,12,27", -"2014,12,28", -"2015,01,01", -"2015,01,02", -"2015,01,03", -"2015,01,04", -"2015,01,10", -"2015,01,11", -"2015,01,17", -"2015,01,18", -"2015,01,24", -"2015,01,25", -"2015,01,31", -"2015,02,01", -"2015,02,07", -"2015,02,08", -"2015,02,14", -"2015,02,15", -"2015,02,18", -"2015,02,19", -"2015,02,20", -"2015,02,21", -"2015,02,22", -"2015,02,23", -"2015,02,24", -"2015,02,28", -"2015,03,01", -"2015,03,07", -"2015,03,08", -"2015,03,14", -"2015,03,15", -"2015,03,21", -"2015,03,22", -"2015,03,28", -"2015,03,29", -"2015,04,04", -"2015,04,05", -"2015,04,06", -"2015,04,11", -"2015,04,12", -"2015,04,18", -"2015,04,19", -"2015,04,25", -"2015,04,26", -"2015,05,01", -"2015,05,02", -"2015,05,03", -"2015,05,09", -"2015,05,10", -"2015,05,16", -"2015,05,17", -"2015,05,23", -"2015,05,24", -"2015,05,30", -"2015,05,31", -"2015,06,06", -"2015,06,07", -"2015,06,13", -"2015,06,14", -"2015,06,20", -"2015,06,21", -"2015,06,22", -"2015,06,27", -"2015,06,28", -"2015,07,04", -"2015,07,05", -"2015,07,11", -"2015,07,12", -"2015,07,18", -"2015,07,19", -"2015,07,25", -"2015,07,26", -"2015,08,01", -"2015,08,02", -"2015,08,08", -"2015,08,09", -"2015,08,15", -"2015,08,16", -"2015,08,22", -"2015,08,23", -"2015,08,29", -"2015,08,30", -"2015,09,03", -"2015,09,04", -"2015,09,05", -"2015,09,06", -"2015,09,12", -"2015,09,13", -"2015,09,19", -"2015,09,20", -"2015,09,26", -"2015,09,27", -"2015,10,01", -"2015,10,02", -"2015,10,03", -"2015,10,04", -"2015,10,05", -"2015,10,06", -"2015,10,07", -"2015,10,10", -"2015,10,11", -"2015,10,17", -"2015,10,18", -"2015,10,24", -"2015,10,25", -"2015,10,31", -"2015,11,01", -"2015,11,07", -"2015,11,08", -"2015,11,10", -"2015,11,14", -"2015,11,15", -"2015,11,21", -"2015,11,22", -"2015,11,28", -"2015,11,29", -"2015,12,05", -"2015,12,06", -"2015,12,12", -"2015,12,13", -"2015,12,19", -"2015,12,20", -"2015,12,26", -"2015,12,27", -"2016,01,01", -"2016,01,02", -"2016,01,03", -"2016,01,09", -"2016,01,10", -"2016,01,16", -"2016,01,17", -"2016,01,23", -"2016,01,24", -"2016,01,30", -"2016,01,31", -"2016,02,06", -"2016,02,07", -"2016,02,08", -"2016,02,09", -"2016,02,10", -"2016,02,11", -"2016,02,12", -"2016,02,13", -"2016,02,14", -"2016,02,20", -"2016,02,21", -"2016,02,27", -"2016,02,28", -"2016,03,05", -"2016,03,06", -"2016,03,12", -"2016,03,13", -"2016,03,19", -"2016,03,20", -"2016,03,26", -"2016,03,27", -"2016,04,02", -"2016,04,03", -"2016,04,04", -"2016,04,09", -"2016,04,10", -"2016,04,16", -"2016,04,17", -"2016,04,23", -"2016,04,24", -"2016,04,30", -"2016,05,01", -"2016,05,02", -"2016,05,07", -"2016,05,08", -"2016,05,14", -"2016,05,15", -"2016,05,21", -"2016,05,22", -"2016,05,28", -"2016,05,29", -"2016,06,04", -"2016,06,05", -"2016,06,09", -"2016,06,10", -"2016,06,11", -"2016,06,12", -"2016,06,18", -"2016,06,19", -"2016,06,25", -"2016,06,26", -"2016,07,02", -"2016,07,03", -"2016,07,09", -"2016,07,10", -"2016,07,16", -"2016,07,17", -"2016,07,23", -"2016,07,24", -"2016,07,30", -"2016,07,31", -"2016,08,06", -"2016,08,07", -"2016,08,13", -"2016,08,14", -"2016,08,20", -"2016,08,21", -"2016,08,27", -"2016,08,28", -"2016,09,03", -"2016,09,04", -"2016,09,10", -"2016,09,11", -"2016,09,15", -"2016,09,16", -"2016,09,17", -"2016,09,18", -"2016,09,24", -"2016,09,25", -"2016,10,01", -"2016,10,02", -"2016,10,03", -"2016,10,04", -"2016,10,05", -"2016,10,06", -"2016,10,07", -"2016,10,08", -"2016,10,09", -"2016,10,15", -"2016,10,16", -"2016,10,22", -"2016,10,23", -"2016,10,29", -"2016,10,30", -"2016,11,05", -"2016,11,06", -"2016,11,12", -"2016,11,13", -"2016,11,19", -"2016,11,20", -"2016,11,26", -"2016,11,27", -"2016,12,03", -"2016,12,04", -"2016,12,10", -"2016,12,11", -"2016,12,17", -"2016,12,18", -"2016,12,24", -"2016,12,25", -"2016,12,31", -"2017,01,01", -"2017,01,02", -"2017,01,07", -"2017,01,08", -"2017,01,14", -"2017,01,15", -"2017,01,21", -"2017,01,22", -"2017,01,27", -"2017,01,28", -"2017,01,29", -"2017,01,30", -"2017,01,31", -"2017,02,01", -"2017,02,02", -"2017,02,04", -"2017,02,05", -"2017,02,11", -"2017,02,12", -"2017,02,18", -"2017,02,19", -"2017,02,25", -"2017,02,26", -"2017,03,04", -"2017,03,05", -"2017,03,11", -"2017,03,12", -"2017,03,18", -"2017,03,19", -"2017,03,25", -"2017,03,26", -"2017,04,01", -"2017,04,02", -"2017,04,03", -"2017,04,04", -"2017,04,08", -"2017,04,09", -"2017,04,15", -"2017,04,16", -"2017,04,22", -"2017,04,23", -"2017,04,29", -"2017,04,30", -"2017,05,01", -"2017,05,06", -"2017,05,07", -"2017,05,13", -"2017,05,14", -"2017,05,20", -"2017,05,21", -"2017,05,27", -"2017,05,28", -"2017,05,29", -"2017,05,30", -"2017,06,03", -"2017,06,04", -"2017,06,10", -"2017,06,11", -"2017,06,17", -"2017,06,18", -"2017,06,24", -"2017,06,25", -"2017,07,01", -"2017,07,02", -"2017,07,08", -"2017,07,09", -"2017,07,15", -"2017,07,16", -"2017,07,22", -"2017,07,23", -"2017,07,29", -"2017,07,30", -"2017,08,05", -"2017,08,06", -"2017,08,12", -"2017,08,13", -"2017,08,19", -"2017,08,20", -"2017,08,26", -"2017,08,27", -"2017,09,02", -"2017,09,03", -"2017,09,09", -"2017,09,10", -"2017,09,16", -"2017,09,17", -"2017,09,23", -"2017,09,24", -"2017,09,30", -"2017,10,01", -"2017,10,02", -"2017,10,03", -"2017,10,04", -"2017,10,05", -"2017,10,06", -"2017,10,07", -"2017,10,08", -"2017,10,14", -"2017,10,15", -"2017,10,21", -"2017,10,22", -"2017,10,28", -"2017,10,29", -"2017,11,04", -"2017,11,05", -"2017,11,11", -"2017,11,12", -"2017,11,18", -"2017,11,19", -"2017,11,25", -"2017,11,26", -"2017,12,02", -"2017,12,03", -"2017,12,09", -"2017,12,10", -"2017,12,16", -"2017,12,17", -"2017,12,23", -"2017,12,24", -"2017,12,30", -"2017,12,31", -"2018,01,01", -"2018,01,06", -"2018,01,07", -"2018,01,13", -"2018,01,14", -"2018,01,20", -"2018,01,21", -"2018,01,27", -"2018,01,28", -"2018,02,03", -"2018,02,04", -"2018,02,10", -"2018,02,11", -"2018,02,15", -"2018,02,16", -"2018,02,17", -"2018,02,18", -"2018,02,19", -"2018,02,20", -"2018,02,21", -"2018,02,24", -"2018,02,25", -"2018,03,03", -"2018,03,04", -"2018,03,10", -"2018,03,11", -"2018,03,17", -"2018,03,18", -"2018,03,24", -"2018,03,25", -"2018,03,31", -"2018,04,01", -"2018,04,05", -"2018,04,06", -"2018,04,07", -"2018,04,08", -"2018,04,14", -"2018,04,15", -"2018,04,21", -"2018,04,22", -"2018,04,28", -"2018,04,29", -"2018,04,30", -"2018,05,01", -"2018,05,05", -"2018,05,06", -"2018,05,12", -"2018,05,13", -"2018,05,19", -"2018,05,20", -"2018,05,26", -"2018,05,27", -"2018,06,02", -"2018,06,03", -"2018,06,09", -"2018,06,10", -"2018,06,16", -"2018,06,17", -"2018,06,18", -"2018,06,23", -"2018,06,24", -"2018,06,30", -"2018,07,01", -"2018,07,07", -"2018,07,08", -"2018,07,14", -"2018,07,15", -"2018,07,21", -"2018,07,22", -"2018,07,28", -"2018,07,29", -"2018,08,04", -"2018,08,05", -"2018,08,11", -"2018,08,12", -"2018,08,18", -"2018,08,19", -"2018,08,25", -"2018,08,26", -"2018,09,01", -"2018,09,02", -"2018,09,08", -"2018,09,09", -"2018,09,15", -"2018,09,16", -"2018,09,22", -"2018,09,23", -"2018,09,24", -"2018,09,29", -"2018,09,30", -"2018,10,01", -"2018,10,02", -"2018,10,03", -"2018,10,04", -"2018,10,05", -"2018,10,06", -"2018,10,07", -"2018,10,13", -"2018,10,14", -"2018,10,20", -"2018,10,21", -"2018,10,27", -"2018,10,28", -"2018,11,03", -"2018,11,04", -"2018,11,10", -"2018,11,11", -"2018,11,17", -"2018,11,18", -"2018,11,24", -"2018,11,25", -"2018,12,01", -"2018,12,02", -"2018,12,08", -"2018,12,09", -"2018,12,15", -"2018,12,16", -"2018,12,22", -"2018,12,23", -"2018,12,29", -"2018,12,30", -"2018,12,31", -"2019,01,01", -"2019,01,05", -"2019,01,06", -"2019,01,12", -"2019,01,13", -"2019,01,19", -"2019,01,20", -"2019,01,26", -"2019,01,27", -"2019,02,02", -"2019,02,03", -"2019,02,04", -"2019,02,05", -"2019,02,06", -"2019,02,07", -"2019,02,08", -"2019,02,09", -"2019,02,10", -"2019,02,16", -"2019,02,17", -"2019,02,23", -"2019,02,24", -"2019,03,02", -"2019,03,03", -"2019,03,09", -"2019,03,10", -"2019,03,16", -"2019,03,17", -"2019,03,23", -"2019,03,24", -"2019,03,30", -"2019,03,31", -"2019,04,05", -"2019,04,06", -"2019,04,07", -"2019,04,13", -"2019,04,14", -"2019,04,20", -"2019,04,21", -"2019,04,27", -"2019,04,28", -"2019,05,01", -"2019,05,04", -"2019,05,05", -"2019,05,11", -"2019,05,12", -"2019,05,18", -"2019,05,19", -"2019,05,25", -"2019,05,26", -"2019,06,01", -"2019,06,02", -"2019,06,07", -"2019,06,08", -"2019,06,09", -"2019,06,15", -"2019,06,16", -"2019,06,22", -"2019,06,23", -"2019,06,29", -"2019,06,30", -"2019,07,06", -"2019,07,07", -"2019,07,13", -"2019,07,14", -"2019,07,20", -"2019,07,21", -"2019,07,27", -"2019,07,28", -"2019,08,03", -"2019,08,04", -"2019,08,10", -"2019,08,11", -"2019,08,17", -"2019,08,18", -"2019,08,24", -"2019,08,25", -"2019,08,31", -"2019,09,01", -"2019,09,07", -"2019,09,08", -"2019,09,13", -"2019,09,14", -"2019,09,15", -"2019,09,21", -"2019,09,22", -"2019,09,28", -"2019,09,29", -"2019,10,01", -"2019,10,02", -"2019,10,03", -"2019,10,04", -"2019,10,05", -"2019,10,06", -"2019,10,07", -"2019,10,12", -"2019,10,13", -"2019,10,19", -"2019,10,20", -"2019,10,26", -"2019,10,27", -"2019,11,02", -"2019,11,03", -"2019,11,09", -"2019,11,10", -"2019,11,16", -"2019,11,17", -"2019,11,23", -"2019,11,24", -"2019,11,30", -"2019,12,01", -"2019,12,07", -"2019,12,08", -"2019,12,14", -"2019,12,15", -"2019,12,21", -"2019,12,22", -"2019,12,28", -"2019,12,29", -"2020,01,01", -"2020,01,04", -"2020,01,05", -"2020,01,11", -"2020,01,12", -"2020,01,18", -"2020,01,19", -"2020,01,24", -"2020,01,25", -"2020,01,26", -"2020,01,27", -"2020,01,28", -"2020,01,29", -"2020,01,30", -"2020,02,01", -"2020,02,02", -"2020,02,08", -"2020,02,09", -"2020,02,15", -"2020,02,16", -"2020,02,22", -"2020,02,23", -"2020,02,29", -"2020,03,01", -"2020,03,07", -"2020,03,08", -"2020,03,14", -"2020,03,15", -"2020,03,21", -"2020,03,22", -"2020,03,28", -"2020,03,29", -"2020,04,04", -"2020,04,05", -"2020,04,11", -"2020,04,12", -"2020,04,18", -"2020,04,19", -"2020,04,25", -"2020,04,26", -"2020,05,01", -"2020,05,02", -"2020,05,03", -"2020,05,09", -"2020,05,10", -"2020,05,16", -"2020,05,17", -"2020,05,23", -"2020,05,24", -"2020,05,30", -"2020,05,31", -"2020,06,06", -"2020,06,07", -"2020,06,13", -"2020,06,14", -"2020,06,20", -"2020,06,21", -"2020,06,25", -"2020,06,27", -"2020,06,28", -"2020,07,04", -"2020,07,05", -"2020,07,11", -"2020,07,12", -"2020,07,18", -"2020,07,19", -"2020,07,25", -"2020,07,26", -"2020,08,01", -"2020,08,02", -"2020,08,08", -"2020,08,09", -"2020,08,15", -"2020,08,16", -"2020,08,22", -"2020,08,23", -"2020,08,29", -"2020,08,30", -"2020,09,05", -"2020,09,06", -"2020,09,12", -"2020,09,13", -"2020,09,19", -"2020,09,20", -"2020,09,26", -"2020,09,27", -"2020,10,01", -"2020,10,02", -"2020,10,03", -"2020,10,04", -"2020,10,05", -"2020,10,06", -"2020,10,07", -"2020,10,10", -"2020,10,11", -"2020,10,17", -"2020,10,18", -"2020,10,24", -"2020,10,25", -"2020,10,31", -"2020,11,01", -"2020,11,07", -"2020,11,08", -"2020,11,14", -"2020,11,15", -"2020,11,21", -"2020,11,22", -"2020,11,28", -"2020,11,29", -"2020,12,05", -"2020,12,06", -"2020,12,12", -"2020,12,13", -"2020,12,19", -"2020,12,20", -"2020,12,26", -"2020,12,27", -"2021,01,01", -"2021,01,02", -"2021,01,03", -"2021,01,09", -"2021,01,10", -"2021,01,12", -"2021,01,16", -"2021,01,17", -"2021,01,23", -"2021,01,24", -"2021,01,30", -"2021,01,31", -"2021,02,06", -"2021,02,07", -"2021,02,11", -"2021,02,13", -"2021,02,14", -"2021,02,15", -"2021,02,16", -"2021,02,17", -"2021,02,20", -"2021,02,21", -"2021,02,27", -"2021,02,28", -"2021,03,06", -"2021,03,07", -"2021,03,13", -"2021,03,14", -"2021,03,20", -"2021,03,21", -"2021,03,27", -"2021,03,28", -"2021,04,03", -"2021,04,04", -"2021,04,10", -"2021,04,11", -"2021,04,17", -"2021,04,18", -"2021,04,24", -"2021,04,25", -"2021,05,01", -"2021,05,02", -"2021,05,08", -"2021,05,09", -"2021,05,15", -"2021,05,16", -"2021,05,22", -"2021,05,23", -"2021,05,29", -"2021,05,30", -"2021,06,05", -"2021,06,06", -"2021,06,12", -"2021,06,13", -"2021,06,14", -"2021,06,19", -"2021,06,20", -"2021,06,26", -"2021,06,27", -"2021,07,03", -"2021,07,04", -"2021,07,10", -"2021,07,11", -"2021,07,17", -"2021,07,18", -"2021,07,24", -"2021,07,25", -"2021,07,31", -"2021,08,01", -"2021,08,07", -"2021,08,08", -"2021,08,14", -"2021,08,15", -"2021,08,21", -"2021,08,22", -"2021,08,28", -"2021,08,29", -"2021,09,04", -"2021,09,05", -"2021,09,11", -"2021,09,12", -"2021,09,18", -"2021,09,19", -"2021,09,21", -"2021,09,25", -"2021,09,26", -"2021,10,01", -"2021,10,02", -"2021,10,03", -"2021,10,04", -"2021,10,05", -"2021,10,06", -"2021,10,07", -"2021,10,09", -"2021,10,10", -"2021,10,16", -"2021,10,17", -"2021,10,23", -"2021,10,24", -"2021,10,30", -"2021,10,31", -"2021,11,06", -"2021,11,07", -"2021,11,13", -"2021,11,14", -"2021,11,20", -"2021,11,21", -"2021,11,27", -"2021,11,28", -"2021,12,04", -"2021,12,05", -"2021,12,11", -"2021,12,12", -"2021,12,18", -"2021,12,19", -"2021,12,25", -"2021,12,26", -"2022,01,01", -"2022,01,02", -"2022,01,08", -"2022,01,09", -"2022,01,15", -"2022,01,16", -"2022,01,22", -"2022,01,23", -"2022,01,29", -"2022,01,30", -"2022,01,31", -"2022,02,01", -"2022,02,02", -"2022,02,03", -"2022,02,04", -"2022,02,05", -"2022,02,06", -"2022,02,12", -"2022,02,13", -"2022,02,19", -"2022,02,20", -"2022,02,26", -"2022,02,27", -"2022,03,05", -"2022,03,06", -"2022,03,12", -"2022,03,13", -"2022,03,19", -"2022,03,20", -"2022,03,26", -"2022,03,27", -"2022,04,02", -"2022,04,03", -"2022,04,05", -"2022,04,09", -"2022,04,10", -"2022,04,16", -"2022,04,17", -"2022,04,23", -"2022,04,24", -"2022,04,30", -"2022,05,01", -"2022,05,07", -"2022,05,08", -"2022,05,14", -"2022,05,15", -"2022,05,21", -"2022,05,22", -"2022,05,28", -"2022,05,29", -"2022,06,03", -"2022,06,04", -"2022,06,05", -"2022,06,11", -"2022,06,12", -"2022,06,18", -"2022,06,19", -"2022,06,25", -"2022,06,26", -"2022,07,02", -"2022,07,03", -"2022,07,09", -"2022,07,10", -"2022,07,16", -"2022,07,17", -"2022,07,23", -"2022,07,24", -"2022,07,30", -"2022,07,31", -"2022,08,06", -"2022,08,07", -"2022,08,13", -"2022,08,14", -"2022,08,20", -"2022,08,21", -"2022,08,27", -"2022,08,28", -"2022,09,03", -"2022,09,04", -"2022,09,10", -"2022,09,11", -"2022,09,17", -"2022,09,18", -"2022,09,24", -"2022,09,25", -"2022,10,01", -"2022,10,02", -"2022,10,03", -"2022,10,04", -"2022,10,05", -"2022,10,06", -"2022,10,07", -"2022,10,08", -"2022,10,09", -"2022,10,15", -"2022,10,16", -"2022,10,22", -"2022,10,23", -"2022,10,29", -"2022,10,30", -"2022,11,05", -"2022,11,06", -"2022,11,12", -"2022,11,13", -"2022,11,19", -"2022,11,20", -"2022,11,26", -"2022,11,27", -"2022,12,03", -"2022,12,04", -"2022,12,10", -"2022,12,11", -"2022,12,17", -"2022,12,18", -"2022,12,24", -"2022,12,25", -"2022,12,31", -"2023,01,01", -"2023,01,07", -"2023,01,08", -"2023,01,14", -"2023,01,15", -"2023,01,21", -"2023,01,22", -"2023,01,23", -"2023,01,24", -"2023,01,25", -"2023,01,26", -"2023,01,27", -"2023,01,28", -"2023,01,29", -"2023,02,04", -"2023,02,05", -"2023,02,11", -"2023,02,12", -"2023,02,18", -"2023,02,19", -"2023,02,25", -"2023,02,26", -"2023,03,04", -"2023,03,05", -"2023,03,11", -"2023,03,12", -"2023,03,18", -"2023,03,19", -"2023,03,25", -"2023,03,26", -"2023,04,01", -"2023,04,02", -"2023,04,05", -"2023,04,08", -"2023,04,09", -"2023,04,15", -"2023,04,16", -"2023,04,22", -"2023,04,23", -"2023,04,29", -"2023,04,30", -"2023,05,01", -"2023,05,06", -"2023,05,07", -"2023,05,13", -"2023,05,14", -"2023,05,20", -"2023,05,21", -"2023,05,27", -"2023,05,28", -"2023,06,03", -"2023,06,04", -"2023,06,10", -"2023,06,11", -"2023,06,17", -"2023,06,18", -"2023,06,22", -"2023,06,24", -"2023,06,25", -"2023,07,01", -"2023,07,02", -"2023,07,08", -"2023,07,09", -"2023,07,15", -"2023,07,16", -"2023,07,22", -"2023,07,23", -"2023,07,29", -"2023,07,30", -"2023,08,05", -"2023,08,06", -"2023,08,12", -"2023,08,13", -"2023,08,19", -"2023,08,20", -"2023,08,26", -"2023,08,27", -"2023,09,02", -"2023,09,03", -"2023,09,09", -"2023,09,10", -"2023,09,16", -"2023,09,17", -"2023,09,23", -"2023,09,24", -"2023,09,29", -"2023,09,30", -"2023,10,01", -"2023,10,02", -"2023,10,03", -"2023,10,04", -"2023,10,05", -"2023,10,06", -"2023,10,07", -"2023,10,08", -"2023,10,14", -"2023,10,15", -"2023,10,21", -"2023,10,22", -"2023,10,28", -"2023,10,29", -"2023,11,04", -"2023,11,05", -"2023,11,11", -"2023,11,12", -"2023,11,18", -"2023,11,19", -"2023,11,25", -"2023,11,26", -"2023,12,02", -"2023,12,03", -"2023,12,09", -"2023,12,10", -"2023,12,16", -"2023,12,17", -"2023,12,23", -"2023,12,24", -"2023,12,30", -"2023,12,31", -"2024,01,01", -"2024,01,06", -"2024,01,07", -"2024,01,13", -"2024,01,14", -"2024,01,20", -"2024,01,21", -"2024,01,27", -"2024,01,28", -"2024,02,03", -"2024,02,04", -"2024,02,09", -"2024,02,10", -"2024,02,11", -"2024,02,12", -"2024,02,13", -"2024,02,14", -"2024,02,15", -"2024,02,17", -"2024,02,18", -"2024,02,24", -"2024,02,25", -"2024,03,02", -"2024,03,03", -"2024,03,09", -"2024,03,10", -"2024,03,16", -"2024,03,17", -"2024,03,23", -"2024,03,24", -"2024,03,30", -"2024,03,31", -"2024,04,04", -"2024,04,06", -"2024,04,07", -"2024,04,13", -"2024,04,14", -"2024,04,20", -"2024,04,21", -"2024,04,27", -"2024,04,28", -"2024,05,01", -"2024,05,04", -"2024,05,05", -"2024,05,11", -"2024,05,12", -"2024,05,18", -"2024,05,19", -"2024,05,25", -"2024,05,26", -"2024,06,01", -"2024,06,02", -"2024,06,08", -"2024,06,09", -"2024,06,10", -"2024,06,15", -"2024,06,16", -"2024,06,22", -"2024,06,23", -"2024,06,29", -"2024,06,30", -"2024,07,06", -"2024,07,07", -"2024,07,13", -"2024,07,14", -"2024,07,20", -"2024,07,21", -"2024,07,27", -"2024,07,28", -"2024,08,03", -"2024,08,04", -"2024,08,10", -"2024,08,11", -"2024,08,17", -"2024,08,18", -"2024,08,24", -"2024,08,25", -"2024,08,31", -"2024,09,01", -"2024,09,07", -"2024,09,08", -"2024,09,14", -"2024,09,15", -"2024,09,17", -"2024,09,21", -"2024,09,22", -"2024,09,28", -"2024,09,29", -"2024,10,01", -"2024,10,02", -"2024,10,03", -"2024,10,04", -"2024,10,05", -"2024,10,06", -"2024,10,07", -"2024,10,12", -"2024,10,13", -"2024,10,19", -"2024,10,20", -"2024,10,26", -"2024,10,27", -"2024,11,02", -"2024,11,03", -"2024,11,09", -"2024,11,10", -"2024,11,16", -"2024,11,17", -"2024,11,23", -"2024,11,24", -"2024,11,30", -"2024,12,01", -"2024,12,07", -"2024,12,08", -"2024,12,14", -"2024,12,15", -"2024,12,21", -"2024,12,22", -"2024,12,28", -"2024,12,29", -"2025,01,01", -"2025,01,04", -"2025,01,05", -"2025,01,11", -"2025,01,12", -"2025,01,18", -"2025,01,19", -"2025,01,25", -"2025,01,26", -"2025,01,28", -"2025,01,29", -"2025,01,30", -"2025,01,31", -"2025,02,01", -"2025,02,02", -"2025,02,03", -"2025,02,08", -"2025,02,09", -"2025,02,15", -"2025,02,16", -"2025,02,22", -"2025,02,23", -"2025,03,01", -"2025,03,02", -"2025,03,08", -"2025,03,09", -"2025,03,15", -"2025,03,16", -"2025,03,22", -"2025,03,23", -"2025,03,29", -"2025,03,30", -"2025,04,04", -"2025,04,05", -"2025,04,06", -"2025,04,12", -"2025,04,13", -"2025,04,19", -"2025,04,20", -"2025,04,26", -"2025,04,27", -"2025,05,01", -"2025,05,03", -"2025,05,04", -"2025,05,10", -"2025,05,11", -"2025,05,17", -"2025,05,18", -"2025,05,24", -"2025,05,25", -"2025,05,31", -"2025,06,01", -"2025,06,07", -"2025,06,08", -"2025,06,14", -"2025,06,15", -"2025,06,21", -"2025,06,22", -"2025,06,28", -"2025,06,29", -"2025,07,05", -"2025,07,06", -"2025,07,12", -"2025,07,13", -"2025,07,19", -"2025,07,20", -"2025,07,26", -"2025,07,27", -"2025,08,02", -"2025,08,03", -"2025,08,09", -"2025,08,10", -"2025,08,16", -"2025,08,17", -"2025,08,23", -"2025,08,24", -"2025,08,30", -"2025,08,31", -"2025,09,06", -"2025,09,07", -"2025,09,13", -"2025,09,14", -"2025,09,20", -"2025,09,21", -"2025,09,27", -"2025,09,28", -"2025,10,01", -"2025,10,02", -"2025,10,03", -"2025,10,04", -"2025,10,05", -"2025,10,06", -"2025,10,07", -"2025,10,11", -"2025,10,12", -"2025,10,18", -"2025,10,19", -"2025,10,25", -"2025,10,26", -"2025,11,01", -"2025,11,02", -"2025,11,08", -"2025,11,09", -"2025,11,15", -"2025,11,16", -"2025,11,22", -"2025,11,23", -"2025,11,29", -"2025,11,30", -"2025,12,06", -"2025,12,07", -"2025,12,13", -"2025,12,14", -"2025,12,20", -"2025,12,21", -"2025,12,27", -"2025,12,28", -"2026,01,01", -"2026,01,03", -"2026,01,04", -"2026,01,10", -"2026,01,11", -"2026,01,17", -"2026,01,18", -"2026,01,24", -"2026,01,25", -"2026,01,31", -"2026,02,01", -"2026,02,07", -"2026,02,08", -"2026,02,14", -"2026,02,15", -"2026,02,16", -"2026,02,17", -"2026,02,18", -"2026,02,19", -"2026,02,20", -"2026,02,21", -"2026,02,22", -"2026,02,28", -"2026,03,01", -"2026,03,07", -"2026,03,08", -"2026,03,14", -"2026,03,15", -"2026,03,21", -"2026,03,22", -"2026,03,28", -"2026,03,29", -"2026,04,04", -"2026,04,05", -"2026,04,11", -"2026,04,12", -"2026,04,18", -"2026,04,19", -"2026,04,25", -"2026,04,26", -"2026,05,01", -"2026,05,02", -"2026,05,03", -"2026,05,09", -"2026,05,10", -"2026,05,16", -"2026,05,17", -"2026,05,23", -"2026,05,24", -"2026,05,30", -"2026,05,31", -"2026,06,06", -"2026,06,07", -"2026,06,13", -"2026,06,14", -"2026,06,19", -"2026,06,20", -"2026,06,21", -"2026,06,27", -"2026,06,28", -"2026,07,04", -"2026,07,05", -"2026,07,11", -"2026,07,12", -"2026,07,18", -"2026,07,19", -"2026,07,25", -"2026,07,26", -"2026,08,01", -"2026,08,02", -"2026,08,08", -"2026,08,09", -"2026,08,15", -"2026,08,16", -"2026,08,22", -"2026,08,23", -"2026,08,29", -"2026,08,30", -"2026,09,05", -"2026,09,06", -"2026,09,12", -"2026,09,13", -"2026,09,19", -"2026,09,20", -"2026,09,25", -"2026,09,26", -"2026,09,27", -"2026,10,01", -"2026,10,02", -"2026,10,03", -"2026,10,04", -"2026,10,05", -"2026,10,06", -"2026,10,07", -"2026,10,10", -"2026,10,11", -"2026,10,17", -"2026,10,18", -"2026,10,24", -"2026,10,25", -"2026,10,31", -"2026,11,01", -"2026,11,07", -"2026,11,08", -"2026,11,14", -"2026,11,15", -"2026,11,21", -"2026,11,22", -"2026,11,28", -"2026,11,29", -"2026,12,05", -"2026,12,06", -"2026,12,12", -"2026,12,13", -"2026,12,19", -"2026,12,20", -"2026,12,26", -"2026,12,27", -"2027,01,01", -"2027,01,02", -"2027,01,03", -"2027,01,09", -"2027,01,10", -"2027,01,16", -"2027,01,17", -"2027,01,23", -"2027,01,24", -"2027,01,30", -"2027,01,31", -"2027,02,05", -"2027,02,06", -"2027,02,07", -"2027,02,08", -"2027,02,09", -"2027,02,10", -"2027,02,11", -"2027,02,13", -"2027,02,14", -"2027,02,20", -"2027,02,21", -"2027,02,27", -"2027,02,28", -"2027,03,06", -"2027,03,07", -"2027,03,13", -"2027,03,14", -"2027,03,20", -"2027,03,21", -"2027,03,27", -"2027,03,28", -"2027,04,03", -"2027,04,04", -"2027,04,05", -"2027,04,10", -"2027,04,11", -"2027,04,17", -"2027,04,18", -"2027,04,24", -"2027,04,25", -"2027,05,01", -"2027,05,02", -"2027,05,08", -"2027,05,09", -"2027,05,15", -"2027,05,16", -"2027,05,22", -"2027,05,23", -"2027,05,29", -"2027,05,30", -"2027,06,05", -"2027,06,06", -"2027,06,09", -"2027,06,12", -"2027,06,13", -"2027,06,19", -"2027,06,20", -"2027,06,26", -"2027,06,27", -"2027,07,03", -"2027,07,04", -"2027,07,10", -"2027,07,11", -"2027,07,17", -"2027,07,18", -"2027,07,24", -"2027,07,25", -"2027,07,31", -"2027,08,01", -"2027,08,07", -"2027,08,08", -"2027,08,14", -"2027,08,15", -"2027,08,21", -"2027,08,22", -"2027,08,28", -"2027,08,29", -"2027,09,04", -"2027,09,05", -"2027,09,11", -"2027,09,12", -"2027,09,15", -"2027,09,18", -"2027,09,19", -"2027,09,25", -"2027,09,26", -"2027,10,01", -"2027,10,02", -"2027,10,03", -"2027,10,04", -"2027,10,05", -"2027,10,06", -"2027,10,07", -"2027,10,09", -"2027,10,10", -"2027,10,16", -"2027,10,17", -"2027,10,23", -"2027,10,24", -"2027,10,30", -"2027,10,31", -"2027,11,06", -"2027,11,07", -"2027,11,13", -"2027,11,14", -"2027,11,20", -"2027,11,21", -"2027,11,27", -"2027,11,28", -"2027,12,04", -"2027,12,05", -"2027,12,11", -"2027,12,12", -"2027,12,18", -"2027,12,19", -"2027,12,25", -"2027,12,26", -"2028,01,01", -"2028,01,02", -"2028,01,08", -"2028,01,09", -"2028,01,15", -"2028,01,16", -"2028,01,22", -"2028,01,23", -"2028,01,25", -"2028,01,26", -"2028,01,27", -"2028,01,28", -"2028,01,29", -"2028,01,30", -"2028,01,31", -"2028,02,05", -"2028,02,06", -"2028,02,12", -"2028,02,13", -"2028,02,19", -"2028,02,20", -"2028,02,26", -"2028,02,27", -"2028,03,04", -"2028,03,05", -"2028,03,11", -"2028,03,12", -"2028,03,18", -"2028,03,19", -"2028,03,25", -"2028,03,26", -"2028,04,01", -"2028,04,02", -"2028,04,04", -"2028,04,08", -"2028,04,09", -"2028,04,15", -"2028,04,16", -"2028,04,22", -"2028,04,23", -"2028,04,29", -"2028,04,30", -"2028,05,01", -"2028,05,06", -"2028,05,07", -"2028,05,13", -"2028,05,14", -"2028,05,20", -"2028,05,21", -"2028,05,27", -"2028,05,28", -"2028,06,03", -"2028,06,04", -"2028,06,10", -"2028,06,11", -"2028,06,17", -"2028,06,18", -"2028,06,24", -"2028,06,25", -"2028,07,01", -"2028,07,02", -"2028,07,08", -"2028,07,09", -"2028,07,15", -"2028,07,16", -"2028,07,22", -"2028,07,23", -"2028,07,29", -"2028,07,30", -"2028,08,05", -"2028,08,06", -"2028,08,12", -"2028,08,13", -"2028,08,19", -"2028,08,20", -"2028,08,26", -"2028,08,27", -"2028,09,02", -"2028,09,03", -"2028,09,09", -"2028,09,10", -"2028,09,16", -"2028,09,17", -"2028,09,23", -"2028,09,24", -"2028,09,30", -"2028,10,01", -"2028,10,02", -"2028,10,03", -"2028,10,04", -"2028,10,05", -"2028,10,06", -"2028,10,07", -"2028,10,08", -"2028,10,14", -"2028,10,15", -"2028,10,21", -"2028,10,22", -"2028,10,28", -"2028,10,29", -"2028,11,04", -"2028,11,05", -"2028,11,11", -"2028,11,12", -"2028,11,18", -"2028,11,19", -"2028,11,25", -"2028,11,26", -"2028,12,02", -"2028,12,03", -"2028,12,09", -"2028,12,10", -"2028,12,16", -"2028,12,17", -"2028,12,23", -"2028,12,24", -"2028,12,30", -"2028,12,31", -"2029,01,01", -"2029,01,06", -"2029,01,07", -"2029,01,13", -"2029,01,14", -"2029,01,20", -"2029,01,21", -"2029,01,27", -"2029,01,28", -"2029,02,03", -"2029,02,04", -"2029,02,10", -"2029,02,11", -"2029,02,12", -"2029,02,13", -"2029,02,14", -"2029,02,15", -"2029,02,16", -"2029,02,17", -"2029,02,18", -"2029,02,24", -"2029,02,25", -"2029,03,03", -"2029,03,04", -"2029,03,10", -"2029,03,11", -"2029,03,17", -"2029,03,18", -"2029,03,24", -"2029,03,25", -"2029,03,31", -"2029,04,01", -"2029,04,04", -"2029,04,07", -"2029,04,08", -"2029,04,14", -"2029,04,15", -"2029,04,21", -"2029,04,22", -"2029,04,28", -"2029,04,29", -"2029,05,01", -"2029,05,05", -"2029,05,06", -"2029,05,12", -"2029,05,13", -"2029,05,19", -"2029,05,20", -"2029,05,26", -"2029,05,27", -"2029,06,02", -"2029,06,03", -"2029,06,09", -"2029,06,10", -"2029,06,16", -"2029,06,17", -"2029,06,23", -"2029,06,24", -"2029,06,30", -"2029,07,01", -"2029,07,07", -"2029,07,08", -"2029,07,14", -"2029,07,15", -"2029,07,21", -"2029,07,22", -"2029,07,28", -"2029,07,29", -"2029,08,04", -"2029,08,05", -"2029,08,11", -"2029,08,12", -"2029,08,18", -"2029,08,19", -"2029,08,25", -"2029,08,26", -"2029,09,01", -"2029,09,02", -"2029,09,08", -"2029,09,09", -"2029,09,15", -"2029,09,16", -"2029,09,22", -"2029,09,23", -"2029,09,29", -"2029,09,30", -"2029,10,01", -"2029,10,02", -"2029,10,03", -"2029,10,04", -"2029,10,05", -"2029,10,06", -"2029,10,07", -"2029,10,13", -"2029,10,14", -"2029,10,20", -"2029,10,21", -"2029,10,27", -"2029,10,28", -"2029,11,03", -"2029,11,04", -"2029,11,10", -"2029,11,11", -"2029,11,17", -"2029,11,18", -"2029,11,24", -"2029,11,25", -"2029,12,01", -"2029,12,02", -"2029,12,08", -"2029,12,09", -"2029,12,15", -"2029,12,16", -"2029,12,22", -"2029,12,23", -"2029,12,29", -"2029,12,30", -"2030,01,01", -"2030,01,05", -"2030,01,06", -"2030,01,12", -"2030,01,13", -"2030,01,19", -"2030,01,20", -"2030,01,26", -"2030,01,27", -"2030,02,02", -"2030,02,03", -"2030,02,04", -"2030,02,05", -"2030,02,06", -"2030,02,07", -"2030,02,08", -"2030,02,09", -"2030,02,10", -"2030,02,16", -"2030,02,17", -"2030,02,23", -"2030,02,24", -"2030,03,02", -"2030,03,03", -"2030,03,09", -"2030,03,10", -"2030,03,16", -"2030,03,17", -"2030,03,23", -"2030,03,24", -"2030,03,30", -"2030,03,31", -"2030,04,05", -"2030,04,06", -"2030,04,07", -"2030,04,13", -"2030,04,14", -"2030,04,20", -"2030,04,21", -"2030,04,27", -"2030,04,28", -"2030,05,01", -"2030,05,04", -"2030,05,05", -"2030,05,11", -"2030,05,12", -"2030,05,18", -"2030,05,19", -"2030,05,25", -"2030,05,26", -"2030,06,01", -"2030,06,02", -"2030,06,05", -"2030,06,08", -"2030,06,09", -"2030,06,15", -"2030,06,16", -"2030,06,22", -"2030,06,23", -"2030,06,29", -"2030,06,30", -"2030,07,06", -"2030,07,07", -"2030,07,13", -"2030,07,14", -"2030,07,20", -"2030,07,21", -"2030,07,27", -"2030,07,28", -"2030,08,03", -"2030,08,04", -"2030,08,10", -"2030,08,11", -"2030,08,17", -"2030,08,18", -"2030,08,24", -"2030,08,25", -"2030,08,31", -"2030,09,01", -"2030,09,07", -"2030,09,08", -"2030,09,12", -"2030,09,14", -"2030,09,15", -"2030,09,21", -"2030,09,22", -"2030,09,28", -"2030,09,29", -"2030,10,01", -"2030,10,02", -"2030,10,03", -"2030,10,04", -"2030,10,05", -"2030,10,06", -"2030,10,07", -"2030,10,12", -"2030,10,13", -"2030,10,19", -"2030,10,20", -"2030,10,26", -"2030,10,27", -"2030,11,02", -"2030,11,03", -"2030,11,09", -"2030,11,10", -"2030,11,16", -"2030,11,17", -"2030,11,23", -"2030,11,24", -"2030,11,30", -"2030,12,01", -"2030,12,07", -"2030,12,08", -"2030,12,14", -"2030,12,15", -"2030,12,21", -"2030,12,22", -"2030,12,28", -"2030,12,29", -"2031,01,01", -"2031,01,04", -"2031,01,05", -"2031,01,11", -"2031,01,12", -"2031,01,18", -"2031,01,19", -"2031,01,22", -"2031,01,23", -"2031,01,24", -"2031,01,25", -"2031,01,26", -"2031,01,27", -"2031,01,28", -"2031,02,01", -"2031,02,02", -"2031,02,08", -"2031,02,09", -"2031,02,15", -"2031,02,16", -"2031,02,22", -"2031,02,23", -"2031,03,01", -"2031,03,02", -"2031,03,08", -"2031,03,09", -"2031,03,15", -"2031,03,16", -"2031,03,22", -"2031,03,23", -"2031,03,29", -"2031,03,30", -"2031,04,05", -"2031,04,06", -"2031,04,12", -"2031,04,13", -"2031,04,19", -"2031,04,20", -"2031,04,26", -"2031,04,27", -"2031,05,01", -"2031,05,03", -"2031,05,04", -"2031,05,10", -"2031,05,11", -"2031,05,17", -"2031,05,18", -"2031,05,24", -"2031,05,25", -"2031,05,31", -"2031,06,01", -"2031,06,07", -"2031,06,08", -"2031,06,14", -"2031,06,15", -"2031,06,21", -"2031,06,22", -"2031,06,24", -"2031,06,28", -"2031,06,29", -"2031,07,05", -"2031,07,06", -"2031,07,12", -"2031,07,13", -"2031,07,19", -"2031,07,20", -"2031,07,26", -"2031,07,27", -"2031,08,02", -"2031,08,03", -"2031,08,09", -"2031,08,10", -"2031,08,16", -"2031,08,17", -"2031,08,23", -"2031,08,24", -"2031,08,30", -"2031,08,31", -"2031,09,06", -"2031,09,07", -"2031,09,13", -"2031,09,14", -"2031,09,20", -"2031,09,21", -"2031,09,27", -"2031,09,28", -"2031,10,01", -"2031,10,02", -"2031,10,03", -"2031,10,04", -"2031,10,05", -"2031,10,06", -"2031,10,07", -"2031,10,11", -"2031,10,12", -"2031,10,18", -"2031,10,19", -"2031,10,25", -"2031,10,26", -"2031,11,01", -"2031,11,02", -"2031,11,08", -"2031,11,09", -"2031,11,15", -"2031,11,16", -"2031,11,22", -"2031,11,23", -"2031,11,29", -"2031,11,30", -"2031,12,06", -"2031,12,07", -"2031,12,13", -"2031,12,14", -"2031,12,20", -"2031,12,21", -"2031,12,27", -"2031,12,28", -"2032,01,01", -"2032,01,03", -"2032,01,04", -"2032,01,10", -"2032,01,11", -"2032,01,17", -"2032,01,18", -"2032,01,24", -"2032,01,25", -"2032,01,31", -"2032,02,01", -"2032,02,07", -"2032,02,08", -"2032,02,10", -"2032,02,11", -"2032,02,12", -"2032,02,13", -"2032,02,14", -"2032,02,15", -"2032,02,16", -"2032,02,21", -"2032,02,22", -"2032,02,28", -"2032,02,29", -"2032,03,06", -"2032,03,07", -"2032,03,13", -"2032,03,14", -"2032,03,20", -"2032,03,21", -"2032,03,27", -"2032,03,28", -"2032,04,03", -"2032,04,04", -"2032,04,10", -"2032,04,11", -"2032,04,17", -"2032,04,18", -"2032,04,24", -"2032,04,25", -"2032,05,01", -"2032,05,02", -"2032,05,08", -"2032,05,09", -"2032,05,15", -"2032,05,16", -"2032,05,22", -"2032,05,23", -"2032,05,29", -"2032,05,30", -"2032,06,05", -"2032,06,06", -"2032,06,12", -"2032,06,13", -"2032,06,19", -"2032,06,20", -"2032,06,26", -"2032,06,27", -"2032,07,03", -"2032,07,04", -"2032,07,10", -"2032,07,11", -"2032,07,17", -"2032,07,18", -"2032,07,24", -"2032,07,25", -"2032,07,31", -"2032,08,01", -"2032,08,07", -"2032,08,08", -"2032,08,14", -"2032,08,15", -"2032,08,21", -"2032,08,22", -"2032,08,28", -"2032,08,29", -"2032,09,04", -"2032,09,05", -"2032,09,11", -"2032,09,12", -"2032,09,18", -"2032,09,19", -"2032,09,25", -"2032,09,26", -"2032,10,01", -"2032,10,02", -"2032,10,03", -"2032,10,04", -"2032,10,05", -"2032,10,06", -"2032,10,07", -"2032,10,09", -"2032,10,10", -"2032,10,16", -"2032,10,17", -"2032,10,23", -"2032,10,24", -"2032,10,30", -"2032,10,31", -"2032,11,06", -"2032,11,07", -"2032,11,13", -"2032,11,14", -"2032,11,20", -"2032,11,21", -"2032,11,27", -"2032,11,28", -"2032,12,04", -"2032,12,05", -"2032,12,11", -"2032,12,12", -"2032,12,18", -"2032,12,19", -"2032,12,25", -"2032,12,26", -"2033,01,01", -"2033,01,02", -"2033,01,08", -"2033,01,09", -"2033,01,15", -"2033,01,16", -"2033,01,22", -"2033,01,23", -"2033,01,29", -"2033,01,30", -"2033,01,31", -"2033,02,01", -"2033,02,02", -"2033,02,03", -"2033,02,04", -"2033,02,05", -"2033,02,06", -"2033,02,12", -"2033,02,13", -"2033,02,19", -"2033,02,20", -"2033,02,26", -"2033,02,27", -"2033,03,05", -"2033,03,06", -"2033,03,12", -"2033,03,13", -"2033,03,19", -"2033,03,20", -"2033,03,26", -"2033,03,27", -"2033,04,02", -"2033,04,03", -"2033,04,04", -"2033,04,09", -"2033,04,10", -"2033,04,16", -"2033,04,17", -"2033,04,23", -"2033,04,24", -"2033,04,30", -"2033,05,01", -"2033,05,07", -"2033,05,08", -"2033,05,14", -"2033,05,15", -"2033,05,21", -"2033,05,22", -"2033,05,28", -"2033,05,29", -"2033,06,01", -"2033,06,04", -"2033,06,05", -"2033,06,11", -"2033,06,12", -"2033,06,18", -"2033,06,19", -"2033,06,25", -"2033,06,26", -"2033,07,02", -"2033,07,03", -"2033,07,09", -"2033,07,10", -"2033,07,16", -"2033,07,17", -"2033,07,23", -"2033,07,24", -"2033,07,30", -"2033,07,31", -"2033,08,06", -"2033,08,07", -"2033,08,13", -"2033,08,14", -"2033,08,20", -"2033,08,21", -"2033,08,27", -"2033,08,28", -"2033,09,03", -"2033,09,04", -"2033,09,08", -"2033,09,10", -"2033,09,11", -"2033,09,17", -"2033,09,18", -"2033,09,24", -"2033,09,25", -"2033,10,01", -"2033,10,02", -"2033,10,03", -"2033,10,04", -"2033,10,05", -"2033,10,06", -"2033,10,07", -"2033,10,08", -"2033,10,09", -"2033,10,15", -"2033,10,16", -"2033,10,22", -"2033,10,23", -"2033,10,29", -"2033,10,30", -"2033,11,05", -"2033,11,06", -"2033,11,12", -"2033,11,13", -"2033,11,19", -"2033,11,20", -"2033,11,26", -"2033,11,27", -"2033,12,03", -"2033,12,04", -"2033,12,10", -"2033,12,11", -"2033,12,17", -"2033,12,18", -"2033,12,24", -"2033,12,25", -"2033,12,31", -"2034,01,01", -"2034,01,07", -"2034,01,08", -"2034,01,14", -"2034,01,15", -"2034,01,21", -"2034,01,22", -"2034,01,28", -"2034,01,29", -"2034,02,04", -"2034,02,05", -"2034,02,11", -"2034,02,12", -"2034,02,18", -"2034,02,19", -"2034,02,20", -"2034,02,21", -"2034,02,22", -"2034,02,23", -"2034,02,24", -"2034,02,25", -"2034,02,26", -"2034,03,04", -"2034,03,05", -"2034,03,11", -"2034,03,12", -"2034,03,18", -"2034,03,19", -"2034,03,25", -"2034,03,26", -"2034,04,01", -"2034,04,02", -"2034,04,05", -"2034,04,08", -"2034,04,09", -"2034,04,15", -"2034,04,16", -"2034,04,22", -"2034,04,23", -"2034,04,29", -"2034,04,30", -"2034,05,01", -"2034,05,06", -"2034,05,07", -"2034,05,13", -"2034,05,14", -"2034,05,20", -"2034,05,21", -"2034,05,27", -"2034,05,28", -"2034,06,03", -"2034,06,04", -"2034,06,10", -"2034,06,11", -"2034,06,17", -"2034,06,18", -"2034,06,20", -"2034,06,24", -"2034,06,25", -"2034,07,01", -"2034,07,02", -"2034,07,08", -"2034,07,09", -"2034,07,15", -"2034,07,16", -"2034,07,22", -"2034,07,23", -"2034,07,29", -"2034,07,30", -"2034,08,05", -"2034,08,06", -"2034,08,12", -"2034,08,13", -"2034,08,19", -"2034,08,20", -"2034,08,26", -"2034,08,27", -"2034,09,02", -"2034,09,03", -"2034,09,09", -"2034,09,10", -"2034,09,16", -"2034,09,17", -"2034,09,23", -"2034,09,24", -"2034,09,27", -"2034,09,30", -"2034,10,01", -"2034,10,02", -"2034,10,03", -"2034,10,04", -"2034,10,05", -"2034,10,06", -"2034,10,07", -"2034,10,08", -"2034,10,14", -"2034,10,15", -"2034,10,21", -"2034,10,22", -"2034,10,28", -"2034,10,29", -"2034,11,04", -"2034,11,05", -"2034,11,11", -"2034,11,12", -"2034,11,18", -"2034,11,19", -"2034,11,25", -"2034,11,26", -"2034,12,02", -"2034,12,03", -"2034,12,09", -"2034,12,10", -"2034,12,16", -"2034,12,17", -"2034,12,23", -"2034,12,24", -"2034,12,30", -"2034,12,31", -"2035,01,01", -"2035,01,06", -"2035,01,07", -"2035,01,13", -"2035,01,14", -"2035,01,20", -"2035,01,21", -"2035,01,27", -"2035,01,28", -"2035,02,03", -"2035,02,04", -"2035,02,07", -"2035,02,08", -"2035,02,09", -"2035,02,10", -"2035,02,11", -"2035,02,12", -"2035,02,13", -"2035,02,17", -"2035,02,18", -"2035,02,24", -"2035,02,25", -"2035,03,03", -"2035,03,04", -"2035,03,10", -"2035,03,11", -"2035,03,17", -"2035,03,18", -"2035,03,24", -"2035,03,25", -"2035,03,31", -"2035,04,01", -"2035,04,05", -"2035,04,07", -"2035,04,08", -"2035,04,14", -"2035,04,15", -"2035,04,21", -"2035,04,22", -"2035,04,28", -"2035,04,29", -"2035,05,01", -"2035,05,05", -"2035,05,06", -"2035,05,12", -"2035,05,13", -"2035,05,19", -"2035,05,20", -"2035,05,26", -"2035,05,27", -"2035,06,02", -"2035,06,03", -"2035,06,09", -"2035,06,10", -"2035,06,16", -"2035,06,17", -"2035,06,23", -"2035,06,24", -"2035,06,30", -"2035,07,01", -"2035,07,07", -"2035,07,08", -"2035,07,14", -"2035,07,15", -"2035,07,21", -"2035,07,22", -"2035,07,28", -"2035,07,29", -"2035,08,04", -"2035,08,05", -"2035,08,11", -"2035,08,12", -"2035,08,18", -"2035,08,19", -"2035,08,25", -"2035,08,26", -"2035,09,01", -"2035,09,02", -"2035,09,08", -"2035,09,09", -"2035,09,15", -"2035,09,16", -"2035,09,22", -"2035,09,23", -"2035,09,29", -"2035,09,30", -"2035,10,01", -"2035,10,02", -"2035,10,03", -"2035,10,04", -"2035,10,05", -"2035,10,06", -"2035,10,07", -"2035,10,13", -"2035,10,14", -"2035,10,20", -"2035,10,21", -"2035,10,27", -"2035,10,28", -"2035,11,03", -"2035,11,04", -"2035,11,10", -"2035,11,11", -"2035,11,17", -"2035,11,18", -"2035,11,24", -"2035,11,25", -"2035,12,01", -"2035,12,02", -"2035,12,08", -"2035,12,09", -"2035,12,15", -"2035,12,16", -"2035,12,22", -"2035,12,23", -"2035,12,29", -"2035,12,30", -"2036,01,01", -"2036,01,05", -"2036,01,06", -"2036,01,12", -"2036,01,13", -"2036,01,19", -"2036,01,20", -"2036,01,26", -"2036,01,27", -"2036,01,28", -"2036,01,29", -"2036,01,30", -"2036,01,31", -"2036,02,01", -"2036,02,02", -"2036,02,03", -"2036,02,09", -"2036,02,10", -"2036,02,16", -"2036,02,17", -"2036,02,23", -"2036,02,24", -"2036,03,01", -"2036,03,02", -"2036,03,08", -"2036,03,09", -"2036,03,15", -"2036,03,16", -"2036,03,22", -"2036,03,23", -"2036,03,29", -"2036,03,30", -"2036,04,04", -"2036,04,05", -"2036,04,06", -"2036,04,12", -"2036,04,13", -"2036,04,19", -"2036,04,20", -"2036,04,26", -"2036,04,27", -"2036,05,01", -"2036,05,03", -"2036,05,04", -"2036,05,10", -"2036,05,11", -"2036,05,17", -"2036,05,18", -"2036,05,24", -"2036,05,25", -"2036,05,30", -"2036,05,31", -"2036,06,01", -"2036,06,07", -"2036,06,08", -"2036,06,14", -"2036,06,15", -"2036,06,21", -"2036,06,22", -"2036,06,28", -"2036,06,29", -"2036,07,05", -"2036,07,06", -"2036,07,12", -"2036,07,13", -"2036,07,19", -"2036,07,20", -"2036,07,26", -"2036,07,27", -"2036,08,02", -"2036,08,03", -"2036,08,09", -"2036,08,10", -"2036,08,16", -"2036,08,17", -"2036,08,23", -"2036,08,24", -"2036,08,30", -"2036,08,31", -"2036,09,06", -"2036,09,07", -"2036,09,13", -"2036,09,14", -"2036,09,20", -"2036,09,21", -"2036,09,27", -"2036,09,28", -"2036,10,01", -"2036,10,02", -"2036,10,03", -"2036,10,04", -"2036,10,05", -"2036,10,06", -"2036,10,07", -"2036,10,11", -"2036,10,12", -"2036,10,18", -"2036,10,19", -"2036,10,25", -"2036,10,26", -"2036,11,01", -"2036,11,02", -"2036,11,08", -"2036,11,09", -"2036,11,15", -"2036,11,16", -"2036,11,22", -"2036,11,23", -"2036,11,29", -"2036,11,30", -"2036,12,06", -"2036,12,07", -"2036,12,13", -"2036,12,14", -"2036,12,20", -"2036,12,21", -"2036,12,27", -"2036,12,28", -"2037,01,01", -"2037,01,03", -"2037,01,04", -"2037,01,10", -"2037,01,11", -"2037,01,17", -"2037,01,18", -"2037,01,24", -"2037,01,25", -"2037,01,31", -"2037,02,01", -"2037,02,07", -"2037,02,08", -"2037,02,14", -"2037,02,15", -"2037,02,16", -"2037,02,17", -"2037,02,18", -"2037,02,19", -"2037,02,20", -"2037,02,21", -"2037,02,22", -"2037,02,28", -"2037,03,01", -"2037,03,07", -"2037,03,08", -"2037,03,14", -"2037,03,15", -"2037,03,21", -"2037,03,22", -"2037,03,28", -"2037,03,29", -"2037,04,04", -"2037,04,05", -"2037,04,11", -"2037,04,12", -"2037,04,18", -"2037,04,19", -"2037,04,25", -"2037,04,26", -"2037,05,01", -"2037,05,02", -"2037,05,03", -"2037,05,09", -"2037,05,10", -"2037,05,16", -"2037,05,17", -"2037,05,23", -"2037,05,24", -"2037,05,30", -"2037,05,31", -"2037,06,06", -"2037,06,07", -"2037,06,13", -"2037,06,14", -"2037,06,18", -"2037,06,20", -"2037,06,21", -"2037,06,27", -"2037,06,28", -"2037,07,04", -"2037,07,05", -"2037,07,11", -"2037,07,12", -"2037,07,18", -"2037,07,19", -"2037,07,25", -"2037,07,26", -"2037,08,01", -"2037,08,02", -"2037,08,08", -"2037,08,09", -"2037,08,15", -"2037,08,16", -"2037,08,22", -"2037,08,23", -"2037,08,29", -"2037,08,30", -"2037,09,05", -"2037,09,06", -"2037,09,12", -"2037,09,13", -"2037,09,19", -"2037,09,20", -"2037,09,24", -"2037,09,26", -"2037,09,27", -"2037,10,01", -"2037,10,02", -"2037,10,03", -"2037,10,04", -"2037,10,05", -"2037,10,06", -"2037,10,07", -"2037,10,10", -"2037,10,11", -"2037,10,17", -"2037,10,18", -"2037,10,24", -"2037,10,25", -"2037,10,31", -"2037,11,01", -"2037,11,07", -"2037,11,08", -"2037,11,14", -"2037,11,15", -"2037,11,21", -"2037,11,22", -"2037,11,28", -"2037,11,29", -"2037,12,05", -"2037,12,06", -"2037,12,12", -"2037,12,13", -"2037,12,19", -"2037,12,20", -"2037,12,26", -"2037,12,27", -"2038,01,01", -"2038,01,02", -"2038,01,03", -"2038,01,09", -"2038,01,10", -"2038,01,16", -"2038,01,17", -"2038,01,23", -"2038,01,24", -"2038,01,30", -"2038,01,31", -"2038,02,03", -"2038,02,04", -"2038,02,05", -"2038,02,06", -"2038,02,07", -"2038,02,08", -"2038,02,09", -"2038,02,13", -"2038,02,14", -"2038,02,20", -"2038,02,21", -"2038,02,27", -"2038,02,28", -"2038,03,06", -"2038,03,07", -"2038,03,13", -"2038,03,14", -"2038,03,20", -"2038,03,21", -"2038,03,27", -"2038,03,28", -"2038,04,03", -"2038,04,04", -"2038,04,05", -"2038,04,10", -"2038,04,11", -"2038,04,17", -"2038,04,18", -"2038,04,24", -"2038,04,25", -"2038,05,01", -"2038,05,02", -"2038,05,08", -"2038,05,09", -"2038,05,15", -"2038,05,16", -"2038,05,22", -"2038,05,23", -"2038,05,29", -"2038,05,30", -"2038,06,05", -"2038,06,06", -"2038,06,07", -"2038,06,12", -"2038,06,13", -"2038,06,19", -"2038,06,20", -"2038,06,26", -"2038,06,27", -"2038,07,03", -"2038,07,04", -"2038,07,10", -"2038,07,11", -"2038,07,17", -"2038,07,18", -"2038,07,24", -"2038,07,25", -"2038,07,31", -"2038,08,01", -"2038,08,07", -"2038,08,08", -"2038,08,14", -"2038,08,15", -"2038,08,21", -"2038,08,22", -"2038,08,28", -"2038,08,29", -"2038,09,04", -"2038,09,05", -"2038,09,11", -"2038,09,12", -"2038,09,13", -"2038,09,18", -"2038,09,19", -"2038,09,25", -"2038,09,26", -"2038,10,01", -"2038,10,02", -"2038,10,03", -"2038,10,04", -"2038,10,05", -"2038,10,06", -"2038,10,07", -"2038,10,09", -"2038,10,10", -"2038,10,16", -"2038,10,17", -"2038,10,23", -"2038,10,24", -"2038,10,30", -"2038,10,31", -"2038,11,06", -"2038,11,07", -"2038,11,13", -"2038,11,14", -"2038,11,20", -"2038,11,21", -"2038,11,27", -"2038,11,28", -"2038,12,04", -"2038,12,05", -"2038,12,11", -"2038,12,12", -"2038,12,18", -"2038,12,19", -"2038,12,25", -"2038,12,26", -"2039,01,01", -"2039,01,02", -"2039,01,08", -"2039,01,09", -"2039,01,15", -"2039,01,16", -"2039,01,22", -"2039,01,23", -"2039,01,24", -"2039,01,25", -"2039,01,26", -"2039,01,27", -"2039,01,28", -"2039,01,29", -"2039,01,30", -"2039,02,05", -"2039,02,06", -"2039,02,12", -"2039,02,13", -"2039,02,19", -"2039,02,20", -"2039,02,26", -"2039,02,27", -"2039,03,05", -"2039,03,06", -"2039,03,12", -"2039,03,13", -"2039,03,19", -"2039,03,20", -"2039,03,26", -"2039,03,27", -"2039,04,02", -"2039,04,03", -"2039,04,05", -"2039,04,09", -"2039,04,10", -"2039,04,16", -"2039,04,17", -"2039,04,23", -"2039,04,24", -"2039,04,30", -"2039,05,01", -"2039,05,07", -"2039,05,08", -"2039,05,14", -"2039,05,15", -"2039,05,21", -"2039,05,22", -"2039,05,27", -"2039,05,28", -"2039,05,29", -"2039,06,04", -"2039,06,05", -"2039,06,11", -"2039,06,12", -"2039,06,18", -"2039,06,19", -"2039,06,25", -"2039,06,26", -"2039,07,02", -"2039,07,03", -"2039,07,09", -"2039,07,10", -"2039,07,16", -"2039,07,17", -"2039,07,23", -"2039,07,24", -"2039,07,30", -"2039,07,31", -"2039,08,06", -"2039,08,07", -"2039,08,13", -"2039,08,14", -"2039,08,20", -"2039,08,21", -"2039,08,27", -"2039,08,28", -"2039,09,03", -"2039,09,04", -"2039,09,10", -"2039,09,11", -"2039,09,17", -"2039,09,18", -"2039,09,24", -"2039,09,25", -"2039,10,01", -"2039,10,02", -"2039,10,03", -"2039,10,04", -"2039,10,05", -"2039,10,06", -"2039,10,07", -"2039,10,08", -"2039,10,09", -"2039,10,15", -"2039,10,16", -"2039,10,22", -"2039,10,23", -"2039,10,29", -"2039,10,30", -"2039,11,05", -"2039,11,06", -"2039,11,12", -"2039,11,13", -"2039,11,19", -"2039,11,20", -"2039,11,26", -"2039,11,27", -"2039,12,03", -"2039,12,04", -"2039,12,10", -"2039,12,11", -"2039,12,17", -"2039,12,18", -"2039,12,24", -"2039,12,25", -"2039,12,31", -"2040,01,01", -"2040,01,07", -"2040,01,08", -"2040,01,14", -"2040,01,15", -"2040,01,21", -"2040,01,22", -"2040,01,28", -"2040,01,29", -"2040,02,04", -"2040,02,05", -"2040,02,11", -"2040,02,12", -"2040,02,13", -"2040,02,14", -"2040,02,15", -"2040,02,16", -"2040,02,17", -"2040,02,18", -"2040,02,19", -"2040,02,25", -"2040,02,26", -"2040,03,03", -"2040,03,04", -"2040,03,10", -"2040,03,11", -"2040,03,17", -"2040,03,18", -"2040,03,24", -"2040,03,25", -"2040,03,31", -"2040,04,01", -"2040,04,04", -"2040,04,07", -"2040,04,08", -"2040,04,14", -"2040,04,15", -"2040,04,21", -"2040,04,22", -"2040,04,28", -"2040,04,29", -"2040,05,01", -"2040,05,05", -"2040,05,06", -"2040,05,12", -"2040,05,13", -"2040,05,19", -"2040,05,20", -"2040,05,26", -"2040,05,27", -"2040,06,02", -"2040,06,03", -"2040,06,09", -"2040,06,10", -"2040,06,14", -"2040,06,16", -"2040,06,17", -"2040,06,23", -"2040,06,24", -"2040,06,30", -"2040,07,01", -"2040,07,07", -"2040,07,08", -"2040,07,14", -"2040,07,15", -"2040,07,21", -"2040,07,22", -"2040,07,28", -"2040,07,29", -"2040,08,04", -"2040,08,05", -"2040,08,11", -"2040,08,12", -"2040,08,18", -"2040,08,19", -"2040,08,25", -"2040,08,26", -"2040,09,01", -"2040,09,02", -"2040,09,08", -"2040,09,09", -"2040,09,15", -"2040,09,16", -"2040,09,20", -"2040,09,22", -"2040,09,23", -"2040,09,29", -"2040,09,30", -"2040,10,01", -"2040,10,02", -"2040,10,03", -"2040,10,04", -"2040,10,05", -"2040,10,06", -"2040,10,07", -"2040,10,13", -"2040,10,14", -"2040,10,20", -"2040,10,21", -"2040,10,27", -"2040,10,28", -"2040,11,03", -"2040,11,04", -"2040,11,10", -"2040,11,11", -"2040,11,17", -"2040,11,18", -"2040,11,24", -"2040,11,25", -"2040,12,01", -"2040,12,02", -"2040,12,08", -"2040,12,09", -"2040,12,15", -"2040,12,16", -"2040,12,22", -"2040,12,23", -"2040,12,29", -"2040,12,30", -"2041,01,01", -"2041,01,05", -"2041,01,06", -"2041,01,12", -"2041,01,13", -"2041,01,19", -"2041,01,20", -"2041,01,26", -"2041,01,27", -"2041,01,31", -"2041,02,01", -"2041,02,02", -"2041,02,03", -"2041,02,04", -"2041,02,05", -"2041,02,06", -"2041,02,09", -"2041,02,10", -"2041,02,16", -"2041,02,17", -"2041,02,23", -"2041,02,24", -"2041,03,02", -"2041,03,03", -"2041,03,09", -"2041,03,10", -"2041,03,16", -"2041,03,17", -"2041,03,23", -"2041,03,24", -"2041,03,30", -"2041,03,31", -"2041,04,04", -"2041,04,06", -"2041,04,07", -"2041,04,13", -"2041,04,14", -"2041,04,20", -"2041,04,21", -"2041,04,27", -"2041,04,28", -"2041,05,01", -"2041,05,04", -"2041,05,05", -"2041,05,11", -"2041,05,12", -"2041,05,18", -"2041,05,19", -"2041,05,25", -"2041,05,26", -"2041,06,01", -"2041,06,02", -"2041,06,03", -"2041,06,08", -"2041,06,09", -"2041,06,15", -"2041,06,16", -"2041,06,22", -"2041,06,23", -"2041,06,29", -"2041,06,30", -"2041,07,06", -"2041,07,07", -"2041,07,13", -"2041,07,14", -"2041,07,20", -"2041,07,21", -"2041,07,27", -"2041,07,28", -"2041,08,03", -"2041,08,04", -"2041,08,10", -"2041,08,11", -"2041,08,17", -"2041,08,18", -"2041,08,24", -"2041,08,25", -"2041,08,31", -"2041,09,01", -"2041,09,07", -"2041,09,08", -"2041,09,10", -"2041,09,14", -"2041,09,15", -"2041,09,21", -"2041,09,22", -"2041,09,28", -"2041,09,29", -"2041,10,01", -"2041,10,02", -"2041,10,03", -"2041,10,04", -"2041,10,05", -"2041,10,06", -"2041,10,07", -"2041,10,12", -"2041,10,13", -"2041,10,19", -"2041,10,20", -"2041,10,26", -"2041,10,27", -"2041,11,02", -"2041,11,03", -"2041,11,09", -"2041,11,10", -"2041,11,16", -"2041,11,17", -"2041,11,23", -"2041,11,24", -"2041,11,30", -"2041,12,01", -"2041,12,07", -"2041,12,08", -"2041,12,14", -"2041,12,15", -"2041,12,21", -"2041,12,22", -"2041,12,28", -"2041,12,29", -"2042,01,01", -"2042,01,04", -"2042,01,05", -"2042,01,11", -"2042,01,12", -"2042,01,18", -"2042,01,19", -"2042,01,21", -"2042,01,22", -"2042,01,25", -"2042,01,26", -"2042,02,01", -"2042,02,02", -"2042,02,08", -"2042,02,09", -"2042,02,15", -"2042,02,16", -"2042,02,22", -"2042,02,23", -"2042,02,24", -"2042,02,27", -"2042,03,01", -"2042,03,02", -"2042,03,08", -"2042,03,09", -"2042,03,15", -"2042,03,16", -"2042,03,22", -"2042,03,23", -"2042,03,29", -"2042,03,30", -"2042,04,04", -"2042,04,05", -"2042,04,06", -"2042,04,12", -"2042,04,13", -"2042,04,19", -"2042,04,20", -"2042,04,26", -"2042,04,27", -"2042,05,01", -"2042,05,03", -"2042,05,04", -"2042,05,10", -"2042,05,11", -"2042,05,17", -"2042,05,18", -"2042,05,24", -"2042,05,25", -"2042,05,31", -"2042,06,01", -"2042,06,07", -"2042,06,08", -"2042,06,14", -"2042,06,15", -"2042,06,21", -"2042,06,22", -"2042,06,28", -"2042,06,29", -"2042,07,05", -"2042,07,06", -"2042,07,12", -"2042,07,13", -"2042,07,19", -"2042,07,20", -"2042,07,26", -"2042,07,27", -"2042,08,02", -"2042,08,03", -"2042,08,09", -"2042,08,10", -"2042,08,16", -"2042,08,17", -"2042,08,23", -"2042,08,24", -"2042,08,30", -"2042,08,31", -"2042,09,06", -"2042,09,07", -"2042,09,13", -"2042,09,14", -"2042,09,20", -"2042,09,21", -"2042,09,27", -"2042,09,28", -"2042,10,01", -"2042,10,02", -"2042,10,03", -"2042,10,04", -"2042,10,05", -"2042,10,06", -"2042,10,07", -"2042,10,11", -"2042,10,12", -"2042,10,18", -"2042,10,19", -"2042,10,25", -"2042,10,26", -"2042,11,01", -"2042,11,02", -"2042,11,08", -"2042,11,09", -"2042,11,15", -"2042,11,16", -"2042,11,22", -"2042,11,23", -"2042,11,29", -"2042,11,30", -"2042,12,06", -"2042,12,07", -"2042,12,13", -"2042,12,14", -"2042,12,20", -"2042,12,21", -"2042,12,27", -"2042,12,28", -"2043,01,01", -"2043,01,03", -"2043,01,04", -"2043,01,10", -"2043,01,11", -"2043,01,17", -"2043,01,18", -"2043,01,24", -"2043,01,25", -"2043,01,31", -"2043,02,01", -"2043,02,07", -"2043,02,08", -"2043,02,09", -"2043,02,10", -"2043,02,11", -"2043,02,12", -"2043,02,13", -"2043,02,14", -"2043,02,15", -"2043,02,21", -"2043,02,22", -"2043,02,28", -"2043,03,01", -"2043,03,07", -"2043,03,08", -"2043,03,14", -"2043,03,15", -"2043,03,21", -"2043,03,22", -"2043,03,28", -"2043,03,29", -"2043,04,04", -"2043,04,05", -"2043,04,11", -"2043,04,12", -"2043,04,18", -"2043,04,19", -"2043,04,25", -"2043,04,26", -"2043,05,01", -"2043,05,02", -"2043,05,03", -"2043,05,09", -"2043,05,10", -"2043,05,16", -"2043,05,17", -"2043,05,23", -"2043,05,24", -"2043,05,30", -"2043,05,31", -"2043,06,06", -"2043,06,07", -"2043,06,11", -"2043,06,13", -"2043,06,14", -"2043,06,20", -"2043,06,21", -"2043,06,27", -"2043,06,28", -"2043,07,04", -"2043,07,05", -"2043,07,11", -"2043,07,12", -"2043,07,18", -"2043,07,19", -"2043,07,25", -"2043,07,26", -"2043,08,01", -"2043,08,02", -"2043,08,08", -"2043,08,09", -"2043,08,15", -"2043,08,16", -"2043,08,22", -"2043,08,23", -"2043,08,29", -"2043,08,30", -"2043,09,05", -"2043,09,06", -"2043,09,12", -"2043,09,13", -"2043,09,17", -"2043,09,19", -"2043,09,20", -"2043,09,26", -"2043,09,27", -"2043,10,01", -"2043,10,02", -"2043,10,03", -"2043,10,04", -"2043,10,05", -"2043,10,06", -"2043,10,07", -"2043,10,10", -"2043,10,11", -"2043,10,17", -"2043,10,18", -"2043,10,24", -"2043,10,25", -"2043,10,31", -"2043,11,01", -"2043,11,07", -"2043,11,08", -"2043,11,14", -"2043,11,15", -"2043,11,21", -"2043,11,22", -"2043,11,28", -"2043,11,29", -"2043,12,05", -"2043,12,06", -"2043,12,12", -"2043,12,13", -"2043,12,19", -"2043,12,20", -"2043,12,26", -"2043,12,27", -"2044,01,01", -"2044,01,02", -"2044,01,03", -"2044,01,09", -"2044,01,10", -"2044,01,16", -"2044,01,17", -"2044,01,23", -"2044,01,24", -"2044,01,29", -"2044,01,30", -"2044,01,31", -"2044,02,01", -"2044,02,02", -"2044,02,03", -"2044,02,04", -"2044,02,06", -"2044,02,07", -"2044,02,13", -"2044,02,14", -"2044,02,20", -"2044,02,21", -"2044,02,27", -"2044,02,28", -"2044,03,05", -"2044,03,06", -"2044,03,12", -"2044,03,13", -"2044,03,19", -"2044,03,20", -"2044,03,26", -"2044,03,27", -"2044,04,02", -"2044,04,03", -"2044,04,04", -"2044,04,09", -"2044,04,10", -"2044,04,16", -"2044,04,17", -"2044,04,23", -"2044,04,24", -"2044,04,30", -"2044,05,01", -"2044,05,07", -"2044,05,08", -"2044,05,14", -"2044,05,15", -"2044,05,21", -"2044,05,22", -"2044,05,28", -"2044,05,29", -"2044,05,31", -"2044,06,04", -"2044,06,05", -"2044,06,11", -"2044,06,12", -"2044,06,18", -"2044,06,19", -"2044,06,25", -"2044,06,26", -"2044,07,02", -"2044,07,03", -"2044,07,09", -"2044,07,10", -"2044,07,16", -"2044,07,17", -"2044,07,23", -"2044,07,24", -"2044,07,30", -"2044,07,31", -"2044,08,06", -"2044,08,07", -"2044,08,13", -"2044,08,14", -"2044,08,20", -"2044,08,21", -"2044,08,27", -"2044,08,28", -"2044,09,03", -"2044,09,04", -"2044,09,10", -"2044,09,11", -"2044,09,17", -"2044,09,18", -"2044,09,24", -"2044,09,25", -"2044,10,01", -"2044,10,02", -"2044,10,03", -"2044,10,04", -"2044,10,05", -"2044,10,06", -"2044,10,07", -"2044,10,08", -"2044,10,09", -"2044,10,15", -"2044,10,16", -"2044,10,22", -"2044,10,23", -"2044,10,29", -"2044,10,30", -"2044,11,05", -"2044,11,06", -"2044,11,12", -"2044,11,13", -"2044,11,19", -"2044,11,20", -"2044,11,26", -"2044,11,27", -"2044,12,03", -"2044,12,04", -"2044,12,10", -"2044,12,11", -"2044,12,17", -"2044,12,18", -"2044,12,24", -"2044,12,25", -"2044,12,31", -"2045,01,01", -"2045,01,07", -"2045,01,08", -"2045,01,14", -"2045,01,15", -"2045,01,21", -"2045,01,22", -"2045,01,28", -"2045,01,29", -"2045,02,04", -"2045,02,05", -"2045,02,11", -"2045,02,12", -"2045,02,16", -"2045,02,17", -"2045,02,18", -"2045,02,19", -"2045,02,20", -"2045,02,21", -"2045,02,22", -"2045,02,25", -"2045,02,26", -"2045,03,04", -"2045,03,05", -"2045,03,11", -"2045,03,12", -"2045,03,18", -"2045,03,19", -"2045,03,25", -"2045,03,26", -"2045,04,01", -"2045,04,02", -"2045,04,04", -"2045,04,08", -"2045,04,09", -"2045,04,15", -"2045,04,16", -"2045,04,22", -"2045,04,23", -"2045,04,29", -"2045,04,30", -"2045,05,01", -"2045,05,06", -"2045,05,07", -"2045,05,13", -"2045,05,14", -"2045,05,20", -"2045,05,21", -"2045,05,27", -"2045,05,28", -"2045,06,03", -"2045,06,04", -"2045,06,10", -"2045,06,11", -"2045,06,17", -"2045,06,18", -"2045,06,19", -"2045,06,24", -"2045,06,25", -"2045,07,01", -"2045,07,02", -"2045,07,08", -"2045,07,09", -"2045,07,15", -"2045,07,16", -"2045,07,22", -"2045,07,23", -"2045,07,29", -"2045,07,30", -"2045,08,05", -"2045,08,06", -"2045,08,12", -"2045,08,13", -"2045,08,19", -"2045,08,20", -"2045,08,26", -"2045,08,27", -"2045,09,02", -"2045,09,03", -"2045,09,09", -"2045,09,10", -"2045,09,16", -"2045,09,17", -"2045,09,23", -"2045,09,24", -"2045,09,25", -"2045,09,30", -"2045,10,01", -"2045,10,02", -"2045,10,03", -"2045,10,04", -"2045,10,05", -"2045,10,06", -"2045,10,07", -"2045,10,08", -"2045,10,14", -"2045,10,15", -"2045,10,21", -"2045,10,22", -"2045,10,28", -"2045,10,29", -"2045,11,04", -"2045,11,05", -"2045,11,11", -"2045,11,12", -"2045,11,18", -"2045,11,19", -"2045,11,25", -"2045,11,26", -"2045,12,02", -"2045,12,03", -"2045,12,09", -"2045,12,10", -"2045,12,16", -"2045,12,17", -"2045,12,23", -"2045,12,24", -"2045,12,30", -"2045,12,31", -"2046,01,01", -"2046,01,06", -"2046,01,07", -"2046,01,13", -"2046,01,14", -"2046,01,20", -"2046,01,21", -"2046,01,27", -"2046,01,28", -"2046,02,03", -"2046,02,04", -"2046,02,05", -"2046,02,06", -"2046,02,07", -"2046,02,08", -"2046,02,09", -"2046,02,10", -"2046,02,11", -"2046,02,17", -"2046,02,18", -"2046,02,24", -"2046,02,25", -"2046,03,03", -"2046,03,04", -"2046,03,10", -"2046,03,11", -"2046,03,17", -"2046,03,18", -"2046,03,24", -"2046,03,25", -"2046,03,31", -"2046,04,01", -"2046,04,04", -"2046,04,07", -"2046,04,08", -"2046,04,14", -"2046,04,15", -"2046,04,21", -"2046,04,22", -"2046,04,28", -"2046,04,29", -"2046,05,01", -"2046,05,05", -"2046,05,06", -"2046,05,12", -"2046,05,13", -"2046,05,19", -"2046,05,20", -"2046,05,26", -"2046,05,27", -"2046,06,02", -"2046,06,03", -"2046,06,08", -"2046,06,09", -"2046,06,10", -"2046,06,16", -"2046,06,17", -"2046,06,23", -"2046,06,24", -"2046,06,30", -"2046,07,01", -"2046,07,07", -"2046,07,08", -"2046,07,14", -"2046,07,15", -"2046,07,21", -"2046,07,22", -"2046,07,28", -"2046,07,29", -"2046,08,04", -"2046,08,05", -"2046,08,11", -"2046,08,12", -"2046,08,18", -"2046,08,19", -"2046,08,25", -"2046,08,26", -"2046,09,01", -"2046,09,02", -"2046,09,08", -"2046,09,09", -"2046,09,15", -"2046,09,16", -"2046,09,22", -"2046,09,23", -"2046,09,29", -"2046,09,30", -"2046,10,01", -"2046,10,02", -"2046,10,03", -"2046,10,04", -"2046,10,05", -"2046,10,06", -"2046,10,07", -"2046,10,13", -"2046,10,14", -"2046,10,20", -"2046,10,21", -"2046,10,27", -"2046,10,28", -"2046,11,03", -"2046,11,04", -"2046,11,10", -"2046,11,11", -"2046,11,17", -"2046,11,18", -"2046,11,24", -"2046,11,25", -"2046,12,01", -"2046,12,02", -"2046,12,08", -"2046,12,09", -"2046,12,15", -"2046,12,16", -"2046,12,22", -"2046,12,23", -"2046,12,29", -"2046,12,30", -"2047,01,01", -"2047,01,05", -"2047,01,06", -"2047,01,12", -"2047,01,13", -"2047,01,19", -"2047,01,20", -"2047,01,25", -"2047,01,26", -"2047,01,27", -"2047,01,28", -"2047,01,29", -"2047,01,30", -"2047,01,31", -"2047,02,02", -"2047,02,03", -"2047,02,09", -"2047,02,10", -"2047,02,16", -"2047,02,17", -"2047,02,23", -"2047,02,24", -"2047,03,02", -"2047,03,03", -"2047,03,09", -"2047,03,10", -"2047,03,16", -"2047,03,17", -"2047,03,23", -"2047,03,24", -"2047,03,30", -"2047,03,31", -"2047,04,05", -"2047,04,06", -"2047,04,07", -"2047,04,13", -"2047,04,14", -"2047,04,20", -"2047,04,21", -"2047,04,27", -"2047,04,28", -"2047,05,01", -"2047,05,04", -"2047,05,05", -"2047,05,11", -"2047,05,12", -"2047,05,18", -"2047,05,19", -"2047,05,25", -"2047,05,26", -"2047,05,29", -"2047,06,01", -"2047,06,02", -"2047,06,08", -"2047,06,09", -"2047,06,15", -"2047,06,16", -"2047,06,22", -"2047,06,23", -"2047,06,29", -"2047,06,30", -"2047,07,06", -"2047,07,07", -"2047,07,13", -"2047,07,14", -"2047,07,20", -"2047,07,21", -"2047,07,27", -"2047,07,28", -"2047,08,03", -"2047,08,04", -"2047,08,10", -"2047,08,11", -"2047,08,17", -"2047,08,18", -"2047,08,24", -"2047,08,25", -"2047,08,31", -"2047,09,01", -"2047,09,07", -"2047,09,08", -"2047,09,14", -"2047,09,15", -"2047,09,21", -"2047,09,22", -"2047,09,28", -"2047,09,29", -"2047,10,01", -"2047,10,02", -"2047,10,03", -"2047,10,04", -"2047,10,04", -"2047,10,05", -"2047,10,06", -"2047,10,07", -"2047,10,12", -"2047,10,13", -"2047,10,19", -"2047,10,20", -"2047,10,26", -"2047,10,27", -"2047,11,02", -"2047,11,03", -"2047,11,09", -"2047,11,10", -"2047,11,16", -"2047,11,17", -"2047,11,23", -"2047,11,24", -"2047,11,30", -"2047,12,01", -"2047,12,07", -"2047,12,08", -"2047,12,14", -"2047,12,15", -"2047,12,21", -"2047,12,22", -"2047,12,28", -"2047,12,29", -"2048,01,01", -"2048,01,04", -"2048,01,05", -"2048,01,11", -"2048,01,12", -"2048,01,18", -"2048,01,19", -"2048,01,25", -"2048,01,26", -"2048,02,01", -"2048,02,02", -"2048,02,08", -"2048,02,09", -"2048,02,13", -"2048,02,14", -"2048,02,15", -"2048,02,16", -"2048,02,17", -"2048,02,18", -"2048,02,19", -"2048,02,22", -"2048,02,23", -"2048,02,29", -"2048,03,01", -"2048,03,07", -"2048,03,08", -"2048,03,14", -"2048,03,15", -"2048,03,21", -"2048,03,22", -"2048,03,28", -"2048,03,29", -"2048,04,04", -"2048,04,05", -"2048,04,11", -"2048,04,12", -"2048,04,18", -"2048,04,19", -"2048,04,25", -"2048,04,26", -"2048,05,01", -"2048,05,02", -"2048,05,03", -"2048,05,09", -"2048,05,10", -"2048,05,16", -"2048,05,17", -"2048,05,23", -"2048,05,24", -"2048,05,30", -"2048,05,31", -"2048,06,06", -"2048,06,07", -"2048,06,13", -"2048,06,14", -"2048,06,15", -"2048,06,20", -"2048,06,21", -"2048,06,27", -"2048,06,28", -"2048,07,04", -"2048,07,05", -"2048,07,11", -"2048,07,12", -"2048,07,18", -"2048,07,19", -"2048,07,25", -"2048,07,26", -"2048,08,01", -"2048,08,02", -"2048,08,08", -"2048,08,09", -"2048,08,15", -"2048,08,16", -"2048,08,22", -"2048,08,23", -"2048,08,29", -"2048,08,30", -"2048,09,05", -"2048,09,06", -"2048,09,12", -"2048,09,13", -"2048,09,19", -"2048,09,20", -"2048,09,22", -"2048,09,26", -"2048,09,27", -"2048,10,01", -"2048,10,02", -"2048,10,03", -"2048,10,04", -"2048,10,05", -"2048,10,06", -"2048,10,07", -"2048,10,10", -"2048,10,11", -"2048,10,17", -"2048,10,18", -"2048,10,24", -"2048,10,25", -"2048,10,31", -"2048,11,01", -"2048,11,07", -"2048,11,08", -"2048,11,14", -"2048,11,15", -"2048,11,21", -"2048,11,22", -"2048,11,28", -"2048,11,29", -"2048,12,05", -"2048,12,06", -"2048,12,12", -"2048,12,13", -"2048,12,19", -"2048,12,20", -"2048,12,26", -"2048,12,27", -"2049,01,01", -"2049,01,02", -"2049,01,03", -"2049,01,09", -"2049,01,10", -"2049,01,16", -"2049,01,17", -"2049,01,23", -"2049,01,24", -"2049,01,30", -"2049,01,31", -"2049,02,01", -"2049,02,02", -"2049,02,03", -"2049,02,04", -"2049,02,05", -"2049,02,06", -"2049,02,07", -"2049,02,13", -"2049,02,14", -"2049,02,20", -"2049,02,21", -"2049,02,27", -"2049,02,28", -"2049,03,06", -"2049,03,07", -"2049,03,13", -"2049,03,14", -"2049,03,20", -"2049,03,21", -"2049,03,27", -"2049,03,28", -"2049,04,03", -"2049,04,04", -"2049,04,05", -"2049,04,10", -"2049,04,11", -"2049,04,17", -"2049,04,18", -"2049,04,24", -"2049,04,25", -"2049,05,01", -"2049,05,02", -"2049,05,08", -"2049,05,09", -"2049,05,15", -"2049,05,16", -"2049,05,22", -"2049,05,23", -"2049,05,29", -"2049,05,30", -"2049,06,04", -"2049,06,05", -"2049,06,06", -"2049,06,12", -"2049,06,13", -"2049,06,19", -"2049,06,20", -"2049,06,26", -"2049,06,27", -"2049,07,03", -"2049,07,04", -"2049,07,10", -"2049,07,11", -"2049,07,17", -"2049,07,18", -"2049,07,24", -"2049,07,25", -"2049,07,31", -"2049,08,01", -"2049,08,07", -"2049,08,08", -"2049,08,14", -"2049,08,15", -"2049,08,21", -"2049,08,22", -"2049,08,28", -"2049,08,29", -"2049,09,04", -"2049,09,05", -"2049,09,11", -"2049,09,12", -"2049,09,18", -"2049,09,19", -"2049,09,25", -"2049,09,26", -"2049,10,01", -"2049,10,02", -"2049,10,03", -"2049,10,04", -"2049,10,05", -"2049,10,06", -"2049,10,07", -"2049,10,09", -"2049,10,10", -"2049,10,16", -"2049,10,17", -"2049,10,23", -"2049,10,24", -"2049,10,30", -"2049,10,31", -"2049,11,06", -"2049,11,07", -"2049,11,13", -"2049,11,14", -"2049,11,20", -"2049,11,21", -"2049,11,27", -"2049,11,28", -"2049,12,04", -"2049,12,05", -"2049,12,11", -"2049,12,12", -"2049,12,18", -"2049,12,19", -"2049,12,25", -"2049,12,26", -"2050,01,01", -"2050,01,02", -"2050,01,08", -"2050,01,09", -"2050,01,15", -"2050,01,16", -"2050,01,22", -"2050,01,23", -"2050,01,24", -"2050,01,25", -"2050,01,26", -"2050,01,27", -"2050,01,28", -"2050,01,29", -"2050,01,30", -"2050,02,05", -"2050,02,06", -"2050,02,12", -"2050,02,13", -"2050,02,19", -"2050,02,20", -"2050,02,26", -"2050,02,27", -"2050,03,05", -"2050,03,06", -"2050,03,12", -"2050,03,13", -"2050,03,19", -"2050,03,20", -"2050,03,26", -"2050,03,27", -"2050,04,02", -"2050,04,03", -"2050,04,04", -"2050,04,09", -"2050,04,10", -"2050,04,16", -"2050,04,17", -"2050,04,23", -"2050,04,24", -"2050,04,30", -"2050,05,01", -"2050,05,07", -"2050,05,08", -"2050,05,14", -"2050,05,15", -"2050,05,21", -"2050,05,22", -"2050,05,28", -"2050,05,29", -"2050,06,04", -"2050,06,05", -"2050,06,11", -"2050,06,12", -"2050,06,18", -"2050,06,19", -"2050,06,23", -"2050,06,25", -"2050,06,26", -"2050,07,02", -"2050,07,03", -"2050,07,09", -"2050,07,10", -"2050,07,16", -"2050,07,17", -"2050,07,23", -"2050,07,24", -"2050,07,30", -"2050,07,31", -"2050,08,06", -"2050,08,07", -"2050,08,13", -"2050,08,14", -"2050,08,20", -"2050,08,21", -"2050,08,27", -"2050,08,28", -"2050,09,03", -"2050,09,04", -"2050,09,10", -"2050,09,11", -"2050,09,17", -"2050,09,18", -"2050,09,24", -"2050,09,25", -"2050,09,30", -"2050,10,01", -"2050,10,02", -"2050,10,03", -"2050,10,04", -"2050,10,05", -"2050,10,06", -"2050,10,07", -"2050,10,08", -"2050,10,09", -"2050,10,15", -"2050,10,16", -"2050,10,22", -"2050,10,23", -"2050,10,29", -"2050,10,30", -"2050,11,05", -"2050,11,06", -"2050,11,12", -"2050,11,13", -"2050,11,19", -"2050,11,20", -"2050,11,26", -"2050,11,27", -"2050,12,03", -"2050,12,04", -"2050,12,10", -"2050,12,11", -"2050,12,17", -"2050,12,18", -"2050,12,24", -"2050,12,25", -"2050,12,31", -"2051,01,01", -"2051,01,07", -"2051,01,08", -"2051,01,14", -"2051,01,15", -"2051,01,21", -"2051,01,22", -"2051,01,28", -"2051,01,29", -"2051,02,04", -"2051,02,05", -"2051,02,10", -"2051,02,11", -"2051,02,12", -"2051,02,13", -"2051,02,14", -"2051,02,15", -"2051,02,16", -"2051,02,18", -"2051,02,19", -"2051,02,25", -"2051,02,26", -"2051,03,04", -"2051,03,05", -"2051,03,11", -"2051,03,12", -"2051,03,18", -"2051,03,19", -"2051,03,25", -"2051,03,26", -"2051,04,01", -"2051,04,02", -"2051,04,05", -"2051,04,08", -"2051,04,09", -"2051,04,15", -"2051,04,16", -"2051,04,22", -"2051,04,23", -"2051,04,29", -"2051,04,30", -"2051,05,01", -"2051,05,06", -"2051,05,07", -"2051,05,13", -"2051,05,14", -"2051,05,20", -"2051,05,21", -"2051,05,27", -"2051,05,28", -"2051,06,03", -"2051,06,04", -"2051,06,10", -"2051,06,11", -"2051,06,13", -"2051,06,17", -"2051,06,18", -"2051,06,24", -"2051,06,25", -"2051,07,01", -"2051,07,02", -"2051,07,08", -"2051,07,09", -"2051,07,15", -"2051,07,16", -"2051,07,22", -"2051,07,23", -"2051,07,29", -"2051,07,30", -"2051,08,05", -"2051,08,06", -"2051,08,12", -"2051,08,13", -"2051,08,19", -"2051,08,20", -"2051,08,26", -"2051,08,27", -"2051,09,02", -"2051,09,03", -"2051,09,09", -"2051,09,10", -"2051,09,16", -"2051,09,17", -"2051,09,19", -"2051,09,23", -"2051,09,24", -"2051,09,30", -"2051,10,01", -"2051,10,02", -"2051,10,03", -"2051,10,04", -"2051,10,05", -"2051,10,06", -"2051,10,07", -"2051,10,08", -"2051,10,14", -"2051,10,15", -"2051,10,21", -"2051,10,22", -"2051,10,28", -"2051,10,29", -"2051,11,04", -"2051,11,05", -"2051,11,11", -"2051,11,12", -"2051,11,18", -"2051,11,19", -"2051,11,25", -"2051,11,26", -"2051,12,02", -"2051,12,03", -"2051,12,09", -"2051,12,10", -"2051,12,16", -"2051,12,17", -"2051,12,23", -"2051,12,24", -"2051,12,30", -"2051,12,31", -"2052,01,01", -"2052,01,06", -"2052,01,07", -"2052,01,13", -"2052,01,14", -"2052,01,20", -"2052,01,21", -"2052,01,27", -"2052,01,28", -"2052,01,31", -"2052,02,01", -"2052,02,02", -"2052,02,03", -"2052,02,04", -"2052,02,05", -"2052,02,06", -"2052,02,10", -"2052,02,11", -"2052,02,17", -"2052,02,18", -"2052,02,24", -"2052,02,25", -"2052,03,02", -"2052,03,03", -"2052,03,09", -"2052,03,10", -"2052,03,16", -"2052,03,17", -"2052,03,23", -"2052,03,24", -"2052,03,30", -"2052,03,31", -"2052,04,04", -"2052,04,06", -"2052,04,07", -"2052,04,13", -"2052,04,14", -"2052,04,20", -"2052,04,21", -"2052,04,27", -"2052,04,28", -"2052,05,01", -"2052,05,04", -"2052,05,05", -"2052,05,11", -"2052,05,12", -"2052,05,18", -"2052,05,19", -"2052,05,25", -"2052,05,26", -"2052,06,01", -"2052,06,02", -"2052,06,08", -"2052,06,09", -"2052,06,15", -"2052,06,16", -"2052,06,22", -"2052,06,23", -"2052,06,29", -"2052,06,30", -"2052,07,06", -"2052,07,07", -"2052,07,13", -"2052,07,14", -"2052,07,20", -"2052,07,21", -"2052,07,27", -"2052,07,28", -"2052,08,03", -"2052,08,04", -"2052,08,10", -"2052,08,11", -"2052,08,17", -"2052,08,18", -"2052,08,24", -"2052,08,25", -"2052,08,31", -"2052,09,01", -"2052,09,07", -"2052,09,08", -"2052,09,14", -"2052,09,15", -"2052,09,21", -"2052,09,22", -"2052,09,28", -"2052,09,29", -"2052,10,01", -"2052,10,02", -"2052,10,03", -"2052,10,04", -"2052,10,05", -"2052,10,06", -"2052,10,07", -"2052,10,12", -"2052,10,13", -"2052,10,19", -"2052,10,20", -"2052,10,26", -"2052,10,27", -"2052,11,02", -"2052,11,03", -"2052,11,09", -"2052,11,10", -"2052,11,16", -"2052,11,17", -"2052,11,23", -"2052,11,24", -"2052,11,30", -"2052,12,01", -"2052,12,07", -"2052,12,08", -"2052,12,14", -"2052,12,15", -"2052,12,21", -"2052,12,22", -"2052,12,28", -"2052,12,29", -"2053,01,01", -"2053,01,04", -"2053,01,05", -"2053,01,11", -"2053,01,12", -"2053,01,18", -"2053,01,19", -"2053,01,25", -"2053,01,26", -"2053,02,01", -"2053,02,02", -"2053,02,08", -"2053,02,09", -"2053,02,15", -"2053,02,16", -"2053,02,18", -"2053,02,19", -"2053,02,20", -"2053,02,21", -"2053,02,22", -"2053,02,23", -"2053,02,24", -"2053,03,01", -"2053,03,02", -"2053,03,08", -"2053,03,09", -"2053,03,15", -"2053,03,16", -"2053,03,22", -"2053,03,23", -"2053,03,29", -"2053,03,30", -"2053,04,04", -"2053,04,05", -"2053,04,06", -"2053,04,12", -"2053,04,13", -"2053,04,19", -"2053,04,20", -"2053,04,26", -"2053,04,27", -"2053,05,01", -"2053,05,03", -"2053,05,04", -"2053,05,10", -"2053,05,11", -"2053,05,17", -"2053,05,18", -"2053,05,24", -"2053,05,25", -"2053,05,31", -"2053,06,01", -"2053,06,07", -"2053,06,08", -"2053,06,14", -"2053,06,15", -"2053,06,20", -"2053,06,21", -"2053,06,22", -"2053,06,28", -"2053,06,29", -"2053,07,05", -"2053,07,06", -"2053,07,12", -"2053,07,13", -"2053,07,19", -"2053,07,20", -"2053,07,26", -"2053,07,27", -"2053,08,02", -"2053,08,03", -"2053,08,09", -"2053,08,10", -"2053,08,16", -"2053,08,17", -"2053,08,23", -"2053,08,24", -"2053,08,30", -"2053,08,31", -"2053,09,06", -"2053,09,07", -"2053,09,13", -"2053,09,14", -"2053,09,20", -"2053,09,21", -"2053,09,26", -"2053,09,27", -"2053,09,28", -"2053,10,01", -"2053,10,02", -"2053,10,03", -"2053,10,04", -"2053,10,05", -"2053,10,06", -"2053,10,07", -"2053,10,11", -"2053,10,12", -"2053,10,18", -"2053,10,19", -"2053,10,25", -"2053,10,26", -"2053,11,01", -"2053,11,02", -"2053,11,08", -"2053,11,09", -"2053,11,15", -"2053,11,16", -"2053,11,22", -"2053,11,23", -"2053,11,29", -"2053,11,30", -"2053,12,06", -"2053,12,07", -"2053,12,13", -"2053,12,14", -"2053,12,20", -"2053,12,21", -"2053,12,27", -"2053,12,28", -"2054,01,01", -"2054,01,03", -"2054,01,04", -"2054,01,10", -"2054,01,11", -"2054,01,17", -"2054,01,18", -"2054,01,24", -"2054,01,25", -"2054,01,31", -"2054,02,01", -"2054,02,07", -"2054,02,08", -"2054,02,09", -"2054,02,10", -"2054,02,11", -"2054,02,12", -"2054,02,13", -"2054,02,14", -"2054,02,15", -"2054,02,21", -"2054,02,22", -"2054,02,28", -"2054,03,01", -"2054,03,07", -"2054,03,08", -"2054,03,14", -"2054,03,15", -"2054,03,21", -"2054,03,22", -"2054,03,28", -"2054,03,29", -"2054,04,04", -"2054,04,05", -"2054,04,11", -"2054,04,12", -"2054,04,18", -"2054,04,19", -"2054,04,25", -"2054,04,26", -"2054,05,01", -"2054,05,02", -"2054,05,03", -"2054,05,09", -"2054,05,10", -"2054,05,16", -"2054,05,17", -"2054,05,23", -"2054,05,24", -"2054,05,30", -"2054,05,31", -"2054,06,06", -"2054,06,07", -"2054,06,10", -"2054,06,13", -"2054,06,14", -"2054,06,20", -"2054,06,21", -"2054,06,27", -"2054,06,28", -"2054,07,04", -"2054,07,05", -"2054,07,11", -"2054,07,12", -"2054,07,18", -"2054,07,19", -"2054,07,25", -"2054,07,26", -"2054,08,01", -"2054,08,02", -"2054,08,08", -"2054,08,09", -"2054,08,15", -"2054,08,16", -"2054,08,22", -"2054,08,23", -"2054,08,29", -"2054,08,30", -"2054,09,05", -"2054,09,06", -"2054,09,12", -"2054,09,13", -"2054,09,16", -"2054,09,19", -"2054,09,20", -"2054,09,26", -"2054,09,27", -"2054,10,01", -"2054,10,02", -"2054,10,03", -"2054,10,04", -"2054,10,05", -"2054,10,06", -"2054,10,07", -"2054,10,10", -"2054,10,11", -"2054,10,17", -"2054,10,18", -"2054,10,24", -"2054,10,25", -"2054,10,31", -"2054,11,01", -"2054,11,07", -"2054,11,08", -"2054,11,14", -"2054,11,15", -"2054,11,21", -"2054,11,22", -"2054,11,28", -"2054,11,29", -"2054,12,05", -"2054,12,06", -"2054,12,12", -"2054,12,13", -"2054,12,19", -"2054,12,20", -"2054,12,26", -"2054,12,27", -"2055,01,01", -"2055,01,02", -"2055,01,03", -"2055,01,09", -"2055,01,10", -"2055,01,16", -"2055,01,17", -"2055,01,23", -"2055,01,24", -"2055,01,27", -"2055,01,28", -"2055,01,29", -"2055,01,30", -"2055,01,31", -"2055,02,01", -"2055,02,02", -"2055,02,06", -"2055,02,07", -"2055,02,13", -"2055,02,14", -"2055,02,20", -"2055,02,21", -"2055,02,27", -"2055,02,28", -"2055,03,06", -"2055,03,07", -"2055,03,13", -"2055,03,14", -"2055,03,20", -"2055,03,21", -"2055,03,27", -"2055,03,28", -"2055,04,03", -"2055,04,04", -"2055,04,05", -"2055,04,10", -"2055,04,11", -"2055,04,17", -"2055,04,18", -"2055,04,24", -"2055,04,25", -"2055,05,01", -"2055,05,02", -"2055,05,08", -"2055,05,09", -"2055,05,15", -"2055,05,16", -"2055,05,22", -"2055,05,23", -"2055,05,29", -"2055,05,30", -"2055,06,05", -"2055,06,06", -"2055,06,12", -"2055,06,13", -"2055,06,19", -"2055,06,20", -"2055,06,26", -"2055,06,27", -"2055,07,03", -"2055,07,04", -"2055,07,10", -"2055,07,11", -"2055,07,17", -"2055,07,18", -"2055,07,24", -"2055,07,25", -"2055,07,31", -"2055,08,01", -"2055,08,07", -"2055,08,08", -"2055,08,14", -"2055,08,15", -"2055,08,21", -"2055,08,22", -"2055,08,28", -"2055,08,29", -"2055,09,04", -"2055,09,05", -"2055,09,11", -"2055,09,12", -"2055,09,18", -"2055,09,19", -"2055,09,25", -"2055,09,26", -"2055,10,01", -"2055,10,02", -"2055,10,03", -"2055,10,04", -"2055,10,05", -"2055,10,06", -"2055,10,07", -"2055,10,09", -"2055,10,10", -"2055,10,16", -"2055,10,17", -"2055,10,23", -"2055,10,24", -"2055,10,30", -"2055,10,31", -"2055,11,06", -"2055,11,07", -"2055,11,13", -"2055,11,14", -"2055,11,20", -"2055,11,21", -"2055,11,27", -"2055,11,28", -"2055,12,04", -"2055,12,05", -"2055,12,11", -"2055,12,12", -"2055,12,18", -"2055,12,19", -"2055,12,25", -"2055,12,26", -"2056,01,01", -"2056,01,02", -"2056,01,08", -"2056,01,09", -"2056,01,15", -"2056,01,16", -"2056,01,22", -"2056,01,23", -"2056,01,29", -"2056,01,30", -"2056,02,05", -"2056,02,06", -"2056,02,12", -"2056,02,13", -"2056,02,14", -"2056,02,15", -"2056,02,16", -"2056,02,17", -"2056,02,18", -"2056,02,19", -"2056,02,20", -"2056,02,26", -"2056,02,27", -"2056,03,04", -"2056,03,05", -"2056,03,11", -"2056,03,12", -"2056,03,18", -"2056,03,19", -"2056,03,25", -"2056,03,26", -"2056,04,01", -"2056,04,02", -"2056,04,03", -"2056,04,08", -"2056,04,09", -"2056,04,15", -"2056,04,16", -"2056,04,22", -"2056,04,23", -"2056,04,29", -"2056,04,30", -"2056,05,01", -"2056,05,06", -"2056,05,07", -"2056,05,13", -"2056,05,14", -"2056,05,20", -"2056,05,21", -"2056,05,27", -"2056,05,28", -"2056,06,03", -"2056,06,04", -"2056,06,10", -"2056,06,11", -"2056,06,17", -"2056,06,18", -"2056,06,24", -"2056,06,25", -"2056,07,01", -"2056,07,02", -"2056,07,08", -"2056,07,09", -"2056,07,15", -"2056,07,16", -"2056,07,22", -"2056,07,23", -"2056,07,29", -"2056,07,30", -"2056,08,05", -"2056,08,06", -"2056,08,12", -"2056,08,13", -"2056,08,19", -"2056,08,20", -"2056,08,26", -"2056,08,27", -"2056,09,02", -"2056,09,03", -"2056,09,09", -"2056,09,10", -"2056,09,16", -"2056,09,17", -"2056,09,23", -"2056,09,24", -"2056,09,30", -"2056,10,01", -"2056,10,02", -"2056,10,03", -"2056,10,04", -"2056,10,05", -"2056,10,06", -"2056,10,07", -"2056,10,08", -"2056,10,14", -"2056,10,15", -"2056,10,21", -"2056,10,22", -"2056,10,28", -"2056,10,29", -"2056,11,04", -"2056,11,05", -"2056,11,11", -"2056,11,12", -"2056,11,18", -"2056,11,19", -"2056,11,25", -"2056,11,26", -"2056,12,02", -"2056,12,03", -"2056,12,09", -"2056,12,10", -"2056,12,16", -"2056,12,17", -"2056,12,23", -"2056,12,24", -"2056,12,30", -"2056,12,31", -"2057,01,01", -"2057,01,06", -"2057,01,07", -"2057,01,13", -"2057,01,14", -"2057,01,20", -"2057,01,21", -"2057,01,27", -"2057,01,28", -"2057,02,03", -"2057,02,04", -"2057,02,05", -"2057,02,06", -"2057,02,07", -"2057,02,08", -"2057,02,09", -"2057,02,10", -"2057,02,11", -"2057,02,17", -"2057,02,18", -"2057,02,24", -"2057,02,25", -"2057,03,03", -"2057,03,04", -"2057,03,10", -"2057,03,11", -"2057,03,17", -"2057,03,18", -"2057,03,24", -"2057,03,25", -"2057,03,31", -"2057,04,01", -"2057,04,04", -"2057,04,07", -"2057,04,08", -"2057,04,14", -"2057,04,15", -"2057,04,21", -"2057,04,22", -"2057,04,28", -"2057,04,29", -"2057,05,01", -"2057,05,05", -"2057,05,06", -"2057,05,12", -"2057,05,13", -"2057,05,19", -"2057,05,20", -"2057,05,26", -"2057,05,27", -"2057,06,02", -"2057,06,03", -"2057,06,06", -"2057,06,09", -"2057,06,10", -"2057,06,16", -"2057,06,17", -"2057,06,23", -"2057,06,24", -"2057,06,30", -"2057,07,01", -"2057,07,07", -"2057,07,08", -"2057,07,14", -"2057,07,15", -"2057,07,21", -"2057,07,22", -"2057,07,28", -"2057,07,29", -"2057,08,04", -"2057,08,05", -"2057,08,11", -"2057,08,12", -"2057,08,18", -"2057,08,19", -"2057,08,25", -"2057,08,26", -"2057,09,01", -"2057,09,02", -"2057,09,08", -"2057,09,09", -"2057,09,13", -"2057,09,15", -"2057,09,16", -"2057,09,22", -"2057,09,23", -"2057,09,29", -"2057,09,30", -"2057,10,01", -"2057,10,02", -"2057,10,03", -"2057,10,04", -"2057,10,05", -"2057,10,06", -"2057,10,07", -"2057,10,13", -"2057,10,14", -"2057,10,20", -"2057,10,21", -"2057,10,27", -"2057,10,28", -"2057,11,03", -"2057,11,04", -"2057,11,10", -"2057,11,11", -"2057,11,17", -"2057,11,18", -"2057,11,24", -"2057,11,25", -"2057,12,01", -"2057,12,02", -"2057,12,08", -"2057,12,09", -"2057,12,15", -"2057,12,16", -"2057,12,22", -"2057,12,23", -"2057,12,29", -"2057,12,30", -"2058,01,01", -"2058,01,05", -"2058,01,06", -"2058,01,12", -"2058,01,13", -"2058,01,19", -"2058,01,20", -"2058,01,23", -"2058,01,24", -"2058,01,25", -"2058,01,26", -"2058,01,27", -"2058,01,28", -"2058,01,29", -"2058,02,02", -"2058,02,03", -"2058,02,09", -"2058,02,10", -"2058,02,16", -"2058,02,17", -"2058,02,23", -"2058,02,24", -"2058,03,02", -"2058,03,03", -"2058,03,09", -"2058,03,10", -"2058,03,16", -"2058,03,17", -"2058,03,23", -"2058,03,24", -"2058,03,30", -"2058,03,31", -"2058,04,04", -"2058,04,06", -"2058,04,07", -"2058,04,13", -"2058,04,14", -"2058,04,20", -"2058,04,21", -"2058,04,27", -"2058,04,28", -"2058,05,01", -"2058,05,04", -"2058,05,05", -"2058,05,11", -"2058,05,12", -"2058,05,18", -"2058,05,19", -"2058,05,25", -"2058,05,26", -"2058,06,01", -"2058,06,02", -"2058,06,08", -"2058,06,09", -"2058,06,15", -"2058,06,16", -"2058,06,22", -"2058,06,23", -"2058,06,25", -"2058,06,29", -"2058,06,30", -"2058,07,06", -"2058,07,07", -"2058,07,13", -"2058,07,14", -"2058,07,20", -"2058,07,21", -"2058,07,27", -"2058,07,28", -"2058,08,03", -"2058,08,04", -"2058,08,10", -"2058,08,11", -"2058,08,17", -"2058,08,18", -"2058,08,24", -"2058,08,25", -"2058,08,31", -"2058,09,01", -"2058,09,07", -"2058,09,08", -"2058,09,14", -"2058,09,15", -"2058,09,21", -"2058,09,22", -"2058,09,28", -"2058,09,29", -"2058,10,01", -"2058,10,02", -"2058,10,03", -"2058,10,04", -"2058,10,05", -"2058,10,06", -"2058,10,07", -"2058,10,12", -"2058,10,13", -"2058,10,19", -"2058,10,20", -"2058,10,26", -"2058,10,27", -"2058,11,02", -"2058,11,03", -"2058,11,09", -"2058,11,10", -"2058,11,16", -"2058,11,17", -"2058,11,23", -"2058,11,24", -"2058,11,30", -"2058,12,01", -"2058,12,07", -"2058,12,08", -"2058,12,14", -"2058,12,15", -"2058,12,21", -"2058,12,22", -"2058,12,28", -"2058,12,29", -"2059,01,01", -"2059,01,04", -"2059,01,05", -"2059,01,11", -"2059,01,12", -"2059,01,18", -"2059,01,19", -"2059,01,25", -"2059,01,26", -"2059,02,01", -"2059,02,02", -"2059,02,08", -"2059,02,09", -"2059,02,11", -"2059,02,12", -"2059,02,13", -"2059,02,14", -"2059,02,15", -"2059,02,16", -"2059,02,17", -"2059,02,22", -"2059,02,23", -"2059,03,01", -"2059,03,02", -"2059,03,08", -"2059,03,09", -"2059,03,15", -"2059,03,16", -"2059,03,22", -"2059,03,23", -"2059,03,29", -"2059,03,30", -"2059,04,05", -"2059,04,06", -"2059,04,12", -"2059,04,13", -"2059,04,19", -"2059,04,20", -"2059,04,26", -"2059,04,27", -"2059,05,01", -"2059,05,03", -"2059,05,04", -"2059,05,10", -"2059,05,11", -"2059,05,17", -"2059,05,18", -"2059,05,24", -"2059,05,25", -"2059,05,31", -"2059,06,01", -"2059,06,07", -"2059,06,08", -"2059,06,14", -"2059,06,15", -"2059,06,21", -"2059,06,22", -"2059,06,28", -"2059,06,29", -"2059,07,05", -"2059,07,06", -"2059,07,12", -"2059,07,13", -"2059,07,19", -"2059,07,20", -"2059,07,26", -"2059,07,27", -"2059,08,02", -"2059,08,03", -"2059,08,09", -"2059,08,10", -"2059,08,16", -"2059,08,17", -"2059,08,23", -"2059,08,24", -"2059,08,30", -"2059,08,31", -"2059,09,06", -"2059,09,07", -"2059,09,13", -"2059,09,14", -"2059,09,20", -"2059,09,21", -"2059,09,27", -"2059,09,28", -"2059,10,01", -"2059,10,02", -"2059,10,03", -"2059,10,04", -"2059,10,05", -"2059,10,06", -"2059,10,07", -"2059,10,11", -"2059,10,12", -"2059,10,18", -"2059,10,19", -"2059,10,25", -"2059,10,26", -"2059,11,01", -"2059,11,02", -"2059,11,08", -"2059,11,09", -"2059,11,15", -"2059,11,16", -"2059,11,22", -"2059,11,23", -"2059,11,29", -"2059,11,30", -"2059,12,06", -"2059,12,07", -"2059,12,13", -"2059,12,14", -"2059,12,20", -"2059,12,21", -"2059,12,27", -"2059,12,28", -"2060,01,01", -"2060,01,03", -"2060,01,04", -"2060,01,10", -"2060,01,11", -"2060,01,17", -"2060,01,18", -"2060,01,24", -"2060,01,25", -"2060,01,31", -"2060,02,01", -"2060,02,02", -"2060,02,03", -"2060,02,04", -"2060,02,05", -"2060,02,06", -"2060,02,07", -"2060,02,08", -"2060,02,14", -"2060,02,15", -"2060,02,21", -"2060,02,22", -"2060,02,28", -"2060,02,29", -"2060,03,06", -"2060,03,07", -"2060,03,13", -"2060,03,14", -"2060,03,20", -"2060,03,21", -"2060,03,27", -"2060,03,28", -"2060,04,03", -"2060,04,04", -"2060,04,10", -"2060,04,11", -"2060,04,17", -"2060,04,18", -"2060,04,24", -"2060,04,25", -"2060,05,01", -"2060,05,02", -"2060,05,08", -"2060,05,09", -"2060,05,15", -"2060,05,16", -"2060,05,22", -"2060,05,23", -"2060,05,29", -"2060,05,30", -"2060,06,03", -"2060,06,05", -"2060,06,06", -"2060,06,12", -"2060,06,13", -"2060,06,19", -"2060,06,20", -"2060,06,26", -"2060,06,27", -"2060,07,03", -"2060,07,04", -"2060,07,10", -"2060,07,11", -"2060,07,17", -"2060,07,18", -"2060,07,24", -"2060,07,25", -"2060,07,31", -"2060,08,01", -"2060,08,07", -"2060,08,08", -"2060,08,14", -"2060,08,15", -"2060,08,21", -"2060,08,22", -"2060,08,28", -"2060,08,29", -"2060,09,04", -"2060,09,05", -"2060,09,09", -"2060,09,11", -"2060,09,12", -"2060,09,18", -"2060,09,19", -"2060,09,25", -"2060,09,26", -"2060,10,01", -"2060,10,02", -"2060,10,03", -"2060,10,04", -"2060,10,05", -"2060,10,06", -"2060,10,07", -"2060,10,09", -"2060,10,10", -"2060,10,16", -"2060,10,17", -"2060,10,23", -"2060,10,24", -"2060,10,30", -"2060,10,31", -"2060,11,06", -"2060,11,07", -"2060,11,13", -"2060,11,14", -"2060,11,20", -"2060,11,21", -"2060,11,27", -"2060,11,28", -"2060,12,04", -"2060,12,05", -"2060,12,11", -"2060,12,12", -"2060,12,18", -"2060,12,19", -"2060,12,25", -"2060,12,26" -] -} \ No newline at end of file diff --git a/YLErpUnitTest/ExternalLibTests/AutoMapperTest.cs b/YLErpUnitTest/ExternalLibTests/AutoMapperTest.cs deleted file mode 100644 index da3a52a9..00000000 --- a/YLErpUnitTest/ExternalLibTests/AutoMapperTest.cs +++ /dev/null @@ -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(); - }); - - var mapper = config.CreateMapper(); - var mapA = new MapA(); - var mapB = mapper.Map(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(volSrc); - - Assert.AreEqual(volDest.id, 0); - - var config = new ComparisonConfig - { - MembersToIgnore = new List() { nameof(volatility.id), nameof(volatility.EncryptId) } - }; - var compareLogic = new CompareLogic(config); - - ComparisonResult result = compareLogic.Compare(volSrc, volDest); - - Assert.IsTrue(result.AreEqual); - } - } -} diff --git a/YLErpUnitTest/ExternalLibTests/DbfReaderTest.cs b/YLErpUnitTest/ExternalLibTests/DbfReaderTest.cs deleted file mode 100644 index ee9a706b..00000000 --- a/YLErpUnitTest/ExternalLibTests/DbfReaderTest.cs +++ /dev/null @@ -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)); - } - } - } - } -} diff --git a/YLErpUnitTest/ExternalLibTests/EntityFrameworkTest .cs b/YLErpUnitTest/ExternalLibTests/EntityFrameworkTest .cs deleted file mode 100644 index ce437df6..00000000 --- a/YLErpUnitTest/ExternalLibTests/EntityFrameworkTest .cs +++ /dev/null @@ -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(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(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"); - } - } -} diff --git a/YLErpUnitTest/ExternalLibTests/ExcelDataReaderTest.cs b/YLErpUnitTest/ExternalLibTests/ExcelDataReaderTest.cs deleted file mode 100644 index b8f3d93e..00000000 --- a/YLErpUnitTest/ExternalLibTests/ExcelDataReaderTest.cs +++ /dev/null @@ -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(); - } - } -} diff --git a/YLErpUnitTest/Helpers/InnerExchangeOptionPriceProvider.cs b/YLErpUnitTest/Helpers/InnerExchangeOptionPriceProvider.cs deleted file mode 100644 index 891fd187..00000000 --- a/YLErpUnitTest/Helpers/InnerExchangeOptionPriceProvider.cs +++ /dev/null @@ -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; - } - } - } -} diff --git a/YLErpUnitTest/Helpers/InnerExchangeTradeCommissionCalc.cs b/YLErpUnitTest/Helpers/InnerExchangeTradeCommissionCalc.cs deleted file mode 100644 index 089753ec..00000000 --- a/YLErpUnitTest/Helpers/InnerExchangeTradeCommissionCalc.cs +++ /dev/null @@ -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 tradeList, bool isActualTrade = true) - { - return new InnerTradeCommissionResult(null); - } - } -} diff --git a/YLErpUnitTest/Helpers/InnerTradeCommissionResult.cs b/YLErpUnitTest/Helpers/InnerTradeCommissionResult.cs deleted file mode 100644 index ea5730ec..00000000 --- a/YLErpUnitTest/Helpers/InnerTradeCommissionResult.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System.Collections.Generic; -using YLErp.Modules.CalculationModule.Abstract; - -namespace YLErp.Helpers -{ - class InnerTradeCommissionResult : ITradeCommissionCalcResult - { - readonly Dictionary _dic; - - public InnerTradeCommissionResult(Dictionary dic) - { - _dic = dic; - } - - public double GetTradeCommission(int tradeId) - { - if (_dic != null && _dic.TryGetValue(tradeId, out var dd)) - { - return dd; - } - return 0; - } - } -} diff --git a/YLErpUnitTest/Helpers/InnerUnderlyingDataProvider.cs b/YLErpUnitTest/Helpers/InnerUnderlyingDataProvider.cs deleted file mode 100644 index 1ae83a15..00000000 --- a/YLErpUnitTest/Helpers/InnerUnderlyingDataProvider.cs +++ /dev/null @@ -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 - { - /// - /// 获取标的数据 - /// - public underlying_manager GetUnderlying(int underlyingId) - { - return DataCacheProvider.GetUnderlyingDataSource().GetData(underlyingId); - } - - /// - /// 获取标的数据 - /// - public underlying_manager GetUnderlying(string underlyingCode) - { - return DataCacheProvider.GetUnderlyingDataSource().GetData(underlyingCode); - } - - /// - /// - /// - public underlying_manager GetUnderlying(string underlyingCode, out double contractSize) - { - var um = DataCacheProvider.GetUnderlyingDataSource().GetData(underlyingCode); - contractSize = um?.ContractSize ?? 1; - return um; - } - - /// - /// 获取品种数据 - /// - public Variety GetVariety(int varietyId) - { - return DataCacheProvider.GetVarietyDataSource().GetData(varietyId); - } - - /// - /// 获取品种信息 - /// - public Variety GetVariety(string underlyingCode, out double contractSize) - { - var um = GetUnderlying(underlyingCode); - contractSize = um?.ContractSize ?? 1; - return DataCacheProvider.GetVarietyDataSource().GetData(um?.UnderlyingTypeId ?? 0); - } - - /// - /// 获取品种数据 - /// - /// 标的代码 - public Variety GetVariety(string underlyingCode) - { - var um = GetUnderlying(underlyingCode); - return DataCacheProvider.GetVarietyDataSource().GetData(um?.UnderlyingTypeId ?? 0); - } - - /// - /// 根据标的代码获取份额和数量的乘积因子 - /// - public int GetCountRatio(string underlyingCode) - { - return DataCacheProvider.GetUnderlyingDataSource().GetCountRatio(underlyingCode); - } - - /// - /// 尝试获取标的过期日(股票:2099-01-01) - /// - 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; - } - - /// - /// 根据标的代码获取当前价格 - /// - public double GetPrice(string underlyingCode) - { - return DataCacheProvider.GetUnderlyingDataSource().TryGetPrice(underlyingCode, out var price) ? price : 0; - } - - /// - /// 根据标的代码获取当前价格 - /// - public bool TryGetPrice(string underlyingCode, out double price) - { - return DataCacheProvider.GetUnderlyingDataSource().TryGetPrice(underlyingCode, out price); - } - - /// - /// 获取相关性 - /// - 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)); - } - - /// - /// 获取场外期权标的信息 - /// - 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" - }; - } - - /// - /// 获取组合标的 - /// - public SyntheticUnderlying GetSyntheticUnderlying(string underlyingCode) - { - return DataCacheProvider.GetUnderlyingDataSource().GetSyntheticUnderlying(underlyingCode); - } - } -} diff --git a/YLErpUnitTest/Helpers/InnerUnderlyingPriceProvider.cs b/YLErpUnitTest/Helpers/InnerUnderlyingPriceProvider.cs deleted file mode 100644 index 41172f73..00000000 --- a/YLErpUnitTest/Helpers/InnerUnderlyingPriceProvider.cs +++ /dev/null @@ -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; - } - } - } -} diff --git a/YLErpUnitTest/Modules/BaseModule/OtcFormatTest.cs b/YLErpUnitTest/Modules/BaseModule/OtcFormatTest.cs deleted file mode 100644 index 750c4df8..00000000 --- a/YLErpUnitTest/Modules/BaseModule/OtcFormatTest.cs +++ /dev/null @@ -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); - } - } -} diff --git a/YLErpUnitTest/Modules/CalculationModule/ForwardradeCalcServiceTest.cs b/YLErpUnitTest/Modules/CalculationModule/ForwardradeCalcServiceTest.cs deleted file mode 100644 index 2f84ba1c..00000000 --- a/YLErpUnitTest/Modules/CalculationModule/ForwardradeCalcServiceTest.cs +++ /dev/null @@ -1,118 +0,0 @@ -using Microsoft.VisualStudio.TestTools.UnitTesting; -using System; -using YLErp.BLL.Calculation; - -namespace YLErp.Modules.CalculationModule -{ - /// - /// - /// - [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); - } - } - - /// - /// 计算远期交易(买方角度)ValueCalculator.CalculateForward - /// - 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; - } - - /// - /// 计算PV/Risk(交易员角度) - /// - 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); - } - } -} diff --git a/YLErpUnitTest/Modules/CalculationModule/HedgePnlCalcTest.cs b/YLErpUnitTest/Modules/CalculationModule/HedgePnlCalcTest.cs deleted file mode 100644 index 3eb4028b..00000000 --- a/YLErpUnitTest/Modules/CalculationModule/HedgePnlCalcTest.cs +++ /dev/null @@ -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 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 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(); - } - } -} diff --git a/YLErpUnitTest/Modules/CalculationModule/OptionCaclTest.cs b/YLErpUnitTest/Modules/CalculationModule/OptionCaclTest.cs deleted file mode 100644 index e8a4fa0e..00000000 --- a/YLErpUnitTest/Modules/CalculationModule/OptionCaclTest.cs +++ /dev/null @@ -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(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>(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); - } - } - } -} diff --git a/YLErpUnitTest/Modules/CalculationModule/OptionCalculatorCompare.cs b/YLErpUnitTest/Modules/CalculationModule/OptionCalculatorCompare.cs deleted file mode 100644 index f8c6ba3c..00000000 --- a/YLErpUnitTest/Modules/CalculationModule/OptionCalculatorCompare.cs +++ /dev/null @@ -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 -{ - /// - /// 期权计算比较(新版本和老版本) - /// - [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(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(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); - } - } -} diff --git a/YLErpUnitTest/Modules/CalculationModule/SSpreadOptionCalcTest.cs b/YLErpUnitTest/Modules/CalculationModule/SSpreadOptionCalcTest.cs deleted file mode 100644 index 788d3433..00000000 --- a/YLErpUnitTest/Modules/CalculationModule/SSpreadOptionCalcTest.cs +++ /dev/null @@ -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 - { - /// - /// 股指期货类型转换为商品期货类型 - /// - [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 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 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(); - - // 先获取返回的结果矩阵中的对角线上的元素,对应的是每个标的的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(); - } - } -} diff --git a/YLErpUnitTest/Modules/CalculationModule/V1/OptionCalculatorV1.cs b/YLErpUnitTest/Modules/CalculationModule/V1/OptionCalculatorV1.cs deleted file mode 100644 index 73a93f23..00000000 --- a/YLErpUnitTest/Modules/CalculationModule/V1/OptionCalculatorV1.cs +++ /dev/null @@ -1,8360 +0,0 @@ -using Qdp.ComputeService.Data.CommonModels.ValuationParams.Equity; -using Qdp.ComputeService.Data.CommonModels.ValuationParams.FixedIncome; -using Qdp.ComputeServiceV2.Data.CommonModels.TradeInfos; -using Qdp.ComputeServiceV2.Data.CommonModels.TradeInfos.Options; -using Qdp.ComputeServiceV2.Data.CommonModels.TradeInfos.Rates; -using Qdp.Foundation.Implementations; -using Qdp.Pricing.Base.Enums; -using Qdp.Pricing.Base.Implementations; -using Qdp.Pricing.Base.Utilities; -using Qdp.Pricing.Library.Common.Interfaces; -using Qdp.Pricing.Library.Common.Products.Rates; -using Qdp.Pricing.Library.Common.Products.Rates.Engines; -using Qdp.Pricing.Library.Options.Products.Accumulator; -using Qdp.Pricing.Library.Options.Products.Accumulator.Engines.Analytical; -using Qdp.Pricing.Library.Options.Products.Accumulator.Engines.Numerical; -using Qdp.Pricing.Library.Options.Products.Airbag; -using Qdp.Pricing.Library.Options.Products.Airbag.Engines.Analytical; -using Qdp.Pricing.Library.Options.Products.Asian; -using Qdp.Pricing.Library.Options.Products.AsianSyntheticSpread; -using Qdp.Pricing.Library.Options.Products.AsianSyntheticSpread.Engines.Analytical; -using Qdp.Pricing.Library.Options.Products.Autocall.Phoenix; -using Qdp.Pricing.Library.Options.Products.Autocall.Snowball; -using Qdp.Pricing.Library.Options.Products.Barrier; -using Qdp.Pricing.Library.Options.Products.Binary; -using Qdp.Pricing.Library.Options.Products.DoubleSharkFin; -using Qdp.Pricing.Library.Options.Products.PayoffEnhance; -using Qdp.Pricing.Library.Options.Products.PayoffEnhance.Engines.Analytical; -using Qdp.Pricing.Library.Options.Products.Rainbow; -using Qdp.Pricing.Library.Options.Products.RangeAccrual; -using Qdp.Pricing.Library.Options.Products.Spread; -using Qdp.Pricing.Library.Options.Products.SyntheticSpread; -using Qdp.Pricing.Library.Options.Products.Vanilla; -using Qdp.Pricing.Library.Options.Utilities; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.CompilerServices; -using YLErp.BLL; -using YLErp.BLL.Calculation; -using YLErp.BLL.Calculation.Engine; -using YLErp.Commons; -using YLErp.DBModels; -using YLErp.DBModels.Helpers; -using YLErp.Model; -using YLErp.Modules.CalculationModule; -using YLErp.Modules.SkewMapVolModule; -using YLErp.QdpModule; - -namespace YLErp.Modules.CalculationModule -{ - /// - /// 期权计算类 - /// - public static class OptionCalculatorV1 - { - #region 香草期权 - private static VanillaOptionTrade CreateVanillaOptionTrade( - 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, - bool isMoneynessOption = false, - double initialSpotPrice = 0.0, - Dictionary dividends = null, - bool hasNightMarket = false, - bool commodityFuturesPreciseTimeMode = false, - double timeToMaturityDays = double.NaN, - double riskFreeRateOverride = double.NaN, - double dividendRateOverride = double.NaN) - //string optionDayCount = "Act365") - { - underlyingInstrumentType = ConvertInstrumentType(underlyingInstrumentType); - var exercise = QdpConverter.ConvertExerciseType(exerciseType); - var optionStartDate = startDate.ToDate(); - var underlyingMaturityDate = string.IsNullOrWhiteSpace(endDate) ? null : endDate.ToDate(); - var temp_exerciseDate = exerciseDate.ToDate(); - - //if (temp_exerciseDate < optionStartDate) - //{ - // throw new Exception("到期日期不能小于起始日"); - //} - - Date[] exerciseDates; - Date[] observationDates; - 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 }; - } - - var optionDayCount = CalculatorHelper.GetTradeDayCount(); - - var pricingTOverride = double.IsNaN(timeToMaturityDays) ? double.NaN : QdpCalendarHelper.CalculateTFromDays(timeToMaturityDays, optionDayCount, optionStartDate.DateTime); - - var vanillaOption = - new VanillaOption( - startDate: optionStartDate, - maturityDate: underlyingMaturityDate, - exercise: exercise, - optionType: (OptionType)Enum.Parse(typeof(OptionType), optionType), - strike: strike, - underlyingInstrumentType: (InstrumentType)Enum.Parse(typeof(InstrumentType), underlyingInstrumentType), - calendar: CalendarImpl.Get("chn"), - dayCount: optionDayCount.ToDayCountImpl(), - payoffCcy: CurrencyCode.CNY, - settlementCcy: CurrencyCode.CNY, - exerciseDates: exerciseDates, - observationDates: observationDates, - notional: notional, - settlementGap: null, - optionPremiumPaymentDate: null, - optionPremium: 0.0, - isMoneynessOption: isMoneynessOption, - initialSpotPrice: initialSpotPrice, - dividends: 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 VanillaOptionTrade( - tradeId, - tradeDate.ToDate(), - vanillaOption.StartDate, - vanillaOption.ExerciseDates.Last(), - QdpConverter.ConvertTradeType(tradeType), - vanillaOption.Notional, - 0.0, - vanillaOption) - { - - ValuationParameters = new OptionValuationParameters("RiskFreeDiscountCurve", MarketProxy.ConstantZeroCurve, volSurfaceName, vanillaOption.UnderlyingTickers[0]), - ProtectionRate = principalRate, - ParticipationRate = participationRate, - AnnualizedFactor = annualizeFactor, - OriginalNotional = TradeHelper.GetStockEqvNotional(notional * initialSpotPrice, participationRate, annualizeFactor) - }; - } - - /// - /// 计算香草期权的估值与风险 - /// - /// MarketProxy对象 - /// 估值日期 - /// 标的代码 - /// 标的类型 - /// 行权价 - /// 用户指定距离到期日的天数,可以为小数 - private static TradeValueResult ValueVanillaOption( - IQdpMarketProxy marketProxy, - string valueDate, - string underlyingTicker, - string underlyingInstrumentType, - double strike, - string startDate, - string endDate, - string optionType, - string exerciseType, - double spotPrice, - double notional, - string volSurfaceName, - double riskFreeRate, - string modelName, - string tradeType, - string exerciseDate, - double participationRate, - double principalRate, - bool isAnnualized, - double annualizeFactor, - double dividendRate = 0.0, - bool isMoneynessOption = false, - double initialSpotPrice = 0.0, - Dictionary dividends = null, - bool hasNightMarket = false, - bool commodityFuturesPreciseTimeMode = false, - string engineName = null, - string discountCurveName = null, - double timeToMaturityDays = double.NaN, - bool isForwardTrade = false, - double riskFreeRateOverride = double.NaN, - double dividendRateOverride = double.NaN, - PricingRequest pricingRequest = QdpPricingRequest.BASIC_GREEKS) - { - try - { - if (string.IsNullOrWhiteSpace(volSurfaceName)) - { - volSurfaceName = underlyingTicker.GenerateVolSurfaceKey(); - } - - var optionTrade = CreateVanillaOptionTrade( - null, - volSurfaceName, - startDate, - underlyingTicker, - underlyingInstrumentType, - strike, - startDate, - endDate, - optionType, - exerciseType, - notional, - tradeType, - exerciseDate, - participationRate, - principalRate, - isAnnualized, - annualizeFactor, - isMoneynessOption, - initialSpotPrice, - dividends, - hasNightMarket: hasNightMarket, - commodityFuturesPreciseTimeMode: commodityFuturesPreciseTimeMode, - timeToMaturityDays: timeToMaturityDays, - riskFreeRateOverride: riskFreeRateOverride, - dividendRateOverride: dividendRateOverride).CheckMaturityDate(); - - var market = marketProxy.GetQdpMarket(valueDate); - if (market == null) - { - return null; - } - - 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 = null; - string dividendCurveName = null; - if (underlyingInstrumentType == "Stock") - { - //设置DividendCurve - 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 option = optionTrade.Instrument as VanillaOption; - var factory = OptionEngineFactory.GetEngineFactory("VanillaOption"); - var engine = factory.GetEngine(engineName, option.Exercise); - - var results = optionTrade.CalculateRisks(marketProxy.GetQdpMarket(valueDate), pricingRequest, engine, parameters); - - if (useLocalDiscountCurve) - { - marketProxy.RemoveYieldCurve(discountCurveName, valueDate); - } - - if (!string.IsNullOrEmpty(dividendCurveName)) - { - marketProxy.RemoveYieldCurve(dividendCurveName, valueDate); - } - - if (results.Succeeded) - { - var ret = new TradeValueResult() - { - UnderlyingCode = underlyingTicker, - Pv = results.Pv, - Delta = results.Delta, - Gamma = results.Gamma, - Vega = results.Vega, - CalendarDayTheta = results.Theta, - TradingDayTheta = results.ThetaPnL, - Rho = results.Rho, - DeltaCash = results.DeltaCash, - GammaCash = results.GammaCash, - Vol = results.PricingVol, - RoundedPv = OtcFormatHelper.FormatValue(results.Pv / notional, 2) * notional - }; - return ret; - } - else - { - return null; - } - } - catch (Exception ex) - { - LogFactory.GetLogger("期权计算").Error("ValueVanillaOption:" + underlyingTicker, ex); - throw new Exception($"香草期权处理失败[标的:{underlyingTicker},开始日:{startDate},结束日:{endDate},行权日:{exerciseDate}]", ex); - } - } - - private static TradeValueResult ValueVanillaOptionTrade( - VolConstructionType volConstructionType, - IQdpMarketProxy marketProxy, - string valueDate, - string underlyingTicker, - string underlyingInstrumentType, - double strike, - string startDate, - string endDate, - string optionType, - string exerciseType, - double spotPrice, - double notional, - string volSurfaceName, - double riskFreeRate, - string modelName, - string tradeType, - string exerciseDate, - double participationRate, - double principalRate, - bool isAnnualized, - double annualizeFactor, - double dividendRate = 0.0, - bool isMoneynessOption = false, - double initialSpotPrice = 0.0, - Dictionary dividends = null, - bool hasNightMarket = false, - bool commodityFuturesPreciseTimeMode = false, - string engineName = null, - string discountCurveName = null, - double timeToMaturityDays = double.NaN, - bool isForwardTrade = false, - bool ignoreSkewMap = false, - double riskFreeRateOverride = double.NaN, - double dividendRateOverride = double.NaN, - PricingRequest pricingRequest = QdpPricingRequest.BASIC_GREEKS) - { - if (volConstructionType == VolConstructionType.Normal || ignoreSkewMap) - { - return ValueVanillaOption( - marketProxy, - valueDate, - underlyingTicker, - underlyingInstrumentType, - strike, - startDate, - endDate, - optionType, - exerciseType, - spotPrice, - notional, - volSurfaceName, - riskFreeRate, - modelName, - tradeType, - exerciseDate, - participationRate, - principalRate, - isAnnualized, - annualizeFactor, - dividendRate, - isMoneynessOption, - initialSpotPrice, - dividends, - hasNightMarket, - commodityFuturesPreciseTimeMode, - engineName, - discountCurveName, - timeToMaturityDays, - isForwardTrade, - riskFreeRateOverride: riskFreeRateOverride, - dividendRateOverride: dividendRateOverride, - pricingRequest: pricingRequest); - } - else // VolConstructionType.SkewMap - { - var tradeId = Guid.NewGuid().ToString(); - SetSkewMapVol( - marketProxy, - valueDate, - underlyingTicker, - exerciseDate, - strike, - TradeCalcHelper.IsBuy(tradeType), - QdpHelper.IsCall(optionType), - tradeId, - spotPrice, - null, - timeToMaturityDays); - - return ValueVanillaOption( - marketProxy, - valueDate, - underlyingTicker, - underlyingInstrumentType, - strike, - startDate, - endDate, - optionType, - exerciseType, - spotPrice, - notional, - tradeId.GenerateVolSurfaceKey(), - riskFreeRate, - modelName, - tradeType, - exerciseDate, - participationRate, - principalRate, - isAnnualized, - annualizeFactor, - dividendRate, - isMoneynessOption, - initialSpotPrice, - dividends, - hasNightMarket, - commodityFuturesPreciseTimeMode, - engineName, - discountCurveName, - timeToMaturityDays, - isForwardTrade, - riskFreeRateOverride: riskFreeRateOverride, - dividendRateOverride: dividendRateOverride, - pricingRequest: pricingRequest); - } - } - - /// - /// 计算香草期权的估值与风险,本函数会根据是否为SkewMap波动率来调整波动率获取方式 - /// - public static TradeValueResult ValueVanillaOptionTrade( - IQdpMarketProxy marketProxy, - string valueDate, - string underlyingTicker, - string underlyingInstrumentType, - double strike, - string startDate, - string endDate, - string optionType, - string exerciseType, - double spotPrice, - double notional, - string volSurfaceName, - double riskFreeRate, - string modelName, - string tradeType, - string exerciseDate, - double participationRate, - double principalRate, - bool isAnnualized, - double annualizeFactor, - double dividendRate = 0.0, - bool isMoneynessOption = false, - double initialSpotPrice = 0.0, - Dictionary dividends = null, - bool hasNightMarket = false, - bool commodityFuturesPreciseTimeMode = false, - string engineName = null, - string discountCurveName = null, - double timeToMaturityDays = double.NaN, - bool isForwardTrade = false, - bool ignoreSkewMap = false, - double riskFreeRateOverride = double.NaN, - double dividendRateOverride = double.NaN, - PricingRequest pricingRequest = QdpPricingRequest.BASIC_GREEKS) - { - underlyingInstrumentType = ConvertInstrumentType(underlyingInstrumentType); - - return ValueVanillaOptionTrade( - VolSurfaceInitializerSingleton.VolConstructionType, - marketProxy, - valueDate, - underlyingTicker, - underlyingInstrumentType, - strike, - startDate, - endDate, - optionType, - exerciseType, - spotPrice, - notional, - volSurfaceName, - riskFreeRate, - modelName, - tradeType, - exerciseDate, - participationRate, - principalRate, - isAnnualized, - annualizeFactor, - dividendRate, - isMoneynessOption, - initialSpotPrice, - dividends, - hasNightMarket, - commodityFuturesPreciseTimeMode, - engineName, - discountCurveName, - timeToMaturityDays, - isForwardTrade, - ignoreSkewMap, - riskFreeRateOverride: riskFreeRateOverride, - dividendRateOverride: dividendRateOverride, - pricingRequest: pricingRequest); - } - #endregion - - #region 障碍期权 (单障碍和双障碍都支持) - public static BarrierOptionTrade CreateBarrierOptionTrade( - string tradeId, - string volSurfaceName, - string tradeDate, - string underlyingTicker, - string underlyingInstrumentType, - double strike, - string startDate, - string endDate, - string optionType, - string exerciseType, - string barrierType, - double barrierPrice, - double upperBarrierPrice, - bool isDiscrete, - double rebate, - double notional, - string tradeType, - string exerciseDate, - string rebateType, - bool rebateAnnualizedAtKO, - string rebateDayCount, - double participationRate, - double principalRate, - bool isAnnualized, - double annualizeFactor, - bool isMoneynessOption = false, - double initialSpotPrice = 0.0, - string observationDateStr = null, - Dictionary dividends = null, - string position = "Buy", - double barrierShift = 0.0, - string barrierStatus = "Monitoring", - bool hasNightMarket = false, - bool commodityFuturesPreciseTimeMode = false, - double timeToMaturityDays = double.NaN, - double riskFreeRateOverride = double.NaN, - double dividendRateOverride = double.NaN) - { - underlyingInstrumentType = ConvertInstrumentType(underlyingInstrumentType); - - var exercise = QdpConverter.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; - Date[] observationDates = null; - var barrierObservationDates = QdpHelper.ParseObservationDate(observationDateStr); - - if (exercise == OptionExercise.American) - { - exerciseDates = CalendarImpl.Get("chn").BizDaysBetweenDatesInclEndDay(optionStartDate, temp_exerciseDate).ToArray(); - if (observationDates == null) - { - observationDates = CalendarImpl.Get("chn").BizDaysBetweenDatesExcluStartDay(optionStartDate, temp_exerciseDate).ToArray(); - } - } - else - { - exerciseDates = new Date[] { temp_exerciseDate }; - if (observationDates == null) - { - observationDates = CalendarImpl.Get("chn").BizDaysBetweenDatesExcluStartDay(optionStartDate, temp_exerciseDate).Union(new[] { temp_exerciseDate }).ToArray(); - } - } - - //补丁 - //if(string.IsNullOrEmpty(barrierType)) - //{ - // barrierType = "0"; - //} - var optionDayCount = CalculatorHelper.GetTradeDayCount(); - - var pricingTOverride = double.IsNaN(timeToMaturityDays) ? double.NaN : QdpCalendarHelper.CalculateTFromDays(timeToMaturityDays, optionDayCount, optionStartDate.DateTime); - - if (rebateAnnualizedAtKO) - { - var rebateDayCountImpl = string.IsNullOrWhiteSpace(rebateDayCount) ? new Act365() : rebateDayCount.ToDayCountImpl(); - rebate /= rebateDayCountImpl.CalcDayCountFraction(optionStartDate, underlyingMaturityDate); - } - - var barrierOption = - new BarrierOption( - startDate: optionStartDate, - maturityDate: underlyingMaturityDate, - exercise: exercise, - optionType: (OptionType)Enum.Parse(typeof(OptionType), optionType), - strike: strike, - rebate: rebate, //rebate - coupon: 0.0, //coupon - participationRate: participationRate, - barrierType: (BarrierType)Enum.Parse(typeof(BarrierType), barrierType), - lowerBarrier: barrierPrice, //lowerBarrier - upperBarrier: upperBarrierPrice, //upperBarrier - isDiscreteMonitored: isDiscrete, - underlyingType: (InstrumentType)Enum.Parse(typeof(InstrumentType), underlyingInstrumentType), - calendar: CalendarImpl.Get("chn"), - dayCount: optionDayCount.ToDayCountImpl(), - payoffCcy: CurrencyCode.CNY, - settlementCcy: CurrencyCode.CNY, - exerciseDates: exerciseDates, - observationDates: observationDates, - barrierObservationDates: barrierObservationDates, - highRebate: double.NaN, - notional: notional, - settlementGap: null, - optionPremiumPaymentDate: null, - optionPremium: 0.0, - isMoneynessOption: isMoneynessOption, - initialSpotPrice: initialSpotPrice, - dividends: dividends, - position: QdpConverter.ConvertPosition(position), - barrierShift: barrierShift, - rebateAnnualizedAtKO: rebateAnnualizedAtKO, - rebateDayCount: string.IsNullOrWhiteSpace(rebateDayCount) ? new Act365() : rebateDayCount.ToDayCountImpl(), - pricingToverride: pricingTOverride, //pricingToverride - rebateType: (string.IsNullOrEmpty(rebateType) ? "AtEnd" : rebateType).ToBinaryRebateType(), - barrierStatus: QdpConverter.ConvertBarrierStatus(barrierStatus), - hasNightMarket: hasNightMarket, - commodityFuturesPreciseTimeMode: commodityFuturesPreciseTimeMode, - riskFreeRateOverride: riskFreeRateOverride, - dividendRateOverride: dividendRateOverride, - isAnnualized: isAnnualized, - annualizedFactor: annualizeFactor) - { - UnderlyingTickers = new string[] { underlyingTicker } - }; - - if (string.IsNullOrWhiteSpace(tradeId)) - { - tradeId = Guid.NewGuid().ToString(); - } - return new BarrierOptionTrade( - tradeId, - tradeDate.ToDate(), - barrierOption.StartDate, - barrierOption.ExerciseDates.Last(), - QdpConverter.ConvertTradeType(tradeType), - barrierOption.Notional, - 0.0, - barrierOption) - { - ValuationParameters = new OptionValuationParameters("RiskFreeDiscountCurve", MarketProxy.ConstantZeroCurve, volSurfaceName, barrierOption.UnderlyingTickers[0]), - ProtectionRate = principalRate, - ParticipationRate = participationRate, - AnnualizedFactor = annualizeFactor, - OriginalNotional = TradeHelper.GetStockEqvNotional(notional * initialSpotPrice, participationRate, annualizeFactor) - }; - } - - public static TradeValueResult ValueBarrierOptionTrade( - IQdpMarketProxy marketProxy, - string valueDate, - string underlyingTicker, - string underlyingInstrumentType, - double strike, - string startDate, - string endDate, - string optionType, - string exerciseType, - string barrierType, - double barrierPrice, - double upperBarrierPrice, - bool isDiscrete, - double spotPrice, - double rebate, - double notional, - string volSurfaceName, - double riskFreeRate, - string tradeType, - string exerciseDate, - string rebateType, - bool rebateAnnualizedAtKO, - string rebateDayCount, - double participationRate, - double principalRate, - bool isAnnualized, - double annualizeFactor, - double dividendRate = 0.0, - bool isMoneynessOption = false, - double initialSpotPrice = 0.0, - string observationDateStr = null, - Dictionary dividends = null, - string position = "Buy", - double barrierShift = 0.0, - string barrierStatus = "Monitoring", - bool hasNightMarket = false, - bool commodityFuturesPreciseTimeMode = false, - string engineName = null, - string discountCurveName = null, - bool isForwardTrade = false, - bool ignoreSkewMap = false, - double timeToMaturityDays = double.NaN, - double riskFreeRateOverride = double.NaN, - double dividendRateOverride = double.NaN, - PricingRequest pricingRequest = QdpPricingRequest.BASIC_GREEKS) - { - underlyingInstrumentType = ConvertInstrumentType(underlyingInstrumentType); - - return ValueBarrierOptionTrade( - VolSurfaceInitializerSingleton.VolConstructionType, - marketProxy, - valueDate, - underlyingTicker, - underlyingInstrumentType, - strike, - startDate, - endDate, - optionType, - exerciseType, - barrierType, - barrierPrice, - upperBarrierPrice, - isDiscrete, - spotPrice, - rebate, - notional, - volSurfaceName, - riskFreeRate, - tradeType, - exerciseDate, - rebateType, - rebateAnnualizedAtKO, - rebateDayCount, - participationRate, - principalRate, - isAnnualized, - annualizeFactor, - dividendRate, - isMoneynessOption, - initialSpotPrice, - observationDateStr, - dividends, - position, - barrierShift, - barrierStatus, - hasNightMarket, - commodityFuturesPreciseTimeMode, - engineName, - discountCurveName, - isForwardTrade, - ignoreSkewMap, - timeToMaturityDays: timeToMaturityDays, - riskFreeRateOverride: riskFreeRateOverride, - dividendRateOverride: dividendRateOverride, - pricingRequest: pricingRequest); - } - - private static TradeValueResult ValueBarrierOptionTrade( - VolConstructionType volConstructionType, - IQdpMarketProxy marketProxy, - string valueDate, - string underlyingTicker, - string underlyingInstrumentType, - double strike, - string startDate, - string endDate, - string optionType, - string exerciseType, - string barrierType, - double barrierPrice, - double upperBarrierPrice, - bool isDiscrete, - double spotPrice, - double rebate, - double notional, - string volSurfaceName, - double riskFreeRate, - string tradeType, - string exerciseDate, - string rebateType, - bool rebateAnnualizedAtKO, - string rebateDayCount, - double participationRate, - double principalRate, - bool isAnnualized, - double annualizeFactor, - double dividendRate = 0.0, - bool isMoneynessOption = false, - double initialSpotPrice = 0.0, - string observationDateStr = null, - Dictionary dividends = null, - string position = "Buy", - double barrierShift = 0.0, - string barrierStatus = "Monitoring", - bool hasNightMarket = false, - bool commodityFuturesPreciseTimeMode = false, - string engineName = null, - string discountCurveName = null, - bool isForwardTrade = false, - bool ignoreSkewMap = false, - double timeToMaturityDays = double.NaN, - double riskFreeRateOverride = double.NaN, - double dividendRateOverride = double.NaN, - PricingRequest pricingRequest = QdpPricingRequest.BASIC_GREEKS) - { - if (volConstructionType == VolConstructionType.Normal || ignoreSkewMap) - { - return ValueBarrierOption( - marketProxy, - valueDate, - underlyingTicker, - underlyingInstrumentType, - strike, - startDate, - endDate, - optionType, - exerciseType, - barrierType, - barrierPrice, - upperBarrierPrice, - isDiscrete, - spotPrice, - rebate, - notional, - volSurfaceName, - riskFreeRate, - tradeType, - exerciseDate, - rebateType, - rebateAnnualizedAtKO, - rebateDayCount, - participationRate, - principalRate, - isAnnualized, - annualizeFactor, - dividendRate, - isMoneynessOption, - initialSpotPrice, - observationDateStr, - dividends, - position, - barrierShift, - barrierStatus, - hasNightMarket, - commodityFuturesPreciseTimeMode, - engineName, - discountCurveName, - isForwardTrade, - timeToMaturityDays: timeToMaturityDays, - riskFreeRateOverride: riskFreeRateOverride, - dividendRateOverride: dividendRateOverride, - pricingRequest: pricingRequest); - } - else - { - var tradeId = Guid.NewGuid().ToString(); - SetSkewMapVol( - marketProxy, - valueDate, - underlyingTicker, - exerciseDate, - strike, - TradeCalcHelper.IsBuy(tradeType), - QdpHelper.IsCall(optionType), - tradeId, - spotPrice); - - return ValueBarrierOption( - marketProxy, - valueDate, - underlyingTicker, - underlyingInstrumentType, - strike, - startDate, - endDate, - optionType, - exerciseType, - barrierType, - barrierPrice, - upperBarrierPrice, - isDiscrete, - spotPrice, - rebate, - notional, - tradeId.GenerateVolSurfaceKey(), - riskFreeRate, - tradeType, - exerciseDate, - rebateType, - rebateAnnualizedAtKO, - rebateDayCount, - participationRate, - principalRate, - isAnnualized, - annualizeFactor, - dividendRate, - isMoneynessOption, - initialSpotPrice, - observationDateStr, - dividends, - position, - barrierShift, - barrierStatus, - hasNightMarket, - commodityFuturesPreciseTimeMode, - engineName, - discountCurveName, - isForwardTrade, - timeToMaturityDays: timeToMaturityDays, - riskFreeRateOverride: riskFreeRateOverride, - dividendRateOverride: dividendRateOverride, - pricingRequest: pricingRequest); - } - } - - private static TradeValueResult ValueBarrierOption( - IQdpMarketProxy marketProxy, - string valueDate, - string underlyingTicker, - string underlyingInstrumentType, - double strike, - string startDate, - string endDate, - string optionType, - string exerciseType, - string barrierType, - double barrierPrice, - double upperBarrierPrice, - bool isDiscrete, - double spotPrice, - double rebate, - double notional, - string volSurfaceName, - double riskFreeRate, - string tradeType, - string exerciseDate, - string rebateType, - bool rebateAnnualizedAtKO, - string rebateDayCount, - double participationRate, - double principalRate, - bool isAnnualized, - double annualizeFactor, - double dividendRate = 0.0, - bool isMoneynessOption = false, - double initialSpotPrice = 0.0, - string observationDateStr = null, - Dictionary dividends = null, - string position = "Buy", - double barrierShift = 0.0, - string barrierStatus = "Monitoring", - bool hasNightMarket = false, - bool commodityFuturesPreciseTimeMode = false, - string engineName = null, - string discountCurveName = null, - bool isForwardTrade = false, - double timeToMaturityDays = double.NaN, - double riskFreeRateOverride = double.NaN, - double dividendRateOverride = double.NaN, - PricingRequest pricingRequest = QdpPricingRequest.BASIC_GREEKS) - { - if (string.IsNullOrWhiteSpace(volSurfaceName)) - { - volSurfaceName = underlyingTicker.GenerateVolSurfaceKey(); - } - - //如果用户自定义的观察日就是每天观察,则忽略自定义观察日 - var observationDates = CalendarImpl.Get("chn").BizDaysBetweenDatesExcluStartDay(startDate.ToDate(), exerciseDate.ToDate()).Union(new[] { exerciseDate.ToDate() }).ToArray(); - var barrierObservationDates = QdpHelper.ParseObservationDate(observationDateStr); - if (barrierObservationDates != null && - (barrierObservationDates.Count(d => d >= observationDates.First() && d <= observationDates.Last()) == observationDates.Length)) - { - observationDateStr = null; - } - - var optionTrade = CreateBarrierOptionTrade( - null, - volSurfaceName, - startDate, - underlyingTicker, - underlyingInstrumentType, - strike, - startDate, - endDate, - optionType, - exerciseType, - barrierType, - barrierPrice, - upperBarrierPrice, - isDiscrete, - rebate, - notional, - tradeType, - exerciseDate, - rebateType, - rebateAnnualizedAtKO, - rebateDayCount, - participationRate, - principalRate, - isAnnualized, - annualizeFactor, - isMoneynessOption, - initialSpotPrice, - observationDateStr, - dividends, - position, - barrierShift, - barrierStatus, - hasNightMarket: hasNightMarket, - commodityFuturesPreciseTimeMode: commodityFuturesPreciseTimeMode, - timeToMaturityDays: timeToMaturityDays, - riskFreeRateOverride: riskFreeRateOverride, - dividendRateOverride: dividendRateOverride).CheckMaturityDate(); - - var market = marketProxy.GetQdpMarket(valueDate); - if (market == null) - { - return null; - } - - 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 = null; - string dividendCurveName = null; - if (underlyingInstrumentType == "Stock") - { - //设置DividendCurve - 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); - } - - try - { - var option = optionTrade.Instrument as BarrierOption; - var factory = OptionEngineFactory.GetEngineFactory("BarrierOption"); - var engine = factory.GetEngine( - engineName, - option.Exercise, - option, - !string.IsNullOrWhiteSpace(observationDateStr)); - - var results = optionTrade.CalculateRisks( - marketProxy.GetQdpMarket(valueDate), - !string.IsNullOrWhiteSpace(observationDateStr) ? QdpPricingRequest.BASIC_GREEKS : pricingRequest, - engine, - parameters); - - if (useLocalDiscountCurve) - { - marketProxy.RemoveYieldCurve(discountCurveName, valueDate); - } - if (!string.IsNullOrEmpty(dividendCurveName)) - { - marketProxy.RemoveYieldCurve(dividendCurveName, valueDate); - } - - if (results.Succeeded) - { - //double vol = marketProxy.GetVol(valueDate, underlyingTicker, strike, endDate, spotPrice); - //if (isMoneynessOption) - //{ - // vol = marketProxy.GetVol(valueDate, underlyingTicker, strike / spotPrice, endDate); - //} - //else - //{ - // vol = marketProxy.GetVol(valueDate, underlyingTicker, strike, endDate); - //} - return new TradeValueResult() - { - UnderlyingCode = underlyingTicker, - Pv = results.Pv, - Delta = results.Delta, - Gamma = results.Gamma, - Vega = results.Vega, - CalendarDayTheta = results.Theta, - TradingDayTheta = results.ThetaPnL, - Rho = results.Rho, - DeltaCash = results.DeltaCash, - GammaCash = results.GammaCash, - Vol = results.PricingVol, - DDeltaDVol = results.DDeltaDvol, - DDeltaDt = results.DDeltaDt, - DVegaDVol = results.DVegaDvol, - DVegaDt = results.DVegaDt, - StoppingTime = results.StoppingTime, - RoundedPv = OtcFormatHelper.FormatValue(results.Pv / notional, 2) * notional - }; - } - else - { - return null; - } - } - catch (Exception ex) - { - throw ex; - //return null; - } - } - #endregion - - #region 二元期权 - - public static BinaryOptionTrade CreateBinaryOptionTrade( - string tradeId, - string volSurfaceName, - string tradeDate, - string underlyingTicker, - string underlyingInstrumentType, - double strike, - string startDate, - string endDate, - string optionType, - string exerciseType, - string binaryOptionPayoffType, - double cashOrNothingAmount, - double notional, - string tradeType, - string exerciseDate, - double participationRate, - double principalRate, - bool isAnnualized, - double annualizeFactor, - double upperBarrier = double.NaN, - double cashOrNothingAmountHigh = double.NaN, - bool isDiscreateMonitored = false, - bool isMoneynessOption = false, - double initialSpotPrice = 0.0, - Dictionary dividends = null, - string binaryRebateType = "AtEnd", - bool hasNightMarket = false, - bool commodityFuturesPreciseTimeMode = false, - double timeToMaturityDays = double.NaN, - double riskFreeRateOverride = double.NaN, - double dividendRateOverride = double.NaN) - { - underlyingInstrumentType = ConvertInstrumentType(underlyingInstrumentType); - - var exercise = QdpConverter.ConvertExerciseType(exerciseType); - var optionStartDate = startDate.ToDate(); - var underlyingMaturityDate = string.IsNullOrWhiteSpace(endDate) ? null : endDate.ToDate(); - var rebateType = (string.IsNullOrEmpty(binaryRebateType) ? "AtEnd" : binaryRebateType).ToBinaryRebateType(); - var temp_exerciseDate = exerciseDate.ToDate(); - - if (temp_exerciseDate < optionStartDate) - { - return null; - } - - var exerciseDates = new Date[] { temp_exerciseDate }; - var observationDates = new Date[] { temp_exerciseDate }; - - var optionDayCount = CalculatorHelper.GetTradeDayCount(); - var pricingTOverride = double.IsNaN(timeToMaturityDays) ? double.NaN : QdpCalendarHelper.CalculateTFromDays(timeToMaturityDays, optionDayCount, optionStartDate.DateTime); - var binaryOption = - new BinaryOption( - optionStartDate, - underlyingMaturityDate, - exercise, - (OptionType)Enum.Parse(typeof(OptionType), optionType), - strike, - (InstrumentType)Enum.Parse(typeof(InstrumentType), underlyingInstrumentType), - (BinaryOptionPayoffType)Enum.Parse(typeof(BinaryOptionPayoffType), binaryOptionPayoffType), - cashOrNothingAmount, - CalendarImpl.Get("chn"), - optionDayCount.ToDayCountImpl(), - CurrencyCode.CNY, - CurrencyCode.CNY, - exerciseDates, - observationDates, - notional, - null, - null, - 0.0, - isMoneynessOption, - initialSpotPrice, - upperBarrier, - cashOrNothingAmountHigh, - isDiscreteMonitored: isDiscreateMonitored, - dividends: dividends, - binaryRebateType: rebateType, - pricingToverride: pricingTOverride, - hasNightMarket: hasNightMarket, - commodityFuturesPreciseTimeMode: commodityFuturesPreciseTimeMode, - riskFreeRateOverride: riskFreeRateOverride, - dividendRateOverride: dividendRateOverride, - participationRate: participationRate, - isAnnualized: isAnnualized, - annualizedFactor: annualizeFactor) - { - UnderlyingTickers = new string[] { underlyingTicker } - }; - - if (string.IsNullOrWhiteSpace(tradeId)) - { - tradeId = Guid.NewGuid().ToString(); - } - return new BinaryOptionTrade( - tradeId, - tradeDate.ToDate(), - binaryOption.StartDate, - binaryOption.ExerciseDates.Last(), - QdpConverter.ConvertTradeType(tradeType), - binaryOption.Notional, - 0.0, - binaryOption) - { - ValuationParameters = new OptionValuationParameters("RiskFreeDiscountCurve", MarketProxy.ConstantZeroCurve, volSurfaceName, binaryOption.UnderlyingTickers[0]), - ProtectionRate = principalRate, - ParticipationRate = participationRate, - AnnualizedFactor = annualizeFactor, - OriginalNotional = TradeHelper.GetStockEqvNotional(notional * initialSpotPrice, participationRate, annualizeFactor) - }; - } - - public static TradeValueResult ValueBinaryOptionTrade( - IQdpMarketProxy marketProxy, - string valueDate, - string underlyingTicker, - string underlyingInstrumentType, - double strike, - string startDate, - string endDate, - string optionType, - string exerciseType, - string payoffType, - double cashOrNothingAmount, - double spotPrice, - double notional, - string volSurfaceName, - double riskFreeRate, - string tradeType, - string exerciseDate, - double participationRate, - double principalRate, - bool isAnnualized, - double annualizeFactor, - double upperBarrier = double.NaN, - double cashOrNothingAmountHigh = double.NaN, - bool isDiscreteMonitored = false, - double dividendRate = 0.0, - bool isMoneynessOption = false, - double initialSpotPrice = 0.0, - Dictionary dividends = null, - string binaryRebateType = "AtEnd", - string binaryOptionReplicationStrategy = "None", - double replicationShiftSize = 0.0, - bool hasNightMarket = false, - bool commodityFuturesPreciseTimeMode = false, - string engineName = null, - string discountCurveName = null, - bool isForwardTrade = false, - bool ignoreSkewMap = false, - double timeToMaturityDays = double.NaN, - double riskFreeRateOverride = double.NaN, - double dividendRateOverride = double.NaN, - PricingRequest pricingRequest = QdpPricingRequest.BASIC_GREEKS) - { - underlyingInstrumentType = ConvertInstrumentType(underlyingInstrumentType); - - return ValueBinaryOptionTrade( - VolSurfaceInitializerSingleton.VolConstructionType, - marketProxy, - valueDate, - underlyingTicker, - underlyingInstrumentType, - strike, - startDate, - endDate, - optionType, - exerciseType, - payoffType, - cashOrNothingAmount, - spotPrice, - notional, - volSurfaceName, - riskFreeRate, - tradeType, - exerciseDate, - participationRate, - principalRate, - isAnnualized, - annualizeFactor, - upperBarrier, - cashOrNothingAmountHigh, - isDiscreteMonitored, - dividendRate, - isMoneynessOption, - initialSpotPrice, - dividends, - binaryRebateType, - binaryOptionReplicationStrategy, - replicationShiftSize, - hasNightMarket, - commodityFuturesPreciseTimeMode, - engineName, - discountCurveName, - isForwardTrade, - ignoreSkewMap, - timeToMaturityDays: timeToMaturityDays, - riskFreeRateOverride: riskFreeRateOverride, - dividendRateOverride: dividendRateOverride, - pricingRequest: pricingRequest); - } - - private static TradeValueResult ValueBinaryOptionTrade( - VolConstructionType volConstructionType, - IQdpMarketProxy marketProxy, - string valueDate, - string underlyingTicker, - string underlyingInstrumentType, - double strike, - string startDate, - string endDate, - string optionType, - string exerciseType, - string payoffType, - double cashOrNothingAmount, - double spotPrice, - double notional, - string volSurfaceName, - double riskFreeRate, - string tradeType, - string exerciseDate, - double participationRate, - double principalRate, - bool isAnnualized, - double annualizeFactor, - double upperBarrier = double.NaN, - double cashOrNothingAmountHigh = double.NaN, - bool isDiscreteMonitored = false, - double dividendRate = 0.0, - bool isMoneynessOption = false, - double initialSpotPrice = 0.0, - Dictionary dividends = null, - string binaryRebateType = "AtEnd", - string binaryOptionReplicationStrategy = "None", - double replicationShiftSize = 0.0, - bool hasNightMarket = false, - bool commodityFuturesPreciseTimeMode = false, - string engineName = null, - string discountCurveName = null, - bool isForwardTrade = false, - bool ignoreSkewMap = false, - double timeToMaturityDays = double.NaN, - double riskFreeRateOverride = double.NaN, - double dividendRateOverride = double.NaN, - PricingRequest pricingRequest = QdpPricingRequest.BASIC_GREEKS) - { - if (volConstructionType == VolConstructionType.Normal || ignoreSkewMap) - { - return ValueBinaryOption( - marketProxy, - valueDate, - underlyingTicker, - underlyingInstrumentType, - strike, - startDate, - endDate, - optionType, - exerciseType, - payoffType, - cashOrNothingAmount, - spotPrice, - notional, - volSurfaceName, - riskFreeRate, - tradeType, - exerciseDate, - participationRate, - principalRate, - isAnnualized, - annualizeFactor, - upperBarrier, - cashOrNothingAmountHigh, - isDiscreteMonitored, - dividendRate, - isMoneynessOption, - initialSpotPrice, - dividends, - binaryRebateType, - binaryOptionReplicationStrategy, - replicationShiftSize, - hasNightMarket, - commodityFuturesPreciseTimeMode, - engineName, - discountCurveName, - isForwardTrade, - timeToMaturityDays: timeToMaturityDays, - riskFreeRateOverride: riskFreeRateOverride, - dividendRateOverride: dividendRateOverride, - pricingRequest: pricingRequest); - } - else - { - var tradeId = Guid.NewGuid().ToString(); - SetSkewMapVol( - marketProxy, - valueDate, - underlyingTicker, - exerciseDate, - strike, - TradeCalcHelper.IsBuy(tradeType), - QdpHelper.IsCall(optionType), - tradeId, - spotPrice); - - return ValueBinaryOption( - marketProxy, - valueDate, - underlyingTicker, - underlyingInstrumentType, - strike, - startDate, - endDate, - optionType, - exerciseType, - payoffType, - cashOrNothingAmount, - spotPrice, - notional, - tradeId.GenerateVolSurfaceKey(), - riskFreeRate, - tradeType, - exerciseDate, - participationRate, - principalRate, - isAnnualized, - annualizeFactor, - upperBarrier, - cashOrNothingAmountHigh, - isDiscreteMonitored, - dividendRate, - isMoneynessOption, - initialSpotPrice, - dividends, - binaryRebateType, - binaryOptionReplicationStrategy, - replicationShiftSize, - hasNightMarket, - commodityFuturesPreciseTimeMode, - engineName, - discountCurveName, - isForwardTrade, - timeToMaturityDays: timeToMaturityDays, - riskFreeRateOverride: riskFreeRateOverride, - dividendRateOverride: dividendRateOverride, - pricingRequest: pricingRequest); - } - } - - private static TradeValueResult ValueBinaryOption( - IQdpMarketProxy marketProxy, - string valueDate, - string underlyingTicker, - string underlyingInstrumentType, - double strike, - string startDate, - string endDate, - string optionType, - string exerciseType, - string binaryOptionPayoffType, - double cashOrNothingAmount, - double spotPrice, - double notional, - string volSurfaceName, - double riskFreeRate, - string tradeType, - string exerciseDate, - double participationRate, - double principalRate, - bool isAnnualized, - double annualizeFactor, - double upperBarrier = double.NaN, - double cashOrNothingAmountHigh = double.NaN, - bool isDiscreteMonitored = false, - double dividendRate = 0.0, - bool isMoneynessOption = false, - double initialSpotPrice = 0.0, - Dictionary dividends = null, - string binaryRebateType = "AtEnd", - string binaryOptionReplicationStrategy = "None", - double replicationShiftSize = 0.0, - bool hasNightMarket = false, - bool commodityFuturesPreciseTimeMode = false, - string engineName = null, - string discountCurveName = null, - bool isForwardTrade = false, - double timeToMaturityDays = double.NaN, - double riskFreeRateOverride = double.NaN, - double dividendRateOverride = double.NaN, - PricingRequest pricingRequest = QdpPricingRequest.BASIC_GREEKS) - { - if (string.IsNullOrWhiteSpace(volSurfaceName)) - { - volSurfaceName = underlyingTicker.GenerateVolSurfaceKey(); - } - var optionTrade = CreateBinaryOptionTrade( - null, - volSurfaceName, - startDate, - underlyingTicker, - underlyingInstrumentType, - strike, - startDate, - endDate, - optionType, - exerciseType, - binaryOptionPayoffType, - cashOrNothingAmount, - notional, - tradeType, - exerciseDate, - participationRate, - principalRate, - isAnnualized, - annualizeFactor, - upperBarrier, - cashOrNothingAmountHigh, - isDiscreteMonitored, - isMoneynessOption, - initialSpotPrice, - dividends, - binaryRebateType, - hasNightMarket, - commodityFuturesPreciseTimeMode, - timeToMaturityDays: timeToMaturityDays, - riskFreeRateOverride: riskFreeRateOverride, - dividendRateOverride: dividendRateOverride).CheckMaturityDate(); - - var market = marketProxy.GetQdpMarket(valueDate); - if (market == null) - { - return null; - } - - var replicationStrategy = QdpConverter.ConvertReplicationStrategy(binaryOptionReplicationStrategy); - - 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; - string dividendCurveName = null; - if (underlyingInstrumentType == "Stock") - { - //设置DividendCurve - 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); - } - - try - { - var option = optionTrade.Instrument as BinaryOption; - var factory = OptionEngineFactory.GetEngineFactory("BinaryOption"); - var engine = factory.GetEngine( - engineName, - option.Exercise, - (replicationShiftSize <= 0.0) ? option.Strike * 0.01 : replicationShiftSize, - replicationStrategy); - - var results = optionTrade.CalculateRisks(marketProxy.GetQdpMarket(valueDate), pricingRequest, engine, parameters); - - if (useLocalDiscountCurve) - { - marketProxy.RemoveYieldCurve(discountCurveName, valueDate); - } - if (!string.IsNullOrEmpty(dividendCurveName)) - { - marketProxy.RemoveYieldCurve(dividendCurveName, valueDate); - } - - if (results.Succeeded) - { - //double vol = marketProxy.GetVol(valueDate, underlyingTicker, strike, endDate, spotPrice); - //if (isMoneynessOption) - //{ - // vol = marketProxy.GetVol(valueDate, underlyingTicker, strike / spotPrice, endDate); - //} - //else - //{ - // vol = marketProxy.GetVol(valueDate, underlyingTicker, strike, endDate); - //} - return new TradeValueResult() - { - UnderlyingCode = underlyingTicker, - Pv = results.Pv, - Delta = results.Delta, - Gamma = results.Gamma, - Vega = results.Vega, - CalendarDayTheta = results.Theta, - TradingDayTheta = results.ThetaPnL, - Rho = results.Rho, - DeltaCash = results.DeltaCash, - GammaCash = results.GammaCash, - Vol = results.PricingVol, - DDeltaDVol = results.DDeltaDvol, - DDeltaDt = results.DDeltaDt, - DVegaDVol = results.DVegaDvol, - DVegaDt = results.DVegaDt, - StoppingTime = results.StoppingTime, - RoundedPv = OtcFormatHelper.FormatValue(results.Pv / notional, 2) * notional - }; - } - else - { - return null; - } - } - catch (Exception ex) - { - throw ex; - //return null; - } - } - #endregion - - #region 亚式期权 - public static AsianOptionTrade CreateAsianOptionTrade( - string tradeId, - string volSurfaceName, - string tradeDate, - string underlyingTicker, - string underlyingInstrumentType, - double strike, - string startDate, - string endDate, - string optionType, - string exerciseType, - string asianType, - string strikeStyle, - double notional, - string tradeType, - string exerciseDate, - bool isAnnualized, - double annualizeFactor, - bool isMoneynessOption = false, - double initialSpotPrice = 0.0, - double participationRate = 1.0, - double principalRate = 0.0, - double strikeGearingFactor = 1.0, - Dictionary dividends = null, - string averagingPeriodStartDate = null, - string observationDateStr = null, - string fixings = null, - bool hasNightMarket = false, - bool commodityFuturesPreciseTimeMode = false, - double timeToMaturityDays = double.NaN, - double riskFreeRateOverride = double.NaN, - double dividendRateOverride = double.NaN) - { - underlyingInstrumentType = ConvertInstrumentType(underlyingInstrumentType); - var exercise = QdpConverter.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; - Date[] observationDates; - var calendar = CalendarImpl.Get("chn"); - - if (exercise == OptionExercise.American) - { - exerciseDates = calendar.BizDaysBetweenDatesInclEndDay(optionStartDate, temp_exerciseDate).ToArray(); - } - else - { - exerciseDates = new Date[] { temp_exerciseDate }; - } - - if (!string.IsNullOrWhiteSpace(observationDateStr)) - { - observationDates = QdpHelper.ParseObservationDate(observationDateStr); - } - else - { - var observationStartDate = string.IsNullOrWhiteSpace(averagingPeriodStartDate) ? optionStartDate : averagingPeriodStartDate.ToDate(); - observationDates = calendar.BizDaysBetweenDatesExcluStartDay(observationStartDate, temp_exerciseDate).Union(new[] { temp_exerciseDate }).ToArray(); - } - - var fixingValues = QdpHelper.ParseFixingsFromString(fixings); - - var optionDayCount = CalculatorHelper.GetTradeDayCount(); - - var pricingTOverride = double.IsNaN(timeToMaturityDays) ? double.NaN : QdpCalendarHelper.CalculateTFromDays(timeToMaturityDays, optionDayCount, optionStartDate.DateTime); - - var asianOption = - new AsianOption( - optionStartDate, - underlyingMaturityDate, - (OptionExercise)Enum.Parse(typeof(OptionExercise), exerciseType), - (OptionType)Enum.Parse(typeof(OptionType), optionType), - (AsianType)Enum.Parse(typeof(AsianType), asianType), - (StrikeStyle)Enum.Parse(typeof(StrikeStyle), strikeStyle), - strike, - (InstrumentType)Enum.Parse(typeof(InstrumentType), underlyingInstrumentType), - CalendarImpl.Get("chn"), - optionDayCount.ToDayCountImpl(), - CurrencyCode.CNY, - CurrencyCode.CNY, - exerciseDates, - observationDates, - fixingValues, - strikeGearingFactor, - participationRate, - notional, - null, - null, - 0, - isMoneynessOption, - initialSpotPrice, - dividends, - hasNightMarket: hasNightMarket, - commodityFuturesPreciseTimeMode: commodityFuturesPreciseTimeMode, - pricingToverride: pricingTOverride, - riskFreeRateOverride: riskFreeRateOverride, - dividendRateOverride: dividendRateOverride, - isAnnualized: isAnnualized, - annualizedFactor: annualizeFactor) - { - UnderlyingTickers = new string[] { underlyingTicker } - }; - - if (string.IsNullOrWhiteSpace(tradeId)) - { - tradeId = Guid.NewGuid().ToString(); - } - return new AsianOptionTrade( - tradeId, - tradeDate.ToDate(), - asianOption.StartDate, - asianOption.ExerciseDates.Last(), - QdpConverter.ConvertTradeType(tradeType), - asianOption.Notional, - 0.0, - asianOption) - { - ValuationParameters = new OptionValuationParameters("RiskFreeDiscountCurve", MarketProxy.ConstantZeroCurve, volSurfaceName, asianOption.UnderlyingTickers[0]), - ProtectionRate = principalRate, - ParticipationRate = participationRate, - AnnualizedFactor = annualizeFactor, - OriginalNotional = TradeHelper.GetStockEqvNotional(notional * initialSpotPrice, participationRate, annualizeFactor) - }; - } - - public static TradeValueResult ValueAsianOptionTrade( - IQdpMarketProxy marketProxy, - string valueDate, - string underlyingTicker, - string underlyingInstrumentType, - double strike, - string startDate, - string endDate, - string optionType, - string exerciseType, - string asianType, - string strikeStyle, - double spotPrice, - double notional, - string volSurfaceName, - double riskFreeRate, - string tradeType, - string exerciseDate, - bool isAnnualized, - double annualizeFactor, - double dividendRate = 0.0, - bool isMoneynessOption = false, - double initialSpotPrice = 0.0, - double participationRate = 1.0, - double principalRate = 0.0, - double strikeGearingFactor = 1.0, - Dictionary dividends = null, - string fixings = null, - string averagingPeriodStartDate = null, - string observationDateStr = null, - bool hasNightMarket = false, - bool commodityFuturesPreciseTimeMode = false, - string engineName = null, - string discountCurveName = null, - bool isForwardTrade = false, - bool ignoreSkewMap = false, - double timeToMaturityDays = double.NaN, - double riskFreeRateOverride = double.NaN, - double dividendRateOverride = double.NaN, - PricingRequest pricingRequest = QdpPricingRequest.BASIC_GREEKS) - { - underlyingInstrumentType = ConvertInstrumentType(underlyingInstrumentType); - return ValueAsianOptionTrade( - VolSurfaceInitializerSingleton.VolConstructionType, - marketProxy, - valueDate, - underlyingTicker, - underlyingInstrumentType, - strike, - startDate, - endDate, - optionType, - exerciseType, - asianType, - strikeStyle, - spotPrice, - notional, - volSurfaceName, - riskFreeRate, - tradeType, - exerciseDate, - isAnnualized, - annualizeFactor, - dividendRate, - isMoneynessOption, - initialSpotPrice, - participationRate, - principalRate, - strikeGearingFactor, - dividends, - fixings, - averagingPeriodStartDate, - observationDateStr, - hasNightMarket, - commodityFuturesPreciseTimeMode, - engineName, - discountCurveName, - isForwardTrade, - ignoreSkewMap, - timeToMaturityDays: timeToMaturityDays, - riskFreeRateOverride: riskFreeRateOverride, - dividendRateOverride: dividendRateOverride, - pricingRequest: pricingRequest); - } - - private static TradeValueResult ValueAsianOptionTrade( - VolConstructionType volConstructionType, - IQdpMarketProxy marketProxy, - string valueDate, - string underlyingTicker, - string underlyingInstrumentType, - double strike, - string startDate, - string endDate, - string optionType, - string exerciseType, - string asianType, - string strikeStyle, - double spotPrice, - double notional, - string volSurfaceName, - double riskFreeRate, - string tradeType, - string exerciseDate, - bool isAnnualized, - double annualizeFactor, - double dividendRate = 0.0, - bool isMoneynessOption = false, - double initialSpotPrice = 0.0, - double participationRate = 1.0, - double principalRate = 0.0, - double strikeGearingFactor = 1.0, - Dictionary dividends = null, - string fixings = null, - string averagingPeriodStartDate = null, - string observationDateStr = null, - bool hasNightMarket = false, - bool commodityFuturesPreciseTimeMode = false, - string engineName = null, - string discountCurveName = null, - bool isForwardTrade = false, - bool ignoreSkewMap = false, - double timeToMaturityDays = double.NaN, - double riskFreeRateOverride = double.NaN, - double dividendRateOverride = double.NaN, - PricingRequest pricingRequest = QdpPricingRequest.BASIC_GREEKS) - { - if (volConstructionType == VolConstructionType.Normal || ignoreSkewMap) - { - return ValueAsianOption( - marketProxy, - valueDate, - underlyingTicker, - underlyingInstrumentType, - strike, - startDate, - endDate, - optionType, - exerciseType, - asianType, - strikeStyle, - spotPrice, - notional, - volSurfaceName, - riskFreeRate, - tradeType, - exerciseDate, - isAnnualized, - annualizeFactor, - dividendRate, - isMoneynessOption, - initialSpotPrice, - participationRate, - principalRate, - strikeGearingFactor, - dividends, - fixings, - averagingPeriodStartDate, - observationDateStr, - hasNightMarket, - commodityFuturesPreciseTimeMode, - engineName, - discountCurveName, - isForwardTrade, - timeToMaturityDays: timeToMaturityDays, - riskFreeRateOverride: riskFreeRateOverride, - dividendRateOverride: dividendRateOverride, - pricingRequest: pricingRequest); - } - else - { - var tradeId = Guid.NewGuid().ToString(); - SetSkewMapVol( - marketProxy, - valueDate, - underlyingTicker, - exerciseDate, - strike, - TradeCalcHelper.IsBuy(tradeType), - QdpHelper.IsCall(optionType), - tradeId, - spotPrice); - - return ValueAsianOption( - marketProxy, - valueDate, - underlyingTicker, - underlyingInstrumentType, - strike, - startDate, - endDate, - optionType, - exerciseType, - asianType, - strikeStyle, - spotPrice, - notional, - tradeId.GenerateVolSurfaceKey(), - riskFreeRate, - tradeType, - exerciseDate, - isAnnualized, - annualizeFactor, - dividendRate, - isMoneynessOption, - initialSpotPrice, - participationRate, - principalRate, - strikeGearingFactor, - dividends, - fixings, - averagingPeriodStartDate, - observationDateStr, - hasNightMarket, - commodityFuturesPreciseTimeMode, - engineName, - discountCurveName, - isForwardTrade, - timeToMaturityDays: timeToMaturityDays, - riskFreeRateOverride: riskFreeRateOverride, - dividendRateOverride: dividendRateOverride, - pricingRequest: pricingRequest); - } - } - - private static TradeValueResult ValueAsianOption( - IQdpMarketProxy marketProxy, - string valueDate, - string underlyingTicker, - string underlyingInstrumentType, - double strike, - string startDate, - string endDate, - string optionType, - string exerciseType, - string asianType, - string strikeStyle, - double spotPrice, - double notional, - string volSurfaceName, - double riskFreeRate, - string tradeType, - string exerciseDate, - bool isAnnualized, - double annualizeFactor, - double dividendRate = 0.0, - bool isMoneynessOption = false, - double initialSpotPrice = 0.0, - double participationRate = 1.0, - double principalRate = 0.0, - double strikeGearingFactor = 1.0, - Dictionary dividends = null, - string fixings = null, - string averagingPeriodStartDate = null, - string observationDateStr = null, - bool hasNightMarket = false, - bool commodityFuturesPreciseTimeMode = false, - string engineName = null, - string discountCurveName = null, - bool isForwardTrade = false, - double timeToMaturityDays = double.NaN, - double riskFreeRateOverride = double.NaN, - double dividendRateOverride = double.NaN, - PricingRequest pricingRequest = QdpPricingRequest.BASIC_GREEKS) - { - if (string.IsNullOrWhiteSpace(volSurfaceName)) - { - volSurfaceName = underlyingTicker.GenerateVolSurfaceKey(); - } - var optionTrade = CreateAsianOptionTrade( - null, - volSurfaceName, - startDate, - underlyingTicker, - underlyingInstrumentType, - strike, - startDate, - endDate, - optionType, - exerciseType, - asianType, - strikeStyle, - notional, - tradeType, - exerciseDate, - isAnnualized, - annualizeFactor, - isMoneynessOption, - initialSpotPrice, - participationRate, - principalRate, - strikeGearingFactor, - dividends, - averagingPeriodStartDate, - observationDateStr, - (asianType == "EnhancedArithmeticAverage" && strikeStyle != "Segmented" && string.IsNullOrWhiteSpace(fixings)) ? $"{startDate},{spotPrice}" : fixings, - hasNightMarket: hasNightMarket, - commodityFuturesPreciseTimeMode: commodityFuturesPreciseTimeMode, - timeToMaturityDays: timeToMaturityDays, - riskFreeRateOverride: riskFreeRateOverride, - dividendRateOverride: dividendRateOverride).CheckMaturityDate(); - - var market = marketProxy.GetQdpMarket(valueDate); - if (market == null) - { - return null; - } - - 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; - string dividendCurveName = null; - if (underlyingInstrumentType == "Stock") - { - //设置DividendCurve - 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 option = optionTrade.Instrument as AsianOption; - var factory = OptionEngineFactory.GetEngineFactory("AsianOption"); - var engine = factory.GetEngine(engineName, option.Exercise, asianType, option, strikeStyle); - var results = optionTrade.CalculateRisks(marketProxy.GetQdpMarket(valueDate), pricingRequest, engine, parameters); - - if (useLocalDiscountCurve) - { - marketProxy.RemoveYieldCurve(discountCurveName, valueDate); - } - if (!string.IsNullOrEmpty(dividendCurveName)) - { - marketProxy.RemoveYieldCurve(dividendCurveName, valueDate); - } - - if (results.Succeeded) - { - //double vol = marketProxy.GetVol(valueDate, underlyingTicker, strike, endDate, spotPrice); - //if (isMoneynessOption) - //{ - // vol = marketProxy.GetVol(valueDate, underlyingTicker, strike / spotPrice, endDate); - //} - //else - //{ - // vol = marketProxy.GetVol(valueDate, underlyingTicker, strike, endDate); - //} - return new TradeValueResult() - { - UnderlyingCode = underlyingTicker, - Pv = results.Pv, - Delta = results.Delta, - Gamma = results.Gamma, - Vega = results.Vega, - CalendarDayTheta = results.Theta, - TradingDayTheta = results.ThetaPnL, - Rho = results.Rho, - DeltaCash = results.DeltaCash, - GammaCash = results.GammaCash, - Vol = results.PricingVol, - DDeltaDVol = results.DDeltaDvol, - DDeltaDt = results.DDeltaDt, - DVegaDVol = results.DVegaDvol, - DVegaDt = results.DVegaDt, - StoppingTime = results.StoppingTime, - RoundedPv = OtcFormatHelper.FormatValue(results.Pv / notional, 2) * notional, - SA_Delta = results.SA_Delta, - TimeValue = results.TimeValue - }; - } - else - { - return null; - } - } - #endregion - - #region 彩虹期权 - public static RainbowOptionTrade CreateRainbowOptionTrade( - string tradeId, - string[] volSurfaceNames, - string tradeDate, - string underlyingInstrumentType, - string[] underlyingTickers, - double[] strikes, - string startDate, - string endDate, - string optionType, - string exerciseType, - string rainbowType, - double cashAmount, - double notional, - string tradeType, - string exerciseDate, - double participationRate, - double principalRate, - bool isAnnualized, - double annualizeFactor, - bool hasNightMarket = false, - double riskFreeRateOverride = double.NaN, - double dividendRateOverride = double.NaN, - bool commodityFuturesPreciseTimeMode = false) - { - underlyingInstrumentType = ConvertInstrumentType(underlyingInstrumentType); - - var optionStartDate = startDate.ToDate(); - var underlyingMaturityDate = string.IsNullOrWhiteSpace(endDate) ? null : endDate.ToDate(); - var temp_exerciseDate = exerciseDate.ToDate(); - - if (temp_exerciseDate < optionStartDate) - { - return null; - } - - var exerciseDates = new[] { temp_exerciseDate }; - var calendar = CalendarImpl.Get("chn"); - var observationDates = calendar.BizDaysBetweenDatesExcluStartDay(optionStartDate, temp_exerciseDate).ToArray(); - - var optionDayCount = CalculatorHelper.GetTradeDayCount(); - - var rainbowOption = new RainbowOption( - optionStartDate, - underlyingMaturityDate, - (OptionExercise)Enum.Parse(typeof(OptionExercise), exerciseType), - (OptionType)Enum.Parse(typeof(OptionType), optionType), - (RainbowType)Enum.Parse(typeof(RainbowType), rainbowType), - strikes, - cashAmount, - (InstrumentType)Enum.Parse(typeof(InstrumentType), underlyingInstrumentType), - CalendarImpl.Get("chn"), - optionDayCount.ToDayCountImpl(), - CurrencyCode.CNY, - CurrencyCode.CNY, - exerciseDates, - observationDates, - underlyingTickers, - notional, - null, - null, - 0, - hasNightMarket: hasNightMarket, - commodityFuturesPreciseTimeMode: commodityFuturesPreciseTimeMode, - participationRate: participationRate, - isAnnualized: isAnnualized, - annualizedFactor: annualizeFactor, - riskFreeRateOverride: riskFreeRateOverride, - dividendRateOverride: dividendRateOverride) - { - UnderlyingTickers = underlyingTickers - }; - - if (string.IsNullOrWhiteSpace(tradeId)) - { - tradeId = Guid.NewGuid().ToString(); - } - return new RainbowOptionTrade( - tradeId, - tradeDate.ToDate(), - rainbowOption.StartDate, - rainbowOption.ExerciseDates.Last(), - QdpConverter.ConvertTradeType(tradeType), - rainbowOption.Notional, - 0.0, - rainbowOption) - { - ValuationParameters = new OptionValuationParameters( - "RiskFreeDiscountCurve", - new string[] { MarketProxy.ConstantZeroCurve, MarketProxy.ConstantZeroCurve }, - volSurfaceNames, - new string[] { underlyingTickers[0] + "_" + underlyingTickers[1] }, - null), - ProtectionRate = principalRate, - ParticipationRate = participationRate, - AnnualizedFactor = annualizeFactor - }; - } - - public static TradeValueResult ValueRainbowOptionTrade( - IQdpMarketProxy marketProxy, - string valueDate, - string underlyingInstrumentType, - string[] underlyingTickers, - string[] volSurfaceNames, - double[] strikes, - string startDate, - string endDate, - string optionType, - string exerciseType, - string rainbowType, - double cashAmount, - double[] spotPrices, - double notional, - double riskFreeRate, - double correlation, - string tradeType, - string exerciseDate, - double participationRate, - double principalRate, - bool isAnnualized, - double annualizeFactor, - double dividendRate = 0.0, - bool hasNightMarket = false, - bool commodityFuturesPreciseTimeMode = false, - string engineName = null, - string discountCurveName = null, - bool isForwardTrade = false, - bool ignoreSkewMap = false, - double riskFreeRateOverride = double.NaN, - double dividendRateOverride = double.NaN, - PricingRequest pricingRequest = QdpPricingRequest.BASIC_GREEKS) - { - underlyingInstrumentType = ConvertInstrumentType(underlyingInstrumentType); - return ValueRainbowOptionTrade( - VolSurfaceInitializerSingleton.VolConstructionType, - marketProxy, - valueDate, - underlyingInstrumentType, - underlyingTickers, - volSurfaceNames, - strikes, - startDate, - endDate, - optionType, - exerciseType, - rainbowType, - cashAmount, - spotPrices, - notional, - riskFreeRate, - correlation, - tradeType, - exerciseDate, - participationRate, - principalRate, - isAnnualized, - annualizeFactor, - dividendRate, - hasNightMarket, - commodityFuturesPreciseTimeMode, - engineName, - discountCurveName, - isForwardTrade, - ignoreSkewMap, - riskFreeRateOverride, - dividendRateOverride, - pricingRequest); - } - - private static TradeValueResult ValueRainbowOptionTrade( - VolConstructionType volConstructionType, - IQdpMarketProxy marketProxy, - string valueDate, - string underlyingInstrumentType, - string[] underlyingTickers, - string[] volSurfaceNames, - double[] strikes, - string startDate, - string endDate, - string optionType, - string exerciseType, - string rainbowType, - double cashAmount, - double[] spotPrices, - double notional, - double riskFreeRate, - double correlation, - string tradeType, - string exerciseDate, - double participationRate, - double principalRate, - bool isAnnualized, - double annualizeFactor, - double dividendRate = 0.0, - bool hasNightMarket = false, - bool commodityFuturesPreciseTimeMode = false, - string engineName = null, - string discountCurveName = null, - bool isForwardTrade = false, - bool ignoreSkewMap = false, - double riskFreeRateOverride = double.NaN, - double dividendRateOverride = double.NaN, - PricingRequest pricingRequest = QdpPricingRequest.BASIC_GREEKS) - { - if (volConstructionType == VolConstructionType.Normal || ignoreSkewMap) - { - return ValueRainbowOption( - marketProxy, - valueDate, - underlyingInstrumentType, - underlyingTickers, - volSurfaceNames, - strikes, - startDate, - endDate, - optionType, - exerciseType, - rainbowType, - cashAmount, - spotPrices, - notional, - riskFreeRate, - correlation, - tradeType, - exerciseDate, - participationRate, - principalRate, - isAnnualized, - annualizeFactor, - dividendRate, - hasNightMarket, - commodityFuturesPreciseTimeMode, - engineName, - discountCurveName, - isForwardTrade, - riskFreeRateOverride, - dividendRateOverride, - pricingRequest); - } - else - { - var tradeId1 = Guid.NewGuid().ToString(); - SetSkewMapVol( - marketProxy, - valueDate, - underlyingTickers[0], - exerciseDate, - strikes[0], - TradeCalcHelper.IsBuy(tradeType), - QdpHelper.IsCall(optionType), - tradeId1, - spotPrices[0]); - - var tradeId2 = Guid.NewGuid().ToString(); - SetSkewMapVol( - marketProxy, - valueDate, - underlyingTickers[1], - exerciseDate, - strikes[1], - TradeCalcHelper.IsBuy(tradeType), - QdpHelper.IsCall(optionType), - tradeId2, - spotPrices[1]); - - return ValueRainbowOption( - marketProxy, - valueDate, - underlyingInstrumentType, - underlyingTickers, - new string[] { tradeId1.GenerateVolSurfaceKey(), tradeId2.GenerateVolSurfaceKey() }, - strikes, - startDate, - endDate, - optionType, - exerciseType, - rainbowType, - cashAmount, - spotPrices, - notional, - riskFreeRate, - correlation, - tradeType, - exerciseDate, - participationRate, - principalRate, - isAnnualized, - annualizeFactor, - dividendRate, - hasNightMarket, - commodityFuturesPreciseTimeMode, - engineName, - discountCurveName, - isForwardTrade, - riskFreeRateOverride, - dividendRateOverride, - pricingRequest); - } - } - - private static TradeValueResult ValueRainbowOption( - IQdpMarketProxy marketProxy, - string valueDate, - string underlyingInstrumentType, - string[] underlyingTickers, - string[] volSurfaceNames, - double[] strikes, - string startDate, - string endDate, - string optionType, - string exerciseType, - string rainbowType, - double cashAmount, - double[] spotPrices, - double notional, - double riskFreeRate, - double correlation, - string tradeType, - string exerciseDate, - double participationRate, - double principalRate, - bool isAnnualized, - double annualizeFactor, - double dividendRate = 0.0, - bool hasNightMarket = false, - bool commodityFuturesPreciseTimeMode = false, - string engineName = null, - string discountCurveName = null, - bool isForwardTrade = false, - double riskFreeRateOverride = double.NaN, - double dividendRateOverride = double.NaN, - PricingRequest pricingRequest = QdpPricingRequest.BASIC_GREEKS) - { - if (volSurfaceNames == null) - { - volSurfaceNames = underlyingTickers.Select(x => x.GenerateVolSurfaceKey()).ToArray(); - } - - var optionTrade = CreateRainbowOptionTrade( - null, - volSurfaceNames, - startDate, - underlyingInstrumentType, - underlyingTickers, - strikes, - startDate, - endDate, - optionType, - exerciseType, - rainbowType, - cashAmount, - notional, - tradeType, - exerciseDate, - participationRate, - principalRate, - isAnnualized, - annualizeFactor, - hasNightMarket: hasNightMarket, - riskFreeRateOverride: riskFreeRateOverride, - dividendRateOverride: dividendRateOverride, - commodityFuturesPreciseTimeMode: commodityFuturesPreciseTimeMode).CheckMaturityDate(); - - var market = marketProxy.GetQdpMarket(valueDate); - if (market == null) - { - return null; - } - - var useLocalDiscountCurve = string.IsNullOrWhiteSpace(discountCurveName); - - //设置DiscountCurve - if (useLocalDiscountCurve) - { - discountCurveName = Guid.NewGuid().ToString(); - var discountCurve = CalculatorHelper.CreateConstantRiskFreeCurve(discountCurveName, riskFreeRate); - marketProxy.AddYieldCurve(discountCurveName, valueDate, discountCurve); - } - - //设置标的价格 - var count = Math.Min(underlyingTickers.Length, spotPrices.Length); - for (var i = 0; i < count; ++i) - { - marketProxy.AddStockPrice(underlyingTickers[i], valueDate, spotPrices[i]); - } - - //设置correlation - marketProxy.SaveCorrelationSurface(valueDate, underlyingTickers, correlation); - - OptionValuationParameters parameters = null; - string dividendCurveName = null; - - if (underlyingInstrumentType == "Stock") - { - //设置DividendCurve - dividendCurveName = Guid.NewGuid().ToString(); - var dividendCurve = CalculatorHelper.CreateConstantRiskFreeCurve(dividendCurveName, dividendRate); - marketProxy.AddYieldCurve(dividendCurveName, valueDate, dividendCurve); - - parameters = new OptionValuationParameters( - isForwardTrade ? MarketProxy.ConstantZeroCurve : discountCurveName, - new string[] { dividendCurveName, dividendCurveName }, - volSurfaceNames, - new string[] { underlyingTickers[0] + "_" + underlyingTickers[1] }, - null); - } - else - { - parameters = new OptionValuationParameters( - isForwardTrade ? MarketProxy.ConstantZeroCurve : discountCurveName, - new string[] { MarketProxy.ConstantZeroCurve, MarketProxy.ConstantZeroCurve }, - volSurfaceNames, - new string[] { underlyingTickers[0] + "_" + underlyingTickers[1] }, - null); - } - - - try - { - var results = optionTrade.CalculateRisks(marketProxy.GetQdpMarket(valueDate), pricingRequest, null, parameters); - - if (useLocalDiscountCurve) - { - marketProxy.RemoveYieldCurve(discountCurveName, valueDate); - } - if (!string.IsNullOrEmpty(dividendCurveName)) - { - marketProxy.RemoveYieldCurve(dividendCurveName, valueDate); - } - - if (results.Succeeded) - { - //var vol = 0.0; - return new TradeValueResult() - { - UnderlyingCode = underlyingTickers[0], - Pv = results.Pv, - Delta = results.asset1Delta, - Gamma = results.asset1Gamma, - Vega = results.asset1Vega, - CalendarDayTheta = results.Theta, - TradingDayTheta = results.ThetaPnL, - Rho = results.Rho, - DeltaCash = results.DeltaCash, - GammaCash = results.GammaCash, - Vol = results.PricingVol, - - UnderlyingCode2 = underlyingTickers[1], - Delta2 = results.asset2Delta, - Gamma2 = results.asset2Gamma, - DeltaCash2 = results.asset2DeltaCash, - GammaCash2 = results.asset2GammaCash, - Vega2 = results.asset2Vega, - CrossGamma = results.crossGamma, - CrossVogga = results.crossVomma, - CorrVega = results.correlationVega, - RoundedPv = OtcFormatHelper.FormatValue(results.Pv / notional, 2) * notional - }; - } - else - { - return null; - } - } - catch (Exception ex) - { - throw ex; - //return null; - } - } - #endregion - - #region 价差期权 - public static SpreadOptionTrade CreateSpreadOptionTrade( - string tradeId, - string[] volSurfaceNames, - string tradeDate, - string underlyingInstrumentType, - string[] underlyingTickers, - double[] weights, - SpreadType spreadType, - double strike, - string startDate, - string endDate, - string optionType, - string exerciseType, - double notional, - string tradeType, - string exerciseDate, - double participationRate, - bool isAnnualized, - double annualizeFactor, - bool hasNightMarket = false, - double riskFreeRateOverride = double.NaN, - bool commodityFuturesPreciseTimeMode = false) - { - underlyingInstrumentType = ConvertInstrumentType(underlyingInstrumentType); - var exercise = QdpConverter.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; - } - - var exerciseDates = new[] { temp_exerciseDate }; - var calendar = CalendarImpl.Get("chn"); - var observationDates = calendar.BizDaysBetweenDatesExcluStartDay(optionStartDate, temp_exerciseDate).ToArray(); - var normalizedWeight = new double[] { 1.0, 1.0, 1.0, 1.0 }; - for (var i = 0; i < weights.Length; i++) - { - normalizedWeight[i] = weights[i]; - } - - var optionDayCount = CalculatorHelper.GetTradeDayCount(); - - var spreadOption = new SpreadOption( - optionStartDate, - underlyingMaturityDate, - exercise, - (OptionType)Enum.Parse(typeof(OptionType), optionType), - spreadType, - normalizedWeight, - strike, - (InstrumentType)Enum.Parse(typeof(InstrumentType), underlyingInstrumentType), - CalendarImpl.Get("chn"), - optionDayCount.ToDayCountImpl(), - CurrencyCode.CNY, - CurrencyCode.CNY, - exerciseDates, - observationDates, - underlyingTickers, - notional, - null, - null, - 0, - hasNightMarket: hasNightMarket, - commodityFuturesPreciseTimeMode: commodityFuturesPreciseTimeMode, - participationRate: participationRate, - isAnnualized: isAnnualized, - riskFreeRateOverride: riskFreeRateOverride, - annualizedFactor: annualizeFactor); - - - if (string.IsNullOrWhiteSpace(tradeId)) - { - tradeId = Guid.NewGuid().ToString(); - } - - - return new SpreadOptionTrade( - tradeId, - tradeDate.ToDate(), - spreadOption.StartDate, - spreadOption.ExerciseDates.Last(), - QdpConverter.ConvertTradeType(tradeType), - spreadOption.Notional, - 0.0, - spreadOption) - { - ValuationParameters = createParametersForSpreadOption( - underlyingTickers, - "RiskFreeDiscountCurve", - volSurfaceNames) - }; - } - - public static TradeValueResult ValueSpreadOption( - IQdpMarketProxy marketProxy, - string valueDate, - string underlyingInstrumentType, - string[] underlyingTickers, - double[] weights, - SpreadType spreadType, - string[] volSurfaceNames, - double strike, - string startDate, - string endDate, - string optionType, - string exerciseType, - double[] spotPrices, - double notional, - double riskFreeRate, - double[] correlations, - string tradeType, - string exerciseDate, - double participationRate, - bool isAnnualized, - double annualizeFactor, - double[] dividendRates = null, - bool hasNightMarket = false, - bool commodityFuturesPreciseTimeMode = false, - string engineName = null, - string discountCurveName = null, - double riskFreeRateOverride = double.NaN, - PricingRequest pricingRequest = QdpPricingRequest.BASIC_GREEKS) - { - underlyingInstrumentType = ConvertInstrumentType(underlyingInstrumentType); - - if (volSurfaceNames == null) - { - volSurfaceNames = underlyingTickers.Select(x => x.GenerateVolSurfaceKey()).ToArray(); - } - - var optionTrade = CreateSpreadOptionTrade( - null, - volSurfaceNames, - startDate, - underlyingInstrumentType, - underlyingTickers, - weights, - spreadType, - strike, - startDate, - endDate, - optionType, - exerciseType, - notional, - tradeType, - exerciseDate, - participationRate, - isAnnualized, - annualizeFactor, - hasNightMarket: hasNightMarket, - riskFreeRateOverride: riskFreeRateOverride, - commodityFuturesPreciseTimeMode: commodityFuturesPreciseTimeMode).CheckMaturityDate(); - - var market = marketProxy.GetQdpMarket(valueDate); - if (market == null) - { - return null; - } - - var useLocalDiscountCurve = string.IsNullOrWhiteSpace(discountCurveName); - - //设置DiscountCurve - if (useLocalDiscountCurve) - { - discountCurveName = Guid.NewGuid().ToString(); - var discountCurve = CalculatorHelper.CreateConstantRiskFreeCurve(discountCurveName, riskFreeRate); - marketProxy.AddYieldCurve(discountCurveName, valueDate, discountCurve); - } - - //设置标的价格 - var count = Math.Min(underlyingTickers.Length, spotPrices.Length); - for (var i = 0; i < count; ++i) - { - marketProxy.AddStockPrice(underlyingTickers[i], valueDate, spotPrices[i]); - } - - //设置correlation - marketProxy.SaveCorrelationSurface(valueDate, new string[] { underlyingTickers[0], underlyingTickers[1] }, correlations[0]); - if (underlyingTickers.Length >= 3) - { - marketProxy.SaveCorrelationSurface(valueDate, new string[] { underlyingTickers[0], underlyingTickers[2] }, correlations[1]); - marketProxy.SaveCorrelationSurface(valueDate, new string[] { underlyingTickers[1], underlyingTickers[2] }, correlations[2]); - if (underlyingTickers.Length >= 4) - { - marketProxy.SaveCorrelationSurface(valueDate, new string[] { underlyingTickers[0], underlyingTickers[3] }, correlations[3]); - marketProxy.SaveCorrelationSurface(valueDate, new string[] { underlyingTickers[1], underlyingTickers[3] }, correlations[4]); - marketProxy.SaveCorrelationSurface(valueDate, new string[] { underlyingTickers[2], underlyingTickers[3] }, correlations[5]); - } - } - - var parameters = createParametersForSpreadOption(underlyingTickers, discountCurveName, volSurfaceNames); - - - try - { - var factory = OptionEngineFactory.GetEngineFactory("SpreadOption"); - var engine = factory.GetEngine(engineName); - var results = optionTrade.CalculateRisks(marketProxy.GetQdpMarket(valueDate), pricingRequest, engine, parameters); - - if (useLocalDiscountCurve) - { - marketProxy.RemoveYieldCurve(discountCurveName, valueDate); - } - - if (results.Succeeded) - { - var valueResult = new TradeValueResult() - { - Pv = results.Pv, - Delta = results.asset1Delta, - Gamma = results.asset1Gamma, - Vega = results.asset1Vega, - CalendarDayTheta = results.Theta, - TradingDayTheta = results.ThetaPnL, - Rho = results.Rho, - DeltaCash = results.DeltaCash, - GammaCash = results.GammaCash, - Vol = results.PricingVol, - - Delta2 = results.asset2Delta, - Gamma2 = results.asset2Gamma, - DeltaCash2 = results.asset2DeltaCash, - GammaCash2 = results.asset2GammaCash, - Vega2 = results.asset2Vega, - - Delta3 = results.asset3Delta, - Gamma3 = results.asset3Gamma, - DeltaCash3 = results.asset3DeltaCash, - GammaCash3 = results.asset3GammaCash, - Vega3 = results.asset3Vega, - - Delta4 = results.asset4Delta, - Gamma4 = results.asset4Gamma, - DeltaCash4 = results.asset4DeltaCash, - GammaCash4 = results.asset4GammaCash, - Vega4 = results.asset4Vega, - - CrossGamma = results.crossGamma, - CrossVogga = results.crossVomma, - CorrVega = results.correlationVega, - - RoundedPv = OtcFormatHelper.FormatValue(results.Pv / notional, 2) * notional - }; - - valueResult.UnderlyingCode = underlyingTickers[0]; - valueResult.UnderlyingCode2 = underlyingTickers[1]; - if (underlyingTickers.Length > 2) - { - valueResult.UnderlyingCode3 = underlyingTickers[2]; - } - if (underlyingTickers.Length > 3) - { - valueResult.UnderlyingCode4 = underlyingTickers[3]; - } - - return valueResult; - } - else - { - return null; - } - } - catch (Exception ex) - { - throw ex; - } - } - - - private static OptionValuationParameters createParametersForSpreadOption( - string[] underlyingTickers, string discountCurveName, string[] volSurfaceNames) - { - var dividendCurveNames = new string[] { MarketProxy.ConstantZeroCurve, MarketProxy.ConstantZeroCurve }; - var corrSurfNames = new string[] { underlyingTickers[0] + "_" + underlyingTickers[1] }; - - // construct correlation surface names - // see SpreadOptionTrade.GenerateMarketConditionFromPrebuilt for the order - if (underlyingTickers.Length == 3) - { - dividendCurveNames = new string[] { MarketProxy.ConstantZeroCurve, MarketProxy.ConstantZeroCurve, MarketProxy.ConstantZeroCurve }; - corrSurfNames = new string[] { - underlyingTickers[0] + "_" + underlyingTickers[1], - underlyingTickers[0] + "_" + underlyingTickers[2], - underlyingTickers[1] + "_" + underlyingTickers[2] - }; - } - else if (underlyingTickers.Length == 4) - { - dividendCurveNames = new string[] { MarketProxy.ConstantZeroCurve, MarketProxy.ConstantZeroCurve, MarketProxy.ConstantZeroCurve, MarketProxy.ConstantZeroCurve }; - corrSurfNames = new string[] { - underlyingTickers[0] + "_" + underlyingTickers[1], - underlyingTickers[0] + "_" + underlyingTickers[2], - underlyingTickers[1] + "_" + underlyingTickers[2], - underlyingTickers[0] + "_" + underlyingTickers[3], - underlyingTickers[1] + "_" + underlyingTickers[3], - underlyingTickers[2] + "_" + underlyingTickers[3], - }; - } - - return new OptionValuationParameters( - discountCurveName, - dividendCurveNames, - volSurfaceNames, - corrSurfNames, - null); - - } - - #endregion - - #region 合成价差期权 - - 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 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; - if (VolSurfaceInitializerSingleton.VolConstructionType == VolConstructionType.SkewMap && !ignoreSkewMap) - { - tradeId = Guid.NewGuid().ToString(); - SetSkewMapVol( - marketProxy, - valueDate, - underlyingTicker, - exerciseDate, - strike, - TradeCalcHelper.IsBuy(tradeType), - QdpHelper.IsCall(optionType), - tradeId, - spotPrice); - - volSurfaceName = tradeId.GenerateVolSurfaceKey(); - } - - 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) - { - return null; - } - - 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(); - - // 先获取返回的结果矩阵中的对角线上的元素,对应的是每个标的的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(); - } - - public static TradeValueResult ValueSyntheticNormalSpreadOptionTrade( - IQdpMarketProxy marketProxy, - string valueDate, - string underlyingTicker, - string underlyingInstrumentType, - double strike, - string startDate, - string endDate, - string optionType, - string exerciseType, - double spotPrice, - double notional, - string volSurfaceName, - double riskFreeRate, - string modelName, - string tradeType, - string exerciseDate, - double participationRate, - double principalRate, - bool isAnnualized, - double annualizeFactor, - double dividendRate = 0.0, - bool isMoneynessOption = false, - double initialSpotPrice = 0.0, - Dictionary 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, - PricingRequest pricingRequest = QdpPricingRequest.BASIC_GREEKS) - { - underlyingInstrumentType = ConvertInstrumentType(underlyingInstrumentType); - - return ValueSyntheticNormalSpreadOptionTrade( - VolSurfaceInitializerSingleton.VolConstructionType, - marketProxy, - valueDate, - underlyingTicker, - underlyingInstrumentType, - strike, - startDate, - endDate, - optionType, - exerciseType, - spotPrice, - notional, - volSurfaceName, - riskFreeRate, - modelName, - tradeType, - exerciseDate, - participationRate, - principalRate, - isAnnualized, - annualizeFactor, - dividendRate, - isMoneynessOption, - initialSpotPrice, - dividends, - hasNightMarket, - commodityFuturesPreciseTimeMode, - engineName, - discountCurveName, - ignoreSkewMap, - isForwardTrade, - timeToMaturityDays: timeToMaturityDays, - riskFreeRateOverride: riskFreeRateOverride, - dividendRateOverride: dividendRateOverride, - pricingRequest: pricingRequest); - } - - private static TradeValueResult ValueSyntheticNormalSpreadOptionTrade( - VolConstructionType volConstructionType, - IQdpMarketProxy marketProxy, - string valueDate, - string underlyingTicker, - string underlyingInstrumentType, - double strike, - string startDate, - string endDate, - string optionType, - string exerciseType, - double spotPrice, - double notional, - string volSurfaceName, - double riskFreeRate, - string modelName, - string tradeType, - string exerciseDate, - double participationRate, - double principalRate, - bool isAnnualized, - double annualizeFactor, - double dividendRate = 0.0, - bool isMoneynessOption = false, - double initialSpotPrice = 0.0, - Dictionary 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, - PricingRequest pricingRequest = QdpPricingRequest.BASIC_GREEKS) - { - if (volConstructionType == VolConstructionType.Normal || ignoreSkewMap) - { - return ValueSyntheticNormalSpreadOption( - marketProxy, - valueDate, - underlyingTicker, - underlyingInstrumentType, - strike, - startDate, - endDate, - optionType, - exerciseType, - spotPrice, - notional, - volSurfaceName, - riskFreeRate, - modelName, - tradeType, - exerciseDate, - participationRate, - principalRate, - isAnnualized, - annualizeFactor, - dividendRate, - isMoneynessOption, - initialSpotPrice, - dividends, - hasNightMarket, - commodityFuturesPreciseTimeMode, - engineName, - discountCurveName, - isForwardTrade, - timeToMaturityDays: timeToMaturityDays, - riskFreeRateOverride: riskFreeRateOverride, - dividendRateOverride: dividendRateOverride, - pricingRequest: pricingRequest); - } - else - { - var tradeId = Guid.NewGuid().ToString(); - SetSkewMapVol( - marketProxy, - valueDate, - underlyingTicker, - exerciseDate, - strike, - TradeCalcHelper.IsBuy(tradeType), - QdpHelper.IsCall(optionType), - tradeId, - spotPrice); - - return ValueSyntheticNormalSpreadOption( - marketProxy, - valueDate, - underlyingTicker, - underlyingInstrumentType, - strike, - startDate, - endDate, - optionType, - exerciseType, - spotPrice, - notional, - tradeId.GenerateVolSurfaceKey(), - riskFreeRate, - modelName, - tradeType, - exerciseDate, - participationRate, - principalRate, - isAnnualized, - annualizeFactor, - dividendRate, - isMoneynessOption, - initialSpotPrice, - dividends, - hasNightMarket, - commodityFuturesPreciseTimeMode, - engineName, - discountCurveName, - isForwardTrade, - timeToMaturityDays: timeToMaturityDays, - riskFreeRateOverride: riskFreeRateOverride, - dividendRateOverride: dividendRateOverride, - pricingRequest: pricingRequest); - } - } - private static TradeValueResult ValueSyntheticNormalSpreadOption( - IQdpMarketProxy marketProxy, - string valueDate, - string underlyingTicker, - string underlyingInstrumentType, - double strike, - string startDate, - string endDate, - string optionType, - string exerciseType, - double spotPrice, - double notional, - string volSurfaceName, - double riskFreeRate, - string modelName, - string tradeType, - string exerciseDate, - double participationRate, - double principalRate, - bool isAnnualized, - double annualizeFactor, - double dividendRate = 0.0, - bool isMoneynessOption = false, - double initialSpotPrice = 0.0, - Dictionary dividends = null, - bool hasNightMarket = false, - bool commodityFuturesPreciseTimeMode = false, - string engineName = null, - string discountCurveName = null, - bool isForwardTrade = false, - double timeToMaturityDays = double.NaN, - double riskFreeRateOverride = double.NaN, - double dividendRateOverride = double.NaN, - PricingRequest pricingRequest = QdpPricingRequest.BASIC_GREEKS) - { - if (string.IsNullOrWhiteSpace(volSurfaceName)) - { - volSurfaceName = underlyingTicker.GenerateVolSurfaceKey(); - } - - var optionTrade = CreateSyntheticNormalSpreadOptionTrade( - null, - volSurfaceName, - startDate, - underlyingTicker, - underlyingInstrumentType, - strike, - startDate, - endDate, - optionType, - exerciseType, - notional, - tradeType, - exerciseDate, - participationRate, - principalRate, - isAnnualized, - annualizeFactor, - null, // coefficients - isMoneynessOption, - initialSpotPrice, - dividends, - hasNightMarket: hasNightMarket, - commodityFuturesPreciseTimeMode: commodityFuturesPreciseTimeMode, - timeToMaturityDays: timeToMaturityDays, - riskFreeRateOverride: riskFreeRateOverride, - dividendRateOverride: dividendRateOverride).CheckMaturityDate(); - - var market = marketProxy.GetQdpMarket(valueDate); - if (market == null) - { - return null; - } - - 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; - string dividendCurveName = null; - if (underlyingInstrumentType == "Stock") - { - //设置DividendCurve - 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); - } - - try - { - var option = optionTrade.Instrument as VanillaOption; - var factory = OptionEngineFactory.GetEngineFactory("SynthticNormalSpreadOption"); - var engine = factory.GetEngine(engineName, option.Exercise); - - var results = optionTrade.CalculateRisks(marketProxy.GetQdpMarket(valueDate), pricingRequest, engine, parameters); - - if (useLocalDiscountCurve) - { - marketProxy.RemoveYieldCurve(discountCurveName, valueDate); - } - - if (!string.IsNullOrEmpty(dividendCurveName)) - { - marketProxy.RemoveYieldCurve(dividendCurveName, valueDate); - } - - if (results.Succeeded) - { - //double vol = marketProxy.GetVol(valueDate, underlyingTicker, strike, endDate, spotPrice); - //if (isMoneynessOption) - //{ - // vol = marketProxy.GetVol(valueDate, underlyingTicker, strike / spotPrice, endDate); - //} - //else - //{ - // vol = marketProxy.GetVol(valueDate, underlyingTicker, strike, endDate); - //} - - var ret = new TradeValueResult() - { - UnderlyingCode = underlyingTicker, - Pv = results.Pv, - Delta = results.Delta, - Gamma = results.Gamma, - Vega = results.Vega, - CalendarDayTheta = results.Theta, - TradingDayTheta = results.ThetaPnL, - Rho = results.Rho, - DeltaCash = results.DeltaCash, - GammaCash = results.GammaCash, - Vol = results.PricingVol, - RoundedPv = OtcFormatHelper.FormatValue(results.Pv / notional, 2) * notional - }; - return ret; - } - else - { - return null; - } - } - catch - { - throw; - } - } - - 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 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 = QdpConverter.ConvertExerciseType(exerciseType); - var optionStartDate = startDate.ToDate(); - var temp_exerciseDate = exerciseDate.ToDate(); - - if (temp_exerciseDate < optionStartDate) - { - return null; - } - - Date[] exerciseDates; - Date[] observationDates; - 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) - }; - } - #endregion - - #region 亚式合成价差期权 - public static AsianSyntheticNormalSpreadOptionTrade CreateAsianSyntheticNormalSpreadOptionTrade( - string tradeId, - string volSurfaceName, - string tradeDate, - string underlyingTicker, - string underlyingInstrumentType, - double strike, - string startDate, - string endDate, - string optionType, - string exerciseType, - string asianType, - string strikeStyle, - double notional, - string tradeType, - string exerciseDate, - bool isAnnualized, - double annualizeFactor, - bool isMoneynessOption = false, - double initialSpotPrice = 0.0, - Dictionary dividends = null, - string averagingPeriodStartDate = null, - string fixings = null, - bool hasNightMarket = false, - bool commodityFuturesPreciseTimeMode = false, - double timeToMaturityDays = double.NaN, - double riskFreeRateOverride = double.NaN, - double dividendRateOverride = double.NaN) - { - underlyingInstrumentType = ConvertInstrumentType(underlyingInstrumentType); - - var exercise = QdpConverter.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; - var calendar = CalendarImpl.Get("chn"); - - if (exercise == OptionExercise.American) - { - exerciseDates = calendar.BizDaysBetweenDatesInclEndDay(optionStartDate, temp_exerciseDate).ToArray(); - } - else - { - exerciseDates = new Date[] { temp_exerciseDate }; - } - - observationDates = calendar.BizDaysBetweenDatesExcluStartDay(optionStartDate, temp_exerciseDate).Union(new[] { temp_exerciseDate }).ToArray(); - if (!string.IsNullOrWhiteSpace(averagingPeriodStartDate)) - { - observationDates = calendar.BizDaysBetweenDatesInclEndDay(averagingPeriodStartDate.ToDate(), exerciseDates.Last()).ToArray(); - } - - var fixingValues = string.IsNullOrWhiteSpace(fixings) - ? new Dictionary() : - fixings.Split(QdpConsts.Semilicon) - .Select(x => - { - var splits = x.Split(QdpConsts.Comma); - return Tuple.Create(splits[0].ToDate(), double.Parse(splits[1])); - }).ToDictionary(x => x.Item1, x => x.Item2); - - var optionDayCount = CalculatorHelper.GetTradeDayCount(); - var pricingTOverride = double.IsNaN(timeToMaturityDays) ? double.NaN : QdpCalendarHelper.CalculateTFromDays(timeToMaturityDays, optionDayCount, optionStartDate.DateTime); - - var asianSyntheticNormalSpreadOption = - new AsianSyntheticNormalSpreadOption( - optionStartDate, - (OptionExercise)Enum.Parse(typeof(OptionExercise), exerciseType), - (OptionType)Enum.Parse(typeof(OptionType), optionType), - (AsianType)Enum.Parse(typeof(AsianType), asianType), - (StrikeStyle)Enum.Parse(typeof(StrikeStyle), strikeStyle), - strike, - (InstrumentType)Enum.Parse(typeof(InstrumentType), underlyingInstrumentType), - CalendarImpl.Get("chn"), - optionDayCount.ToDayCountImpl(), - CurrencyCode.CNY, - CurrencyCode.CNY, - exerciseDates, - observationDates, - fixingValues, - 1.0, //StrikeGearingFator - 1.0, //ParticipationRate - notional, - null, - null, - 0, - isMoneynessOption, - initialSpotPrice, - dividends, - hasNightMarket: hasNightMarket, - commodityFuturesPreciseTimeMode: commodityFuturesPreciseTimeMode, - pricingToverride: pricingTOverride, - riskFreeRateOverride: riskFreeRateOverride, - dividendRateOverride: dividendRateOverride, - isAnnualized: isAnnualized, - annualizedFactor: annualizeFactor) - { - UnderlyingTickers = new string[] { underlyingTicker } - }; - - if (string.IsNullOrWhiteSpace(tradeId)) - { - tradeId = Guid.NewGuid().ToString(); - } - return new AsianSyntheticNormalSpreadOptionTrade( - tradeId, - tradeDate.ToDate(), - asianSyntheticNormalSpreadOption.StartDate, - asianSyntheticNormalSpreadOption.ExerciseDates.Last(), - QdpConverter.ConvertTradeType(tradeType), - asianSyntheticNormalSpreadOption.Notional, - 0.0, - asianSyntheticNormalSpreadOption) - { - ValuationParameters = new OptionValuationParameters("RiskFreeDiscountCurve", MarketProxy.ConstantZeroCurve, volSurfaceName, asianSyntheticNormalSpreadOption.UnderlyingTickers[0]) - }; - } - - public static TradeValueResult ValueAsianSyntheticNormalSpreadOptionTrade( - IQdpMarketProxy marketProxy, - string valueDate, - string underlyingTicker, - string underlyingInstrumentType, - double strike, - string startDate, - string endDate, - string optionType, - string exerciseType, - string asianType, - string strikeStyle, - double spotPrice, - double notional, - string volSurfaceName, - double riskFreeRate, - string tradeType, - string exerciseDate, - bool isAnnualized, - double annualizeFactor, - double dividendRate = 0.0, - bool isMoneynessOption = false, - double initialSpotPrice = 0.0, - Dictionary dividends = null, - string fixings = null, - string averagingPeriodStartDate = null, - bool hasNightMarket = false, - bool commodityFuturesPreciseTimeMode = false, - string engineName = null, - string discountCurveName = null, - bool isForwardTrade = false, - bool ignoreSkewMap = false, - double timeToMaturityDays = double.NaN, - double riskFreeRateOverride = double.NaN, - double dividendRateOverride = double.NaN, - PricingRequest pricingRequest = QdpPricingRequest.BASIC_GREEKS) - { - underlyingInstrumentType = ConvertInstrumentType(underlyingInstrumentType); - - return ValueAsianSyntheticNormalSpreadOptionTrade( - VolSurfaceInitializerSingleton.VolConstructionType, - marketProxy, - valueDate, - underlyingTicker, - underlyingInstrumentType, - strike, - startDate, - endDate, - optionType, - exerciseType, - asianType, - strikeStyle, - spotPrice, - notional, - volSurfaceName, - riskFreeRate, - tradeType, - exerciseDate, - isAnnualized, - annualizeFactor, - dividendRate, - isMoneynessOption, - initialSpotPrice, - dividends, - fixings, - averagingPeriodStartDate, - hasNightMarket, - commodityFuturesPreciseTimeMode, - engineName, - discountCurveName, - isForwardTrade, - ignoreSkewMap, - timeToMaturityDays: timeToMaturityDays, - riskFreeRateOverride: riskFreeRateOverride, - dividendRateOverride: dividendRateOverride, - pricingRequest: pricingRequest); - } - - private static TradeValueResult ValueAsianSyntheticNormalSpreadOptionTrade( - VolConstructionType volConstructionType, - IQdpMarketProxy marketProxy, - string valueDate, - string underlyingTicker, - string underlyingInstrumentType, - double strike, - string startDate, - string endDate, - string optionType, - string exerciseType, - string asianType, - string strikeStyle, - double spotPrice, - double notional, - string volSurfaceName, - double riskFreeRate, - string tradeType, - string exerciseDate, - bool isAnnualized, - double annualizeFactor, - double dividendRate = 0.0, - bool isMoneynessOption = false, - double initialSpotPrice = 0.0, - Dictionary dividends = null, - string fixings = null, - string averagingPeriodStartDate = null, - bool hasNightMarket = false, - bool commodityFuturesPreciseTimeMode = false, - string engineName = null, - string discountCurveName = null, - bool isForwardTrade = false, - bool ignoreSkewMap = false, - double timeToMaturityDays = double.NaN, - double riskFreeRateOverride = double.NaN, - double dividendRateOverride = double.NaN, - PricingRequest pricingRequest = QdpPricingRequest.BASIC_GREEKS) - { - if (volConstructionType == VolConstructionType.Normal || ignoreSkewMap) - { - return ValueAsianSyntheticNormalSpreadOption( - marketProxy, - valueDate, - underlyingTicker, - underlyingInstrumentType, - strike, - startDate, - endDate, - optionType, - exerciseType, - asianType, - strikeStyle, - spotPrice, - notional, - volSurfaceName, - riskFreeRate, - tradeType, - exerciseDate, - isAnnualized, - annualizeFactor, - dividendRate, - isMoneynessOption, - initialSpotPrice, - dividends, - fixings, - averagingPeriodStartDate, - hasNightMarket, - commodityFuturesPreciseTimeMode, - engineName, - discountCurveName, - isForwardTrade, - timeToMaturityDays: timeToMaturityDays, - riskFreeRateOverride: riskFreeRateOverride, - dividendRateOverride: dividendRateOverride, - pricingRequest: pricingRequest); - } - else - { - var tradeId = Guid.NewGuid().ToString(); - SetSkewMapVol( - marketProxy, - valueDate, - underlyingTicker, - exerciseDate, - strike, - TradeCalcHelper.IsBuy(tradeType), - QdpHelper.IsCall(optionType), - tradeId, - spotPrice); - - return ValueAsianSyntheticNormalSpreadOption( - marketProxy, - valueDate, - underlyingTicker, - underlyingInstrumentType, - strike, - startDate, - endDate, - optionType, - exerciseType, - asianType, - strikeStyle, - spotPrice, - notional, - tradeId.GenerateVolSurfaceKey(), - riskFreeRate, - tradeType, - exerciseDate, - isAnnualized, - annualizeFactor, - dividendRate, - isMoneynessOption, - initialSpotPrice, - dividends, - fixings, - averagingPeriodStartDate, - hasNightMarket, - commodityFuturesPreciseTimeMode, - engineName, - discountCurveName, - isForwardTrade, - timeToMaturityDays: timeToMaturityDays, - riskFreeRateOverride: riskFreeRateOverride, - dividendRateOverride: dividendRateOverride, - pricingRequest: pricingRequest); - } - } - - private static TradeValueResult ValueAsianSyntheticNormalSpreadOption( - IQdpMarketProxy marketProxy, - string valueDate, - string underlyingTicker, - string underlyingInstrumentType, - double strike, - string startDate, - string endDate, - string optionType, - string exerciseType, - string asianType, - string strikeStyle, - double spotPrice, - double notional, - string volSurfaceName, - double riskFreeRate, - string tradeType, - string exerciseDate, - bool isAnnualized, - double annualizeFactor, - double dividendRate = 0.0, - bool isMoneynessOption = false, - double initialSpotPrice = 0.0, - Dictionary dividends = null, - string fixings = null, - string averagingPeriodStartDate = null, - bool hasNightMarket = false, - bool commodityFuturesPreciseTimeMode = false, - string engineName = null, - string discountCurveName = null, - bool isForwardTrade = false, - double timeToMaturityDays = double.NaN, - double riskFreeRateOverride = double.NaN, - double dividendRateOverride = double.NaN, - PricingRequest pricingRequest = QdpPricingRequest.BASIC_GREEKS) - { - if (string.IsNullOrWhiteSpace(volSurfaceName)) - { - volSurfaceName = underlyingTicker.GenerateVolSurfaceKey(); - } - var optionTrade = CreateAsianSyntheticNormalSpreadOptionTrade( - null, - volSurfaceName, - startDate, - underlyingTicker, - underlyingInstrumentType, - strike, - startDate, - endDate, - optionType, - exerciseType, - asianType, - strikeStyle, - notional, - tradeType, - exerciseDate, - isAnnualized, - annualizeFactor, - isMoneynessOption, - initialSpotPrice, - dividends, - averagingPeriodStartDate, - fixings, - hasNightMarket: hasNightMarket, - commodityFuturesPreciseTimeMode: commodityFuturesPreciseTimeMode, - timeToMaturityDays: timeToMaturityDays, - riskFreeRateOverride: riskFreeRateOverride, - dividendRateOverride: dividendRateOverride).CheckMaturityDate(); - - var market = marketProxy.GetQdpMarket(valueDate); - if (market == null) - { - return null; - } - - 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; - string dividendCurveName = null; - if (underlyingInstrumentType == "Stock") - { - //设置DividendCurve - 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 option = optionTrade.Instrument as AsianOption; - //var factory = OptionEngineFactory.GetEngineFactory("AsianOption"); - var engine = new AnalyticalAsianSyntheticNormalSpreadOptionEngine(); - var results = optionTrade.CalculateRisks(marketProxy.GetQdpMarket(valueDate), pricingRequest, engine, parameters); - - if (useLocalDiscountCurve) - { - marketProxy.RemoveYieldCurve(discountCurveName, valueDate); - } - if (!string.IsNullOrEmpty(dividendCurveName)) - { - marketProxy.RemoveYieldCurve(dividendCurveName, valueDate); - } - - if (results.Succeeded) - { - //double vol = marketProxy.GetVol(valueDate, underlyingTicker, strike, endDate, spotPrice); - //if (isMoneynessOption) - //{ - // vol = marketProxy.GetVol(valueDate, underlyingTicker, strike / spotPrice, endDate); - //} - //else - //{ - // vol = marketProxy.GetVol(valueDate, underlyingTicker, strike, endDate); - //} - return new TradeValueResult() - { - UnderlyingCode = underlyingTicker, - Pv = results.Pv, - Delta = results.Delta, - Gamma = results.Gamma, - Vega = results.Vega, - CalendarDayTheta = results.Theta, - TradingDayTheta = results.ThetaPnL, - Rho = results.Rho, - DeltaCash = results.DeltaCash, - GammaCash = results.GammaCash, - Vol = results.PricingVol, - DDeltaDVol = results.DDeltaDvol, - DDeltaDt = results.DDeltaDt, - DVegaDVol = results.DVegaDvol, - DVegaDt = results.DVegaDt, - StoppingTime = results.StoppingTime, - RoundedPv = OtcFormatHelper.FormatValue(results.Pv / notional, 2) * notional, - SA_Delta = results.SA_Delta, - TimeValue = results.TimeValue - }; - } - else - { - return null; - } - } - - #endregion - - #region 双鲨期权 - public static TradeValueResult ValueDoubleSharkFinOptionTrade( - PrebuiltQdpMarketProxy marketProxy, - string valueDate, - string underlyingCode, - string underlyingInstrumentType, - double strikeHigh, - double strikeLow, - string startDate, - string endDate, - string callPut, - string exerciseMode, - double barrierHigh, - double barrierLow, - bool isDiscrete, - double spotPrice, - double rebate, - double rebateHigh, - string rebateType, - double notional, - string volSurfaceName, - double riskFreeRate, - string buySell, - string exerciseDate, - double participationRate, - double principalRate, - bool isAnnualized, - double annualizeFactor, - double callParticipationRate, - double putParticipationRate, - double dividendRate = 0.0, - bool isMoneynessOptionData = false, - double initialSpotPrice = 0.0, - string observationDates = null, - Dictionary dividends = null, - string knockInOutStatus = "Monitoring", - bool hasNightMarket = false, - bool commodityFuturesPreciseTimeMode = false, - string discountCurveName = null, - double timeToMaturityDays = double.NaN, - bool ignoreSkewMap = false, - string engineName = null, - double riskFreeRateOverride = double.NaN, - double dividendRateOverride = double.NaN, - PricingRequest pricingRequest = QdpPricingRequest.BASIC_GREEKS) - { - underlyingInstrumentType = ConvertInstrumentType(underlyingInstrumentType); - - return ValueDoubleSharkFinOptionTrade( - VolSurfaceInitializerSingleton.VolConstructionType, - marketProxy, - valueDate, - underlyingCode, - underlyingInstrumentType, - strikeHigh, - strikeLow, - startDate, - endDate, - callPut, - exerciseMode, - barrierHigh, - barrierLow, - isDiscrete, - spotPrice, - rebate, - rebateHigh, - rebateType, - notional, - volSurfaceName, - riskFreeRate, - buySell, - exerciseDate, - dividendRate, - participationRate, - principalRate, - isAnnualized, - annualizeFactor, - callParticipationRate, - putParticipationRate, - isMoneynessOptionData, - initialSpotPrice, - observationDates, - dividends, - knockInOutStatus, - hasNightMarket, - commodityFuturesPreciseTimeMode, - discountCurveName, - timeToMaturityDays, - ignoreSkewMap, - engineName, - riskFreeRateOverride: riskFreeRateOverride, - dividendRateOverride: dividendRateOverride, - pricingRequest: pricingRequest); - } - - private static TradeValueResult ValueDoubleSharkFinOptionTrade( - VolConstructionType volConstructionType, - PrebuiltQdpMarketProxy marketProxy, - string valueDate, - string underlyingCode, - string underlyingInstrumentType, - double strikeHigh, - double strikeLow, - string startDate, - string endDate, - string callPut, - string exerciseMode, - double barrierHigh, - double barrierLow, - bool isDiscrete, - double spotPrice, - double rebate, - double rebateHigh, - string rebateType, - double notional, - string volSurfaceName, - double riskFreeRate, - string buySell, - string exerciseDate, - double dividendRate, - double participationRate, - double principalRate, - bool isAnnualized, - double annualizeFactor, - double callParticipationRate, - double putParticipationRate, - bool isMoneynessOptionData, - double initialSpotPrice, - string observationDates, - Dictionary dividends, - string knockInOutStatus, - bool hasNightMarket, - bool commodityFuturesPreciseTimeMode, - string discountCurveName, - double timeToMaturityDays, - bool ignoreSkewMap, - string engineName, - double riskFreeRateOverride = double.NaN, - double dividendRateOverride = double.NaN, - PricingRequest pricingRequest = QdpPricingRequest.BASIC_GREEKS) - { - if (volConstructionType == VolConstructionType.Normal || ignoreSkewMap) - { - return ValueDoubleSharkFinOption( - marketProxy, - valueDate, - underlyingCode, - underlyingInstrumentType, - strikeHigh, - strikeLow, - startDate, - endDate, - callPut, - exerciseMode, - barrierHigh, - barrierLow, - isDiscrete, - spotPrice, - rebate, - rebateHigh, - rebateType, - notional, - volSurfaceName, - riskFreeRate, - buySell, - exerciseDate, - dividendRate, - participationRate, - principalRate, - isAnnualized, - annualizeFactor, - callParticipationRate, - putParticipationRate, - isMoneynessOptionData, - initialSpotPrice, - observationDates, - dividends, - knockInOutStatus, - hasNightMarket, - commodityFuturesPreciseTimeMode, - discountCurveName, - timeToMaturityDays, - engineName, - riskFreeRateOverride: riskFreeRateOverride, - dividendRateOverride: dividendRateOverride, - pricingRequest: pricingRequest); - } - else - { - var tradeId = Guid.NewGuid().ToString(); - SetSkewMapVol( - marketProxy, - valueDate, - underlyingCode, - exerciseDate, - (strikeHigh + strikeLow) / 2.0, - TradeCalcHelper.IsBuy(buySell), - QdpHelper.IsCall(callPut), - tradeId, - spotPrice); - - return ValueDoubleSharkFinOption( - marketProxy, - valueDate, - underlyingCode, - underlyingInstrumentType, - strikeHigh, - strikeLow, - startDate, - endDate, - callPut, - exerciseMode, - barrierHigh, - barrierLow, - isDiscrete, - spotPrice, - rebate, - rebateHigh, - rebateType, - notional, - tradeId.GenerateVolSurfaceKey(), - riskFreeRate, - buySell, - exerciseDate, - dividendRate, - participationRate, - principalRate, - isAnnualized, - annualizeFactor, - callParticipationRate, - putParticipationRate, - isMoneynessOptionData, - initialSpotPrice, - observationDates, - dividends, - knockInOutStatus, - hasNightMarket, - commodityFuturesPreciseTimeMode, - discountCurveName, - timeToMaturityDays, - engineName, - riskFreeRateOverride: riskFreeRateOverride, - dividendRateOverride: dividendRateOverride, - pricingRequest: pricingRequest); - } - } - - public static DoubleSharkFinOptionTrade CreateDoubleSharkFinOptionTrade( - string tradeId, - string volSurfaceName, - string tradeDate, - string underlyingTicker, - string underlyingInstrumentType, - double strikeHigh, - double strikeLow, - string startDate, - string endDate, - string exerciseType, - double barrierHigh, - double barrierLow, - bool isDiscrete, - double rebate, - double rebateHigh, - string rebateType, - double notional, - string tradeType, - string exerciseDate, - double participationRate, - double principalRate, - bool isAnnualized, - double annualizeFactor, - double callParticipationRate, - double putParticipationRate, - bool isMoneynessOption = false, - double initialSpotPrice = 0.0, - string observationDateStr = null, - string barrierStatus = "Monitoring", - bool hasNightMarket = false, - bool commodityFuturesPreciseTimeMode = false, - double timeToMaturityDays = double.NaN, - double riskFreeRateOverride = double.NaN, - double dividendRateOverride = double.NaN) - { - underlyingInstrumentType = ConvertInstrumentType(underlyingInstrumentType); - - var exercise = QdpConverter.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; - var observationDates = QdpHelper.ParseObservationDate(observationDateStr); - - if (exercise == OptionExercise.American) - { - exerciseDates = CalendarImpl.Get("chn").BizDaysBetweenDatesInclEndDay(optionStartDate, temp_exerciseDate).ToArray(); - if (observationDates == null) - { - observationDates = CalendarImpl.Get("chn").BizDaysBetweenDatesExcluStartDay(optionStartDate, temp_exerciseDate).ToArray(); - } - } - else - { - exerciseDates = new Date[] { temp_exerciseDate }; - if (observationDates == null) - { - observationDates = CalendarImpl.Get("chn").BizDaysBetweenDatesExcluStartDay(optionStartDate, temp_exerciseDate).Union(new[] { temp_exerciseDate }).ToArray(); - } - } - - var optionDayCount = CalculatorHelper.GetTradeDayCount(); - - var pricingTOverride = double.IsNaN(timeToMaturityDays) ? double.NaN : QdpCalendarHelper.CalculateTFromDays(timeToMaturityDays, optionDayCount, optionStartDate.DateTime); - - var lowRebateValue = double.IsNaN(rebate) ? 0.0 : rebate; - var highReateValue = double.IsNaN(rebateHigh) ? 0.0 : rebateHigh; - - var doubleSharkFinOption = - new DoubleSharkFinOption( - strikeHigh, - strikeLow, - Enumerable.Repeat(barrierHigh, observationDates.Length).ToArray(), - Enumerable.Repeat(barrierLow, observationDates.Length).ToArray(), - Enumerable.Repeat(lowRebateValue, observationDates.Length).ToArray(), - Enumerable.Repeat(highReateValue, observationDates.Length).ToArray(), - (string.IsNullOrEmpty(rebateType) ? "AtEnd" : rebateType).ToBinaryRebateType(), - observationDates, - optionStartDate, - underlyingMaturityDate, - participationRate, - isDiscrete, - (InstrumentType)Enum.Parse(typeof(InstrumentType), underlyingInstrumentType), - CalendarImpl.Get("chn"), - optionDayCount.ToDayCountImpl(), - CurrencyCode.CNY, - CurrencyCode.CNY, - exerciseDates, - callParticipationRate, - putParticipationRate, - isMoneynessOption, - initialSpotPrice, - notional, - settlementGap: null, - optionPremiumPaymentDate: null, - optionPremium: 0, - pricingToverride: pricingTOverride, - barrierStatus: QdpConverter.ConvertBarrierStatus(barrierStatus), - hasNightMarket: hasNightMarket, - commodityFuturesPreciseTimeMode: commodityFuturesPreciseTimeMode, - riskFreeRateOverride: riskFreeRateOverride, - dividendRateOverride: dividendRateOverride, - isAnnualized: isAnnualized, - annualizedFactor: annualizeFactor) - { - UnderlyingTickers = new string[] { underlyingTicker } - }; - - if (string.IsNullOrWhiteSpace(tradeId)) - { - tradeId = Guid.NewGuid().ToString(); - } - return new DoubleSharkFinOptionTrade( - tradeId, - tradeDate.ToDate(), - doubleSharkFinOption.StartDate, - doubleSharkFinOption.ExerciseDates.Last(), - QdpConverter.ConvertTradeType(tradeType), - doubleSharkFinOption.Notional, - 0.0, - doubleSharkFinOption) - { - ValuationParameters = new OptionValuationParameters("RiskFreeDiscountCurve", MarketProxy.ConstantZeroCurve, volSurfaceName, doubleSharkFinOption.UnderlyingTickers[0]), - ProtectionRate = principalRate, - ParticipationRate = participationRate, - AnnualizedFactor = annualizeFactor, - OriginalNotional = TradeHelper.GetStockEqvNotional(notional * initialSpotPrice, participationRate, annualizeFactor) - }; - } - - private static TradeValueResult ValueDoubleSharkFinOption( - PrebuiltQdpMarketProxy marketProxy, - string valueDate, - string underlyingCode, - string underlyingInstrumentType, - double strikeHigh, - double strikeLow, - string startDate, - string endDate, - string callPut, - string exerciseMode, - double barrierHigh, - double barrierLow, - bool isDiscrete, - double spotPrice, - double rebate, - double rebateHigh, - string rebateType, - double notional, - string volSurfaceName, - double riskFreeRate, - string buySell, - string exerciseDate, - double dividendRate, - double participationRate, - double principalRate, - bool isAnnualized, - double annualizeFactor, - double callParticipationRate, - double putParticipationRate, - bool isMoneynessOptionData, - double initialSpotPrice, - string observationDateStr, - Dictionary dividends, - string knockInOutStatus, - bool hasNightMarket, - bool commodityFuturesPreciseTimeMode, - string discountCurveName, - double timeToMaturityDays, - string engineName, - double riskFreeRateOverride = double.NaN, - double dividendRateOverride = double.NaN, - PricingRequest pricingRequest = QdpPricingRequest.BASIC_GREEKS) - { - if (string.IsNullOrWhiteSpace(volSurfaceName)) - { - volSurfaceName = underlyingCode.GenerateVolSurfaceKey(); - } - - //如果用户自定义的观察日就是每天观察,则忽略自定义观察日 - var observationDates = CalendarImpl.Get("chn").BizDaysBetweenDatesExcluStartDay(startDate.ToDate(), exerciseDate.ToDate()).Union(new[] { exerciseDate.ToDate() }).ToArray(); - var barrierObservationDates = QdpHelper.ParseObservationDate(observationDateStr); - if (barrierObservationDates != null && - (barrierObservationDates.Count(d => d >= observationDates.First() && d <= observationDates.Last()) == observationDates.Length)) - { - observationDateStr = null; - } - - var optionTrade = CreateDoubleSharkFinOptionTrade( - null, - volSurfaceName, - startDate, - underlyingCode, - underlyingInstrumentType, - strikeHigh, - strikeLow, - startDate, - endDate, - exerciseMode, - barrierHigh, - barrierLow, - isDiscrete, - rebate, - rebateHigh, - rebateType, - notional, - buySell, - exerciseDate, - participationRate, - principalRate, - isAnnualized, - annualizeFactor, - callParticipationRate, - putParticipationRate, - isMoneynessOptionData, - initialSpotPrice, - observationDateStr, - knockInOutStatus, - hasNightMarket, - commodityFuturesPreciseTimeMode, - timeToMaturityDays, - riskFreeRateOverride: riskFreeRateOverride, - dividendRateOverride: dividendRateOverride).CheckMaturityDate(); - - var market = marketProxy.GetQdpMarket(valueDate); - if (market == null) - { - return null; - } - - 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(underlyingCode, valueDate, spotPrice); - - OptionValuationParameters parameters = null; - string dividendCurveName = null; - if (underlyingInstrumentType == "Stock") - { - //设置DividendCurve - dividendCurveName = Guid.NewGuid().ToString(); - var dividendCurve = CalculatorHelper.CreateConstantRiskFreeCurve(dividendCurveName, dividendRate); - marketProxy.AddYieldCurve(dividendCurveName, valueDate, dividendCurve); - - parameters = new OptionValuationParameters( - discountCurveName, - dividendCurveName, - volSurfaceName, - underlyingCode); - } - else - { - parameters = new OptionValuationParameters( - discountCurveName, - MarketProxy.ConstantZeroCurve, - volSurfaceName, - underlyingCode); - } - - try - { - var option = optionTrade.Instrument as DoubleSharkFinOption; - var factory = OptionEngineFactory.GetEngineFactory("DoubleSharkFinOption"); - var engine = factory.GetEngine(engineName, option.Exercise, option, false, !string.IsNullOrWhiteSpace(observationDateStr), true); - var results = optionTrade.CalculateRisks(marketProxy.GetQdpMarket(valueDate), pricingRequest, engine, parameters); - - if (useLocalDiscountCurve) - { - marketProxy.RemoveYieldCurve(discountCurveName, valueDate); - } - if (!string.IsNullOrEmpty(dividendCurveName)) - { - marketProxy.RemoveYieldCurve(dividendCurveName, valueDate); - } - - if (results.Succeeded) - { - //double vol = marketProxy.GetVol(valueDate, underlyingTicker, strike, endDate, spotPrice); - //if (isMoneynessOption) - //{ - // vol = marketProxy.GetVol(valueDate, underlyingTicker, strike / spotPrice, endDate); - //} - //else - //{ - // vol = marketProxy.GetVol(valueDate, underlyingTicker, strike, endDate); - //} - return new TradeValueResult() - { - UnderlyingCode = underlyingCode, - Pv = results.Pv, - Delta = results.Delta, - Gamma = results.Gamma, - Vega = results.Vega, - CalendarDayTheta = results.Theta, - TradingDayTheta = results.ThetaPnL, - Rho = results.Rho, - DeltaCash = results.DeltaCash, - GammaCash = results.GammaCash, - Vol = results.PricingVol, - DDeltaDVol = results.DDeltaDvol, - DDeltaDt = results.DDeltaDt, - DVegaDVol = results.DVegaDvol, - DVegaDt = results.DVegaDt, - StoppingTime = results.StoppingTime, - RoundedPv = OtcFormatHelper.FormatValue(results.Pv / notional, 2) * notional - }; - } - else - { - return null; - } - } - catch (Exception ex) - { - throw ex; - //return null; - } - } - #endregion - - #region 凤凰期权 - - public static TradeValueResult ValueAutocallTrade( - PrebuiltQdpMarketProxy marketProxy, - string valueDate, - string underlyingCode, - string underlyingInstrumentType, - string startDate, - string endDate, - string callPut, - double koBarrier, - double kiBarrier, - double couponBarrier, - string koObservationDateStr, - string observationDateStr, - double coupon, - bool couponPayAtMaturity, - bool includeCouponAfterKI, - bool isFixedCoupon, - bool annualizedOptionPayoff, - double participationRate, - double principalRate, - double spotPrice, - double notional, - string volSurfaceName, - double riskFreeRate, - string buySell, - string exerciseDate, - double annualizeFactor, - double strike, - double spreadStrike, - string couponDayCount, - List happenedObservations, - string kiOptionType = "Put", - double dividendRate = 0.0, - bool isMoneynessOptionData = false, - double initialSpotPrice = 0.0, - string observationDates = null, - Dictionary dividends = null, - string knockInOutStatus = "Monitoring", - bool hasNightMarket = false, - bool commodityFuturesPreciseTimeMode = false, - string discountCurveName = null, - double timeToMaturityDays = double.NaN, - bool ignoreSkewMap = false, - string engineName = null, - double riskFreeRateOverride = double.NaN, - double dividendRateOverride = double.NaN) - { - underlyingInstrumentType = ConvertInstrumentType(underlyingInstrumentType); - return ValueAutocallTrade( - VolSurfaceInitializerSingleton.VolConstructionType, - marketProxy: marketProxy, - valueDate: valueDate, - underlyingCode: underlyingCode, - underlyingInstrumentType: underlyingInstrumentType, - startDate: startDate, - endDate: endDate, - callPut: callPut, - koBarrier: koBarrier, - kiBarrier: kiBarrier, - couponBarrier: couponBarrier, - koObservationDateStr: koObservationDateStr, - observationDateStr: observationDateStr, - coupon: coupon, - couponPayAtMaturity: couponPayAtMaturity, - includeCouponAfterKI: includeCouponAfterKI, - isFixedCoupon: isFixedCoupon, - annualizedOptionPayoff: annualizedOptionPayoff, - participationRate: participationRate, - principalRate: principalRate, - spotPrice: spotPrice, - notional: notional, - volSurfaceName: volSurfaceName, - riskFreeRate: riskFreeRate, - buySell: buySell, - exerciseDate: exerciseDate, - annualizeFactor: annualizeFactor, - strike: strike, - spreadStrike: spreadStrike, - couponDayCount: couponDayCount, - happenedObservations: happenedObservations, - kiOptionType: kiOptionType, - dividendRate: dividendRate, - isMoneynessOptionData: isMoneynessOptionData, - initialSpotPrice: initialSpotPrice, - observationDates: observationDates, - dividends: dividends, - knockInOutStatus: knockInOutStatus, - hasNightMarket: hasNightMarket, - commodityFuturesPreciseTimeMode: commodityFuturesPreciseTimeMode, - discountCurveName: discountCurveName, - timeToMaturityDays: timeToMaturityDays, - ignoreSkewMap: ignoreSkewMap, - engineName: engineName, - riskFreeRateOverride: riskFreeRateOverride, - dividendRateOverride: dividendRateOverride); - } - - private static TradeValueResult ValueAutocallTrade( - VolConstructionType volConstructionType, - PrebuiltQdpMarketProxy marketProxy, - string valueDate, - string underlyingCode, - string underlyingInstrumentType, - string startDate, - string endDate, - string callPut, - double koBarrier, - double kiBarrier, - double couponBarrier, - string koObservationDateStr, - string observationDateStr, - double coupon, - bool couponPayAtMaturity, - bool includeCouponAfterKI, - bool isFixedCoupon, - bool annualizedOptionPayoff, - double participationRate, - double principalRate, - double spotPrice, - double notional, - string volSurfaceName, - double riskFreeRate, - string buySell, - string exerciseDate, - double annualizeFactor, - double strike, - double spreadStrike, - string couponDayCount, - List happenedObservations, - string kiOptionType = "Put", - double dividendRate = 0.0, - bool isMoneynessOptionData = false, - double initialSpotPrice = 0.0, - string observationDates = null, - Dictionary dividends = null, - string knockInOutStatus = "Monitoring", - bool hasNightMarket = false, - bool commodityFuturesPreciseTimeMode = false, - string discountCurveName = null, - double timeToMaturityDays = double.NaN, - bool ignoreSkewMap = false, - string engineName = null, - double riskFreeRateOverride = double.NaN, - double dividendRateOverride = double.NaN) - { - if (volConstructionType == VolConstructionType.Normal || ignoreSkewMap) - { - return ValueAutocall( - marketProxy: marketProxy, - valueDate: valueDate, - underlyingCode: underlyingCode, - underlyingInstrumentType: underlyingInstrumentType, - startDate: startDate, - endDate: endDate, - callPut: callPut, - koBarrier: koBarrier, - kiBarrier: kiBarrier, - couponBarrier: couponBarrier, - koObservationDateStr: koObservationDateStr, - observationDateStr: observationDateStr, - coupon: coupon, - couponPayAtMaturity: couponPayAtMaturity, - includeCouponAfterKI: includeCouponAfterKI, - isFixedCoupon: isFixedCoupon, - annualizedOptionPayoff: annualizedOptionPayoff, - participationRate: participationRate, - principalRate: principalRate, - spotPrice: spotPrice, - notional: notional, - volSurfaceName: volSurfaceName, - riskFreeRate: riskFreeRate, - buySell: buySell, - exerciseDate: exerciseDate, - annualizeFactor: annualizeFactor, - strike: strike, - spreadStrike: spreadStrike, - couponDayCount: couponDayCount, - happenedObservations: happenedObservations, - kiOptionType: kiOptionType, - dividendRate: dividendRate, - isMoneynessOptionData: isMoneynessOptionData, - initialSpotPrice: initialSpotPrice, - dividends: dividends, - knockInOutStatus: knockInOutStatus, - hasNightMarket: hasNightMarket, - commodityFuturesPreciseTimeMode: commodityFuturesPreciseTimeMode, - discountCurveName: discountCurveName, - timeToMaturityDays: timeToMaturityDays, - ignoreSkewMap: ignoreSkewMap, - engineName: engineName, - riskFreeRateOverride: riskFreeRateOverride, - dividendRateOverride: dividendRateOverride); - } - else - { - var tradeId = Guid.NewGuid().ToString(); - SetSkewMapVol( - marketProxy, - valueDate, - underlyingCode, - exerciseDate, - koBarrier, - TradeCalcHelper.IsBuy(buySell), - QdpHelper.IsCall(callPut), - tradeId, - spotPrice); - - return ValueAutocall( - marketProxy: marketProxy, - valueDate: valueDate, - underlyingCode: underlyingCode, - underlyingInstrumentType: underlyingInstrumentType, - startDate: startDate, - endDate: endDate, - callPut: callPut, - koBarrier: koBarrier, - kiBarrier: kiBarrier, - couponBarrier: couponBarrier, - koObservationDateStr: koObservationDateStr, - observationDateStr: observationDateStr, - coupon: coupon, - couponPayAtMaturity: couponPayAtMaturity, - includeCouponAfterKI: includeCouponAfterKI, - isFixedCoupon: isFixedCoupon, - annualizedOptionPayoff: annualizedOptionPayoff, - participationRate: participationRate, - principalRate: principalRate, - spotPrice: spotPrice, - notional: notional, - volSurfaceName: tradeId.GenerateVolSurfaceKey(), - riskFreeRate: riskFreeRate, - buySell: buySell, - exerciseDate: exerciseDate, - annualizeFactor: annualizeFactor, - strike: strike, - spreadStrike: spreadStrike, - couponDayCount: couponDayCount, - happenedObservations: happenedObservations, - kiOptionType: kiOptionType, - dividendRate: dividendRate, - isMoneynessOptionData: isMoneynessOptionData, - initialSpotPrice: initialSpotPrice, - dividends: dividends, - knockInOutStatus: knockInOutStatus, - hasNightMarket: hasNightMarket, - commodityFuturesPreciseTimeMode: commodityFuturesPreciseTimeMode, - discountCurveName: discountCurveName, - timeToMaturityDays: timeToMaturityDays, - ignoreSkewMap: ignoreSkewMap, - engineName: engineName, - riskFreeRateOverride: riskFreeRateOverride, - dividendRateOverride: dividendRateOverride); - } - } - - public static AutocallTrade CreateAutocallTrade( - string tradeId, - string volSurfaceName, - string tradeDate, - string underlyingTicker, - string underlyingInstrumentType, - string startDate, - string endDate, - double strike, - double initialSpotPrice, - bool isMoneynessOption, - double koBarrier, - double kiBarrier, - double couponBarrier, - string koObservationDateStr, - string observationDateStr, - double coupon, - bool couponPayAtMaturity, - bool includeCouponAfterKI, - bool isFixedCoupon, - bool annualizedOptionPayoff, - double spreadStrike, - double participationRate, - double principalRate, - double notional, - string tradeType, - string exerciseDate, - double annualizeFactor, - string couponDayCount, - List happenedObservations, - string kiOptionType = "Put", - double timeToMaturityDays = double.NaN, - double riskFreeRateOverride = double.NaN, - double dividendRateOverride = double.NaN) - { - underlyingInstrumentType = ConvertInstrumentType(underlyingInstrumentType); - var exercise = OptionExercise.European; // hard code - 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; - var observationDates = QdpHelper.ParseObservationDate(observationDateStr); - - var customizedResults = QdpHelper.ParseAutocallCustomizedInfo(koObservationDateStr); - var koObservationDates = customizedResults.Item1; - var customizedKOBarriers = customizedResults.Item2; - var customizedCoupons = customizedResults.Item3; - - //Date[] koObservationDates = QDPHelper.ParseObservationDate(koObservationDateStr); - if (exercise == OptionExercise.American) - { - exerciseDates = CalendarImpl.Get("chn").BizDaysBetweenDatesInclEndDay(optionStartDate, temp_exerciseDate).ToArray(); - if (observationDates == null) - { - observationDates = CalendarImpl.Get("chn").BizDaysBetweenDatesExcluStartDay(optionStartDate, temp_exerciseDate).ToArray(); - } - } - else - { - exerciseDates = new Date[] { temp_exerciseDate }; - if (observationDates == null) - { - observationDates = CalendarImpl.Get("chn").BizDaysBetweenDatesExcluStartDay(optionStartDate, temp_exerciseDate).Union(new[] { temp_exerciseDate }).ToArray(); - } - } - - if (koObservationDates == null) - { - var monthlyDates = new List(); - var oneMonth = new Term("1M"); - var date = oneMonth.Next(optionStartDate); - var beforeExercise = oneMonth.Prev(temp_exerciseDate); - while (date < beforeExercise) - { - monthlyDates.Add(date); - date = oneMonth.Next(date); - } - monthlyDates.Add(temp_exerciseDate); - koObservationDates = monthlyDates.ToArray(); - } - - var optionDayCount = CalculatorHelper.GetTradeDayCount(); - - var pricingTOverride = double.IsNaN(timeToMaturityDays) ? double.NaN : QdpCalendarHelper.CalculateTFromDays(timeToMaturityDays, optionDayCount, optionStartDate.DateTime); - - var autocall = new AutoCall( - startDate: optionStartDate, - maturityDate: underlyingMaturityDate, - koBarrier: koBarrier, - kiBarrier: kiBarrier, - couponBarrier: couponBarrier, - coupon: coupon, - couponPayAtMaturity: couponPayAtMaturity, - includeCouponAfterKI: includeCouponAfterKI, - optionParticipationRate: 1.0, // 在OTC系统增加“期权参与率”字段之前,请保留一直传1.0 - koObsDates: koObservationDates, - kiObsDates: observationDates, - observationDates: null, - notional: notional, - initialSpotPrice: initialSpotPrice, - underlyingType: (InstrumentType)Enum.Parse(typeof(InstrumentType), underlyingInstrumentType), - calendar: CalendarImpl.Get("chn"), - dayCount: optionDayCount.ToDayCountImpl(), - payoffCcy: CurrencyCode.CNY, - settlementCcy: CurrencyCode.CNY, - exerciseDates: exerciseDates, - strike: strike, - spreadStrike: spreadStrike, - fixedCoupon: isFixedCoupon, - annualizedOptionPayoff: annualizedOptionPayoff, - customizedKOBarriers: customizedKOBarriers, - customizedCoupons: customizedCoupons, - isMoneynessOption: isMoneynessOption, - happenedObservations: happenedObservations?.Where(o => o != null).Select(o => new ObservationPayment() - { - StartDate = new Date(o.StartDate), - EndDate = new Date(o.EndDate), - CouponRate = o.CouponRate, - Notional = o.StockEqvNotional, - PaymentAmount = o.PaymentAmount, - PaymentDate = new Date(o.PaymentDate) - }).ToList(), - couponDayCount: couponDayCount.ToDayCountImpl(), - kiOptionType: kiOptionType.ToOptionType(), - pricingToverride: pricingTOverride, - riskFreeRateOverride: riskFreeRateOverride, - dividendRateOverride: dividendRateOverride, - annualizedFactor: annualizeFactor) - { - UnderlyingTickers = new string[] { underlyingTicker } - }; - - if (string.IsNullOrWhiteSpace(tradeId)) - { - tradeId = Guid.NewGuid().ToString(); - } - return new AutocallTrade( - tradeId, - tradeDate.ToDate(), - autocall.StartDate, - autocall.ExerciseDates.Last(), - QdpConverter.ConvertTradeType(tradeType), - autocall.Notional, - 0.0, - autocall) - { - ValuationParameters = new OptionValuationParameters("RiskFreeDiscountCurve", MarketProxy.ConstantZeroCurve, volSurfaceName, autocall.UnderlyingTickers[0]), - ProtectionRate = principalRate, - ParticipationRate = participationRate, - AnnualizedFactor = annualizeFactor, - OriginalNotional = TradeHelper.GetStockEqvNotional(notional * initialSpotPrice, participationRate, annualizeFactor) - }; - } - - private static TradeValueResult ValueAutocall( - PrebuiltQdpMarketProxy marketProxy, - string valueDate, - string underlyingCode, - string underlyingInstrumentType, - string startDate, - string endDate, - string callPut, - double koBarrier, - double kiBarrier, - double couponBarrier, - string koObservationDateStr, - string observationDateStr, - double coupon, - bool couponPayAtMaturity, - bool includeCouponAfterKI, - bool isFixedCoupon, - bool annualizedOptionPayoff, - double participationRate, - double principalRate, - double spotPrice, - double notional, - string volSurfaceName, - double riskFreeRate, - string buySell, - string exerciseDate, - double annualizeFactor, - double strike, - double spreadStrike, - string couponDayCount, - List happenedObservations, - string kiOptionType = "Put", - double dividendRate = 0.0, - bool isMoneynessOptionData = false, - double initialSpotPrice = 0.0, - Dictionary dividends = null, - string knockInOutStatus = "Monitoring", - bool hasNightMarket = false, - bool commodityFuturesPreciseTimeMode = false, - string discountCurveName = null, - double timeToMaturityDays = double.NaN, - bool ignoreSkewMap = false, - string engineName = null, - double riskFreeRateOverride = double.NaN, - double dividendRateOverride = double.NaN, - PricingRequest pricingRequest = QdpPricingRequest.BASIC_GREEKS) - { - if (string.IsNullOrWhiteSpace(volSurfaceName)) - { - volSurfaceName = underlyingCode.GenerateVolSurfaceKey(); - } - - var optionTrade = CreateAutocallTrade( - null, - volSurfaceName, - startDate, - underlyingCode, - underlyingInstrumentType, - startDate, - endDate, - strike, - initialSpotPrice, - isMoneynessOptionData, - koBarrier, - kiBarrier, - couponBarrier, - koObservationDateStr, - observationDateStr, - coupon, - couponPayAtMaturity, - includeCouponAfterKI, - isFixedCoupon, - annualizedOptionPayoff, - spreadStrike, - participationRate, - principalRate, - notional, - buySell, - exerciseDate, - annualizeFactor, - couponDayCount, - happenedObservations, - kiOptionType, - timeToMaturityDays: timeToMaturityDays, - riskFreeRateOverride: riskFreeRateOverride, - dividendRateOverride: dividendRateOverride).CheckMaturityDate(); - - var market = marketProxy.GetQdpMarket(valueDate); - if (market == null) - { - return null; - } - - 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(underlyingCode, valueDate, spotPrice); - - OptionValuationParameters parameters; - string dividendCurveName = null; - if (underlyingInstrumentType == "Stock") - { - //设置DividendCurve - dividendCurveName = Guid.NewGuid().ToString(); - var dividendCurve = CalculatorHelper.CreateConstantRiskFreeCurve(dividendCurveName, dividendRate); - marketProxy.AddYieldCurve(dividendCurveName, valueDate, dividendCurve); - - parameters = new OptionValuationParameters( - discountCurveName, - dividendCurveName, - volSurfaceName, - underlyingCode); - } - else - { - parameters = new OptionValuationParameters( - discountCurveName, - MarketProxy.ConstantZeroCurve, - volSurfaceName, - underlyingCode); - } - - try - { - var option = optionTrade.Instrument as AutoCall; - var factory = OptionEngineFactory.GetEngineFactory("AutoCall"); - var engine = factory.GetEngine(engineName, option.Exercise); - - var results = optionTrade.CalculateRisks(marketProxy.GetQdpMarket(valueDate), pricingRequest, engine, parameters); - - if (useLocalDiscountCurve) - { - marketProxy.RemoveYieldCurve(discountCurveName, valueDate); - } - if (!string.IsNullOrEmpty(dividendCurveName)) - { - marketProxy.RemoveYieldCurve(dividendCurveName, valueDate); - } - - if (results.Succeeded) - { - return new TradeValueResult() - { - UnderlyingCode = underlyingCode, - Pv = results.Pv, - Delta = results.Delta, - Gamma = results.Gamma, - Vega = results.Vega, - CalendarDayTheta = results.Theta, - TradingDayTheta = results.ThetaPnL, - Rho = results.Rho, - DeltaCash = results.DeltaCash, - GammaCash = results.GammaCash, - Vol = results.PricingVol, - DDeltaDVol = results.DDeltaDvol, - DDeltaDt = results.DDeltaDt, - DVegaDVol = results.DVegaDvol, - DVegaDt = results.DVegaDt, - StoppingTime = results.StoppingTime, - RoundedPv = OtcFormatHelper.FormatValue(results.Pv / notional, 2) * notional - }; - } - else - { - return null; - } - } - catch (Exception ex) - { - throw ex; - //return null; - } - } - - #endregion - - #region 雪球期权 - public static TradeValueResult ValueSnowballTrade( - PrebuiltQdpMarketProxy marketProxy, - string valueDate, - string underlyingCode, - string underlyingInstrumentType, - string startDate, - string endDate, - string callPut, - double koBarrier, - double kiBarrier, - string koObservationDateStr, - string observationDateStr, - double coupon, - double participationRate, - double principalRate, - double spotPrice, - double notional, - string volSurfaceName, - double riskFreeRate, - string buySell, - string exerciseDate, - bool isAnnualized, - double annualizeFactor, - double strike, - double spreadStrikeAtKO, - double spreadStrikeAtMaturity, - bool isFixedCoupon, - double kORebate, - double kOBarrierAdjustStep, - bool useOptionPayoffAtKO, - bool useOptionPayoffAtMaturity, - bool annualizedOptionPayoff, - string couponDayCount, - double dividendRate = 0.0, - bool isMoneynessOptionData = false, - double initialSpotPrice = 0.0, - string observationDates = null, - Dictionary dividends = null, - string knockInOutStatus = "Monitoring", - bool hasNightMarket = false, - bool commodityFuturesPreciseTimeMode = false, - string discountCurveName = null, - double timeToMaturityDays = double.NaN, - bool ignoreSkewMap = false, - string engineName = null, - double riskFreeRateOverride = double.NaN, - double dividendRateOverride = double.NaN) - { - underlyingInstrumentType = ConvertInstrumentType(underlyingInstrumentType); - return ValueSnowballTrade( - VolSurfaceInitializerSingleton.VolConstructionType, - marketProxy: marketProxy, - valueDate: valueDate, - underlyingCode: underlyingCode, - underlyingInstrumentType: underlyingInstrumentType, - startDate: startDate, - endDate: endDate, - callPut: callPut, - koBarrier: koBarrier, - kiBarrier: kiBarrier, - koObservationDateStr: koObservationDateStr, - observationDateStr: observationDateStr, - coupon: coupon, - protectionRate: participationRate, - principalRate: principalRate, - spotPrice: spotPrice, - notional: notional, - volSurfaceName: volSurfaceName, - riskFreeRate: riskFreeRate, - buySell: buySell, - exerciseDate: exerciseDate, - annualizeFactor: annualizeFactor, - strike: strike, - spreadStrikeAtKO: spreadStrikeAtKO, - spreadStrikeAtMaturity: spreadStrikeAtMaturity, - isFixedCoupon: isFixedCoupon, - kORebate: kORebate, - kOBarrierAdjustStep: kOBarrierAdjustStep, - useOptionPayoffAtKO: useOptionPayoffAtKO, - useOptionPayoffAtMaturity: useOptionPayoffAtMaturity, - annualizedOptionPayoff: annualizedOptionPayoff, - couponDayCount: couponDayCount, - dividendRate: dividendRate, - isMoneynessOptionData: isMoneynessOptionData, - initialSpotPrice: initialSpotPrice, - observationDates: observationDates, - dividends: dividends, - knockInOutStatus: knockInOutStatus, - hasNightMarket: hasNightMarket, - commodityFuturesPreciseTimeMode: commodityFuturesPreciseTimeMode, - discountCurveName: discountCurveName, - timeToMaturityDays: timeToMaturityDays, - ignoreSkewMap: ignoreSkewMap, - engineName: engineName, - riskFreeRateOverride: riskFreeRateOverride, - dividendRateOverride: dividendRateOverride); - } - - private static TradeValueResult ValueSnowballTrade( - VolConstructionType volConstructionType, - PrebuiltQdpMarketProxy marketProxy, - string valueDate, - string underlyingCode, - string underlyingInstrumentType, - string startDate, - string endDate, - string callPut, - double koBarrier, - double kiBarrier, - string koObservationDateStr, - string observationDateStr, - double coupon, - double protectionRate, - double principalRate, - double spotPrice, - double notional, - string volSurfaceName, - double riskFreeRate, - string buySell, - string exerciseDate, - double annualizeFactor, - double strike, - double spreadStrikeAtKO, - double spreadStrikeAtMaturity, - bool isFixedCoupon, - double kORebate, - double kOBarrierAdjustStep, - bool useOptionPayoffAtKO, - bool useOptionPayoffAtMaturity, - bool annualizedOptionPayoff, - string couponDayCount, - double dividendRate = 0.0, - bool isMoneynessOptionData = false, - double initialSpotPrice = 0.0, - string observationDates = null, - Dictionary dividends = null, - string knockInOutStatus = "Monitoring", - bool hasNightMarket = false, - bool commodityFuturesPreciseTimeMode = false, - string discountCurveName = null, - double timeToMaturityDays = double.NaN, - bool ignoreSkewMap = false, - string engineName = null, - bool useNoKiSnowball = false, - double koStrike = double.NaN, - string koOptionType = "Call", - double riskFreeRateOverride = double.NaN, - double dividendRateOverride = double.NaN) - { - if (volConstructionType == VolConstructionType.Normal || ignoreSkewMap) - { - return ValueSnowball( - marketProxy: marketProxy, - valueDate: valueDate, - underlyingCode: underlyingCode, - underlyingInstrumentType: underlyingInstrumentType, - startDate: startDate, - endDate: endDate, - callPut: callPut, - koBarrier: koBarrier, - kiBarrier: kiBarrier, - koObservationDateStr: koObservationDateStr, - observationDateStr: observationDateStr, - coupon: coupon, - participationRate: protectionRate, - principalRate: principalRate, - spotPrice: spotPrice, - notional: notional, - volSurfaceName: volSurfaceName, - riskFreeRate: riskFreeRate, - buySell: buySell, - exerciseDate: exerciseDate, - annualizeFactor: annualizeFactor, - strike: strike, - spreadStrikeAtKO: spreadStrikeAtKO, - spreadStrikeAtMaturity: spreadStrikeAtMaturity, - isFixedCoupon: isFixedCoupon, - kORebate: kORebate, - kOBarrierAdjustStep: kOBarrierAdjustStep, - useOptionPayoffAtKO: useOptionPayoffAtKO, - useOptionPayoffAtMaturity: useOptionPayoffAtMaturity, - annualizedOptionPayoff: annualizedOptionPayoff, - couponDayCount: couponDayCount, - dividendRate: dividendRate, - isMoneynessOptionData: isMoneynessOptionData, - initialSpotPrice: initialSpotPrice, - dividends: dividends, - knockInOutStatus: knockInOutStatus, - hasNightMarket: hasNightMarket, - commodityFuturesPreciseTimeMode: commodityFuturesPreciseTimeMode, - discountCurveName: discountCurveName, - timeToMaturityDays: timeToMaturityDays, - ignoreSkewMap: ignoreSkewMap, - engineName: engineName, - riskFreeRateOverride: riskFreeRateOverride, - dividendRateOverride: dividendRateOverride, - useNoKiSnowball: useNoKiSnowball, - koStrike: koStrike, - koOptionType: koOptionType); - } - else - { - var tradeId = Guid.NewGuid().ToString(); - SetSkewMapVol( - marketProxy, - valueDate, - underlyingCode, - exerciseDate, - koBarrier, - TradeCalcHelper.IsBuy(buySell), - QdpHelper.IsCall(callPut), - tradeId, - spotPrice); - - return ValueSnowball( - marketProxy: marketProxy, - valueDate: valueDate, - underlyingCode: underlyingCode, - underlyingInstrumentType: underlyingInstrumentType, - startDate: startDate, - endDate: endDate, - callPut: callPut, - koBarrier: koBarrier, - kiBarrier: kiBarrier, - koObservationDateStr: koObservationDateStr, - observationDateStr: observationDateStr, - coupon: coupon, - participationRate: protectionRate, - principalRate: principalRate, - spotPrice: spotPrice, - notional: notional, - volSurfaceName: tradeId.GenerateVolSurfaceKey(), - riskFreeRate: riskFreeRate, - buySell: buySell, - exerciseDate: exerciseDate, - annualizeFactor: annualizeFactor, - strike: strike, - spreadStrikeAtKO: spreadStrikeAtKO, - spreadStrikeAtMaturity: spreadStrikeAtMaturity, - isFixedCoupon: isFixedCoupon, - kORebate: kORebate, - kOBarrierAdjustStep: kOBarrierAdjustStep, - useOptionPayoffAtKO: useOptionPayoffAtKO, - useOptionPayoffAtMaturity: useOptionPayoffAtMaturity, - annualizedOptionPayoff: annualizedOptionPayoff, - couponDayCount: couponDayCount, - dividendRate: dividendRate, - isMoneynessOptionData: isMoneynessOptionData, - initialSpotPrice: initialSpotPrice, - dividends: dividends, - knockInOutStatus: knockInOutStatus, - hasNightMarket: hasNightMarket, - commodityFuturesPreciseTimeMode: commodityFuturesPreciseTimeMode, - discountCurveName: discountCurveName, - timeToMaturityDays: timeToMaturityDays, - ignoreSkewMap: ignoreSkewMap, - engineName: engineName, - riskFreeRateOverride: riskFreeRateOverride, - dividendRateOverride: dividendRateOverride, - useNoKiSnowball: useNoKiSnowball, - koStrike: koStrike, - koOptionType: koOptionType); - } - } - - /// - /// - /// - /// 是否构造年化权利金模式的保本雪球 - /// - public static SnowballTrade CreateSnowballTrade( - string tradeId, - string volSurfaceName, - string tradeDate, - string underlyingTicker, - string underlyingInstrumentType, - string startDate, - string endDate, - double initialSpotPrice, - bool isMoneynessOption, - double koBarrier, - double kiBarrier, - string koObservationDateStr, - string observationDateStr, - double coupon, - double participationRate, - double principalRate, - double notional, - string tradeType, - string exerciseDate, - double annualizeFactor, - string callput, - double strike, - double spreadStrikeAtKO, - double spreadStrikeAtMaturity, - bool isFixedCoupon, - double kORebate, - double kOBarrierAdjustStep, - bool useOptionPayoffAtKO, - bool useOptionPayoffAtMaturity, - bool annualizedOptionPayoff, - string couponDayCount, - double timeToMaturityDays = double.NaN, - double riskFreeRateOverride = double.NaN, - double dividendRateOverride = double.NaN, - bool useNoKiSnowball = false, - double koStrike = double.NaN, - string koOptionType = "Call", - string kiOptionType = "Put") - { - callput = "Put"; //临时方案 - - underlyingInstrumentType = ConvertInstrumentType(underlyingInstrumentType); - var exercise = OptionExercise.European; // hard code - 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; - var observationDates = QdpHelper.ParseObservationDate(observationDateStr); - - var customizedResults = QdpHelper.ParseAutocallCustomizedInfo(koObservationDateStr); - var koObservationDates = customizedResults.Item1; - var customizedKOBarriers = customizedResults.Item2; - var customizedCoupons = customizedResults.Item3; - if (exercise == OptionExercise.American) - { - exerciseDates = CalendarImpl.Get("chn").BizDaysBetweenDatesInclEndDay(optionStartDate, temp_exerciseDate).ToArray(); - if (observationDates == null) - { - observationDates = CalendarImpl.Get("chn").BizDaysBetweenDatesExcluStartDay(optionStartDate, temp_exerciseDate).ToArray(); - } - } - else - { - exerciseDates = new Date[] { temp_exerciseDate }; - if (observationDates == null) - { - observationDates = CalendarImpl.Get("chn").BizDaysBetweenDatesExcluStartDay(optionStartDate, temp_exerciseDate).Union(new[] { temp_exerciseDate }).ToArray(); - } - } - - if (koObservationDates == null) - { - var monthlyDates = new List(); - var oneMonth = new Term("1M"); - var date = oneMonth.Next(optionStartDate); - var beforeExercise = oneMonth.Prev(temp_exerciseDate); - while (date < beforeExercise) - { - monthlyDates.Add(date); - date = oneMonth.Next(date); - } - monthlyDates.Add(temp_exerciseDate); - koObservationDates = monthlyDates.ToArray(); - } - - var optionDayCount = CalculatorHelper.GetTradeDayCount(); - - var pricingTOverride = double.IsNaN(timeToMaturityDays) ? double.NaN : QdpCalendarHelper.CalculateTFromDays(timeToMaturityDays, optionDayCount, optionStartDate.DateTime); - - var snowball = useNoKiSnowball ? - new AnnualizedPremiumSnowball( - startDate: optionStartDate, - maturityDate: underlyingMaturityDate, - koBarrier: koBarrier, - kiBarrier: kiBarrier, - coupon: coupon, - optionParticipationRate: 1.0, // 在OTC系统增加“期权参与率”字段之前,请保留一直传1.0 - koObsDates: koObservationDates, - kiObsDates: observationDates, - observationDates: null, - notional: notional, - initialSpotPrice: initialSpotPrice, - underlyingType: (InstrumentType)Enum.Parse(typeof(InstrumentType), underlyingInstrumentType), - calendar: CalendarImpl.Get("chn"), - dayCount: optionDayCount.ToDayCountImpl(), - payoffCcy: CurrencyCode.CNY, - settlementCcy: CurrencyCode.CNY, - exerciseDates: exerciseDates, - exercise: OptionExercise.European, - isMoneynessOption: isMoneynessOption, - optionType: callput.ToOptionType(), - strike: strike, - spreadStrikeAtKO: spreadStrikeAtKO, - spreadStrikeAtMaturity: spreadStrikeAtMaturity, - fixedCoupon: isFixedCoupon, - kORebate: kORebate, - kOBarrierAdjustStep: kOBarrierAdjustStep, - useOptionPayoffAtKO: useOptionPayoffAtKO, - useOptionPayoffAtMaturity: useOptionPayoffAtMaturity, - annualizedOptionPayoff: annualizedOptionPayoff, - customizedKOBarriers: customizedKOBarriers, - customizedCoupons: customizedCoupons, - pricingToverride: pricingTOverride, - riskFreeRateOverride: riskFreeRateOverride, - dividendRateOverride: dividendRateOverride, - annualizedFactor: annualizeFactor, - koStrike: koStrike, - koOptionType: koOptionType.ToOptionType(), - kiOptionType: kiOptionType.ToOptionType(), - couponDayCount: couponDayCount.ToDayCountImpl()) : - new SimpleSnowball( - startDate: optionStartDate, - maturityDate: underlyingMaturityDate, - koBarrier: koBarrier, - kiBarrier: kiBarrier, - coupon: coupon, - optionParticipationRate: 1.0, // 在OTC系统增加“期权参与率”字段之前,请保留一直传1.0 - koObsDates: koObservationDates, - kiObsDates: observationDates, - observationDates: null, - notional: notional, - initialSpotPrice: initialSpotPrice, - underlyingType: (InstrumentType)Enum.Parse(typeof(InstrumentType), underlyingInstrumentType), - calendar: CalendarImpl.Get("chn"), - dayCount: optionDayCount.ToDayCountImpl(), - payoffCcy: CurrencyCode.CNY, - settlementCcy: CurrencyCode.CNY, - exerciseDates: exerciseDates, - exercise: OptionExercise.European, - isMoneynessOption: isMoneynessOption, - optionType: callput.ToOptionType(), - strike: strike, - spreadStrikeAtKO: spreadStrikeAtKO, - spreadStrikeAtMaturity: spreadStrikeAtMaturity, - fixedCoupon: isFixedCoupon, - kORebate: kORebate, - kOBarrierAdjustStep: kOBarrierAdjustStep, - useOptionPayoffAtKO: useOptionPayoffAtKO, - useOptionPayoffAtMaturity: useOptionPayoffAtMaturity, - annualizedOptionPayoff: annualizedOptionPayoff, - customizedKOBarriers: customizedKOBarriers, - customizedCoupons: customizedCoupons, - pricingToverride: pricingTOverride, - riskFreeRateOverride: riskFreeRateOverride, - dividendRateOverride: dividendRateOverride, - annualizedFactor: annualizeFactor, - koStrike: koStrike, - koOptionType: koOptionType.ToOptionType(), - kiOptionType: kiOptionType.ToOptionType(), - couponDayCount: couponDayCount.ToDayCountImpl()); - - snowball.UnderlyingTickers = new string[] { underlyingTicker }; - - if (string.IsNullOrWhiteSpace(tradeId)) - { - tradeId = Guid.NewGuid().ToString(); - } - return new SnowballTrade( - tradeId, - tradeDate.ToDate(), - snowball.StartDate, - snowball.ExerciseDates.Last(), - QdpConverter.ConvertTradeType(tradeType), - snowball.Notional, - 0.0, - snowball) - { - ValuationParameters = new OptionValuationParameters("RiskFreeDiscountCurve", MarketProxy.ConstantZeroCurve, volSurfaceName, snowball.UnderlyingTickers[0]), - ProtectionRate = principalRate, - ParticipationRate = participationRate, - AnnualizedFactor = annualizeFactor, - OriginalNotional = TradeHelper.GetStockEqvNotional(notional * initialSpotPrice, participationRate, annualizeFactor) - }; - } - - private static TradeValueResult ValueSnowball( - PrebuiltQdpMarketProxy marketProxy, - string valueDate, - string underlyingCode, - string underlyingInstrumentType, - string startDate, - string endDate, - string callPut, - double koBarrier, - double kiBarrier, - string koObservationDateStr, - string observationDateStr, - double coupon, - double participationRate, - double principalRate, - double spotPrice, - double notional, - string volSurfaceName, - double riskFreeRate, - string buySell, - string exerciseDate, - double annualizeFactor, - double strike, - double spreadStrikeAtKO, - double spreadStrikeAtMaturity, - bool isFixedCoupon, - double kORebate, - double kOBarrierAdjustStep, - bool useOptionPayoffAtKO, - bool useOptionPayoffAtMaturity, - bool annualizedOptionPayoff, - string couponDayCount, - double dividendRate = 0.0, - bool isMoneynessOptionData = false, - double initialSpotPrice = 0.0, - Dictionary dividends = null, - string knockInOutStatus = "Monitoring", - bool hasNightMarket = false, - bool commodityFuturesPreciseTimeMode = false, - string discountCurveName = null, - double timeToMaturityDays = double.NaN, - bool ignoreSkewMap = false, - string engineName = null, - double riskFreeRateOverride = double.NaN, - double dividendRateOverride = double.NaN, - bool useNoKiSnowball = false, - double koStrike = double.NaN, - string koOptionType = "Call", - PricingRequest pricingRequest = QdpPricingRequest.BASIC_GREEKS) - { - if (string.IsNullOrWhiteSpace(volSurfaceName)) - { - volSurfaceName = underlyingCode.GenerateVolSurfaceKey(); - } - - var optionTrade = CreateSnowballTrade( - tradeId: null, - volSurfaceName: volSurfaceName, - tradeDate: startDate, - underlyingTicker: underlyingCode, - underlyingInstrumentType: underlyingInstrumentType, - startDate: startDate, - endDate: endDate, - initialSpotPrice: initialSpotPrice, - isMoneynessOption: isMoneynessOptionData, - koBarrier: koBarrier, - kiBarrier: kiBarrier, - koObservationDateStr: koObservationDateStr, - observationDateStr: observationDateStr, - coupon: coupon, - participationRate: participationRate, - principalRate: principalRate, - notional: notional, - tradeType: buySell, - exerciseDate: exerciseDate, - annualizeFactor: annualizeFactor, - callput: callPut, - strike: strike, - spreadStrikeAtKO: spreadStrikeAtKO, - spreadStrikeAtMaturity: spreadStrikeAtMaturity, - isFixedCoupon: isFixedCoupon, - kORebate: kORebate, - kOBarrierAdjustStep: kOBarrierAdjustStep, - useOptionPayoffAtKO: useOptionPayoffAtKO, - useOptionPayoffAtMaturity: useOptionPayoffAtMaturity, - annualizedOptionPayoff: annualizedOptionPayoff, - couponDayCount: couponDayCount, - timeToMaturityDays: timeToMaturityDays, - riskFreeRateOverride: riskFreeRateOverride, - dividendRateOverride: dividendRateOverride, - useNoKiSnowball: useNoKiSnowball, - koStrike: koStrike, - koOptionType: koOptionType).CheckMaturityDate(); - - var market = marketProxy.GetQdpMarket(valueDate); - if (market == null) - { - return null; - } - - 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(underlyingCode, valueDate, spotPrice); - - OptionValuationParameters parameters; - string dividendCurveName = null; - if (underlyingInstrumentType == "Stock") - { - //设置DividendCurve - dividendCurveName = Guid.NewGuid().ToString(); - var dividendCurve = CalculatorHelper.CreateConstantRiskFreeCurve(dividendCurveName, dividendRate); - marketProxy.AddYieldCurve(dividendCurveName, valueDate, dividendCurve); - - parameters = new OptionValuationParameters( - discountCurveName, - dividendCurveName, - volSurfaceName, - underlyingCode); - } - else - { - parameters = new OptionValuationParameters( - discountCurveName, - MarketProxy.ConstantZeroCurve, - volSurfaceName, - underlyingCode); - } - - try - { - var option = optionTrade.Instrument as SimpleSnowball; - var factory = OptionEngineFactory.GetEngineFactory("Snowball"); - var engine = factory.GetEngine(engineName, option.Exercise); - - var results = optionTrade.CalculateRisks(marketProxy.GetQdpMarket(valueDate), pricingRequest, engine, parameters); - - if (useLocalDiscountCurve) - { - marketProxy.RemoveYieldCurve(discountCurveName, valueDate); - } - if (!string.IsNullOrEmpty(dividendCurveName)) - { - marketProxy.RemoveYieldCurve(dividendCurveName, valueDate); - } - - if (results.Succeeded) - { - return new TradeValueResult() - { - UnderlyingCode = underlyingCode, - Pv = results.Pv, - Delta = results.Delta, - Gamma = results.Gamma, - Vega = results.Vega, - CalendarDayTheta = results.Theta, - TradingDayTheta = results.ThetaPnL, - Rho = results.Rho, - DeltaCash = results.DeltaCash, - GammaCash = results.GammaCash, - Vol = results.PricingVol, - DDeltaDVol = results.DDeltaDvol, - DDeltaDt = results.DDeltaDt, - DVegaDVol = results.DVegaDvol, - DVegaDt = results.DVegaDt, - StoppingTime = results.StoppingTime, - RoundedPv = OtcFormatHelper.FormatValue(results.Pv / notional, 2) * notional - }; - } - else - { - return null; - } - } - catch (Exception ex) - { - throw ex; - //return null; - } - } - - #endregion - - #region 区间累积期权 - private static TradeValueResult ValueRangeAccrual( - PrebuiltQdpMarketProxy marketProxy, - string valueDate, - string underlyingCode, - string underlyingInstrumentType, - string startDate, - string endDate, - double participationRate, - double principalRate, - double spotPrice, - double notional, - string volSurfaceName, - double riskFreeRate, - string buySell, - string exerciseDate, - double lowerRange, - double upperRange, - double bonusRate, - string observationDates, - string settlementDate, - double annualizeFactor, - double strike, - bool isAnnualized, - List happenedObservations, - double dividendRate = 0.0, - bool isMoneynessOption = false, - double initialSpotPrice = 0.0, - bool hasNightMarket = false, - bool commodityFuturesPreciseTimeMode = false, - string engineName = null, - string discountCurveName = null, - double timeToMaturityDays = double.NaN, - bool ignoreSkewMap = false, - double riskFreeRateOverride = double.NaN, - double dividendRateOverride = double.NaN, - PricingRequest pricingRequest = QdpPricingRequest.BASIC_GREEKS) - { - try - { - if (string.IsNullOrWhiteSpace(volSurfaceName)) - { - volSurfaceName = underlyingCode.GenerateVolSurfaceKey(); - } - - var optionTrade = CreateRangeAccrualTrade( - null, - volSurfaceName, - valueDate, - underlyingCode, - underlyingInstrumentType, - strike, - startDate, - endDate, - "Call", - "European", - notional, - buySell, - exerciseDate, - lowerRange, - upperRange, - bonusRate, - observationDates, - settlementDate, - participationRate, - principalRate, - isAnnualized, - annualizeFactor, - happenedObservations, - isMoneynessOption, - initialSpotPrice, - null, - fixings: null, - hasNightMarket: hasNightMarket, - commodityFuturesPreciseTimeMode: commodityFuturesPreciseTimeMode, - timeToMaturityDays: timeToMaturityDays, - riskFreeRateOverride: riskFreeRateOverride, - dividendRateOverride: dividendRateOverride); - - var market = marketProxy.GetQdpMarket(valueDate); - if (market == null) - { - return null; - } - - 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(underlyingCode, valueDate, spotPrice); - - OptionValuationParameters parameters = null; - string dividendCurveName = null; - if (underlyingInstrumentType == "Stock") - { - //设置DividendCurve - dividendCurveName = Guid.NewGuid().ToString(); - var dividendCurve = CalculatorHelper.CreateConstantRiskFreeCurve(dividendCurveName, dividendRate); - marketProxy.AddYieldCurve(dividendCurveName, valueDate, dividendCurve); - - parameters = new OptionValuationParameters( - discountCurveName, - dividendCurveName, - volSurfaceName, - underlyingCode); - } - else - { - parameters = new OptionValuationParameters( - discountCurveName, - MarketProxy.ConstantZeroCurve, - volSurfaceName, - underlyingCode); - } - - var option = optionTrade.Instrument as RangeAccrual; - var factory = OptionEngineFactory.GetEngineFactory("RangeAccrual"); - var engine = factory.GetEngine(engineName, option.Exercise); - - var results = optionTrade.CalculateRisks(marketProxy.GetQdpMarket(valueDate), pricingRequest, engine, parameters); - - if (useLocalDiscountCurve) - { - marketProxy.RemoveYieldCurve(discountCurveName, valueDate); - } - - if (!string.IsNullOrEmpty(dividendCurveName)) - { - marketProxy.RemoveYieldCurve(dividendCurveName, valueDate); - } - - if (results.Succeeded) - { - var ret = new TradeValueResult() - { - UnderlyingCode = underlyingCode, - Pv = results.Pv, - Delta = results.Delta, - Gamma = results.Gamma, - Vega = results.Vega, - CalendarDayTheta = results.Theta, - TradingDayTheta = results.ThetaPnL, - Rho = results.Rho, - DeltaCash = results.DeltaCash, - GammaCash = results.GammaCash, - Vol = results.PricingVol, - RoundedPv = OtcFormatHelper.FormatValue(results.Pv / notional, 2) * notional - }; - return ret; - } - else - { - return null; - } - } - catch (Exception ex) - { - LogFactory.GetLogger("期权计算").Error("ValueRangeAccrual:" + underlyingCode, ex); - throw new Exception($"区间累积期权处理失败[标的:{underlyingCode},开始日:{startDate},结束日:{endDate},行权日:{exerciseDate}]", ex); - } - } - - public static RangeAccrualTrade CreateRangeAccrualTrade( - 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 lowerRange, - double upperRange, - double bonusRate, - string observationDateStr, - string settlementDate, - double participationRate, - double principalRate, - bool isAnnualized, - double annualizeFactor, - List happenedObservations, - bool isMoneynessOption = false, - double initialSpotPrice = 0.0, - Dictionary dividends = null, - string fixings = null, - bool hasNightMarket = false, - bool commodityFuturesPreciseTimeMode = false, - double timeToMaturityDays = double.NaN, - double riskFreeRateOverride = double.NaN, - double dividendRateOverride = double.NaN) - { - underlyingInstrumentType = ConvertInstrumentType(underlyingInstrumentType); - var exercise = QdpConverter.ConvertExerciseType(exerciseType); - var optionStartDate = startDate.ToDate(); - var underlyingMaturityDate = string.IsNullOrWhiteSpace(endDate) ? null : endDate.ToDate(); - var temp_exerciseDate = exerciseDate.ToDate(); - - if (temp_exerciseDate < optionStartDate) - { - throw new Exception("到期日期不能小于起始日"); - } - - Date[] exerciseDates = null; - var observationDates = QdpHelper.ParseObservationDate(observationDateStr); - 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 }; - if (observationDates == null) - { - //observationDates = CalendarImpl.Get("chn").BizDaysBetweenDatesInclEndDay(optionStartDate, exerciseDates.Last()).ToArray(); - observationDates = CalendarImpl.Get("chn").BizDaysBetweenDatesExcluStartDay(optionStartDate, exerciseDates.Last()).ToArray(); - } - } - - var optionDayCount = CalculatorHelper.GetTradeDayCount(); - - var pricingTOverride = double.IsNaN(timeToMaturityDays) ? double.NaN : QdpCalendarHelper.CalculateTFromDays(timeToMaturityDays, optionDayCount, optionStartDate.DateTime); - - var fixingValues = QdpHelper.ParseFixingsFromString(fixings); - - var bonusRateSettlementDate = string.IsNullOrWhiteSpace(settlementDate) ? temp_exerciseDate : new Date(DateTime.Parse(settlementDate)); - if (bonusRateSettlementDate < optionStartDate) - { - bonusRateSettlementDate = temp_exerciseDate; - } - - var rangeAccrual = - new RangeAccrual( - optionStartDate, - underlyingMaturityDate, - exercise, - (OptionType)Enum.Parse(typeof(OptionType), optionType), - strike, - new RangeDefinition[] - { - new RangeDefinition(lowerRange, upperRange, bonusRate, bonusRateSettlementDate, observationDates) - }, - (InstrumentType)Enum.Parse(typeof(InstrumentType), underlyingInstrumentType), - CalendarImpl.Get("chn"), - optionDayCount.ToDayCountImpl(), - CurrencyCode.CNY, - CurrencyCode.CNY, - exerciseDates, - observationDates, - fixingValues, - happenedObservations?.Where(o => o != null).Select(o => new ObservationPayment() - { - StartDate = new Date(o.StartDate), - EndDate = new Date(o.EndDate), - CouponRate = o.CouponRate, - Notional = o.StockEqvNotional, - PaymentAmount = o.PaymentAmount, - PaymentDate = new Date(o.PaymentDate) - }).ToList(), - notional, - null, - null, - 0.0, - isMoneynessOption, - initialSpotPrice, - 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 RangeAccrualTrade( - tradeId, - tradeDate.ToDate(), - rangeAccrual.StartDate, - rangeAccrual.ExerciseDates.Last(), - QdpConverter.ConvertTradeType(tradeType), - rangeAccrual.Notional, - 0.0, - rangeAccrual) - { - - ValuationParameters = new OptionValuationParameters("RiskFreeDiscountCurve", MarketProxy.ConstantZeroCurve, volSurfaceName, rangeAccrual.UnderlyingTickers[0]), - ProtectionRate = principalRate, - ParticipationRate = participationRate, - AnnualizedFactor = annualizeFactor, - OriginalNotional = TradeHelper.GetStockEqvNotional(notional * initialSpotPrice, participationRate, annualizeFactor) - }; - } - - #endregion - - #region 气囊结构 - private static TradeValueResult ValueAirbag( - PrebuiltQdpMarketProxy marketProxy, - string valueDate, - string underlyingCode, - string underlyingInstrumentType, - double strike, - double highStrike, - string startDate, - string endDate, - string optionType, - string exerciseType, - double barrier, - double participationRate, - double kiParticipationRate, - double principalRate, - bool isDiscrete, - bool hasPayoffLimit, - double spotPrice, - double notional, - double riskFreeRate, - double dividendRate, - string volSurfaceName, - string tradeType, - string exerciseDate, - bool isAnnualized, - double annualizeFactor, - bool isMoneynessOption = false, - double initialSpotPrice = 0.0, - string observationDateStr = null, - Dictionary dividends = null, - string position = "Buy", - string engineName = null, - string discountCurveName = null, - string barrierStatus = "Monitoring", - bool hasNightMarket = false, - bool commodityFuturesPreciseTimeMode = false, - double timeToMaturityDays = double.NaN, - double riskFreeRateOverride = double.NaN, - double dividendRateOverride = double.NaN, - PricingRequest pricingRequest = QdpPricingRequest.BASIC_GREEKS) - { - try - { - if (string.IsNullOrWhiteSpace(volSurfaceName)) - { - volSurfaceName = underlyingCode.GenerateVolSurfaceKey(); - } - - var optionTrade = CreateAirbagTrade( - null, - volSurfaceName, - valueDate, - underlyingCode, - underlyingInstrumentType, - strike, - highStrike, - startDate, - endDate, - optionType, - exerciseType, - barrier, - participationRate, - kiParticipationRate, - principalRate, - isDiscrete, - hasPayoffLimit, - notional, - position, - exerciseDate, - isAnnualized, - annualizeFactor, - isMoneynessOption, - initialSpotPrice, - observationDateStr, - dividends, - position, - barrierStatus, - hasNightMarket, - commodityFuturesPreciseTimeMode, - timeToMaturityDays, - riskFreeRateOverride, - dividendRateOverride); - - var market = marketProxy.GetQdpMarket(valueDate); - if (market == null) - { - return null; - } - - 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(underlyingCode, valueDate, spotPrice); - - OptionValuationParameters parameters = null; - string dividendCurveName = null; - if (underlyingInstrumentType == "Stock") - { - //设置DividendCurve - dividendCurveName = Guid.NewGuid().ToString(); - var dividendCurve = CalculatorHelper.CreateConstantRiskFreeCurve(dividendCurveName, dividendRate); - marketProxy.AddYieldCurve(dividendCurveName, valueDate, dividendCurve); - - parameters = new OptionValuationParameters( - discountCurveName, - dividendCurveName, - volSurfaceName, - underlyingCode); - } - else - { - parameters = new OptionValuationParameters( - discountCurveName, - MarketProxy.ConstantZeroCurve, - volSurfaceName, - underlyingCode); - } - - var option = optionTrade.Instrument as Airbag; - //var factory = OptionEngineFactory.GetEngineFactory("Airbag"); - //var engine = factory.GetEngine(engineName, option.Exercise); - var engine = new AnalyticalAirbagReplicationEngine(); - - var results = optionTrade.CalculateRisks(marketProxy.GetQdpMarket(valueDate), pricingRequest, engine, parameters); - - if (useLocalDiscountCurve) - { - marketProxy.RemoveYieldCurve(discountCurveName, valueDate); - } - - if (!string.IsNullOrEmpty(dividendCurveName)) - { - marketProxy.RemoveYieldCurve(dividendCurveName, valueDate); - } - - if (results.Succeeded) - { - var ret = new TradeValueResult() - { - UnderlyingCode = underlyingCode, - Pv = results.Pv, - Delta = results.Delta, - Gamma = results.Gamma, - Vega = results.Vega, - CalendarDayTheta = results.Theta, - TradingDayTheta = results.ThetaPnL, - Rho = results.Rho, - DeltaCash = results.DeltaCash, - GammaCash = results.GammaCash, - Vol = results.PricingVol, - RoundedPv = OtcFormatHelper.FormatValue(results.Pv / notional, 2) * notional - }; - return ret; - } - else - { - return null; - } - } - catch (Exception ex) - { - LogFactory.GetLogger("期权计算").Error("ValueAirbag:" + underlyingCode, ex); - throw new Exception($"气囊结构处理失败[标的:{underlyingCode},开始日:{startDate},结束日:{endDate},行权日:{exerciseDate}]", ex); - } - } - - public static AirbagTrade CreateAirbagTrade( - string tradeId, - string volSurfaceName, - string tradeDate, - string underlyingTicker, - string underlyingInstrumentType, - double strike, - double highStrike, - string startDate, - string endDate, - string optionType, - string exerciseType, - double barrier, - double participationRate, - double kiParticipationRate, - double principalRate, - bool isDiscrete, - bool hasPayoffLimit, - double notional, - string tradeType, - string exerciseDate, - bool isAnnualized, - double annualizeFactor, - bool isMoneynessOption = false, - double initialSpotPrice = 0.0, - string observationDateStr = null, - Dictionary dividends = null, - string position = "Buy", - string barrierStatus = "Monitoring", - bool hasNightMarket = false, - bool commodityFuturesPreciseTimeMode = false, - double timeToMaturityDays = double.NaN, - double riskFreeRateOverride = double.NaN, - double dividendRateOverride = double.NaN) - { - underlyingInstrumentType = ConvertInstrumentType(underlyingInstrumentType); - var exercise = QdpConverter.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; - Date[] observationDates = null; - if (exercise == OptionExercise.American) - { - exerciseDates = CalendarImpl.Get("chn").BizDaysBetweenDatesInclEndDay(optionStartDate, temp_exerciseDate).ToArray(); - if (observationDates == null) - { - observationDates = CalendarImpl.Get("chn").BizDaysBetweenDatesExcluStartDay(optionStartDate, temp_exerciseDate).ToArray(); - } - } - else - { - exerciseDates = new Date[] { temp_exerciseDate }; - if (observationDates == null) - { - observationDates = CalendarImpl.Get("chn").BizDaysBetweenDatesExcluStartDay(optionStartDate, temp_exerciseDate).Union(new[] { temp_exerciseDate }).ToArray(); - } - } - - //补丁 - //if(string.IsNullOrEmpty(barrierType)) - //{ - // barrierType = "0"; - //} - var optionDayCount = CalculatorHelper.GetTradeDayCount(); - - var pricingTOverride = double.IsNaN(timeToMaturityDays) ? double.NaN : QdpCalendarHelper.CalculateTFromDays(timeToMaturityDays, optionDayCount, optionStartDate.DateTime); - - var airbag = - new Airbag( - optionStartDate, - underlyingMaturityDate, - exercise, - (OptionType)Enum.Parse(typeof(OptionType), optionType), - strike, - highStrike, - barrier, - participationRate, - kiParticipationRate, - isDiscrete, - hasPayoffLimit, - (InstrumentType)Enum.Parse(typeof(InstrumentType), underlyingInstrumentType), - CalendarImpl.Get("chn"), - optionDayCount.ToDayCountImpl(), - CurrencyCode.CNY, - CurrencyCode.CNY, - exerciseDates, - observationDates, - notional, - null, - null, - 0.0, - isMoneynessOption: isMoneynessOption, - initialSpotPrice: initialSpotPrice, - dividends: dividends, - hasNightMarket: hasNightMarket, - commodityFuturesPreciseTimeMode: commodityFuturesPreciseTimeMode, - pricingToverride: pricingTOverride, //pricingToverride - riskFreeRateOverride: riskFreeRateOverride, - dividendRateOverride: dividendRateOverride, - isAnnualized: isAnnualized, - annualizedFactor: annualizeFactor) - { - UnderlyingTickers = new string[] { underlyingTicker } - }; - - if (string.IsNullOrWhiteSpace(tradeId)) - { - tradeId = Guid.NewGuid().ToString(); - } - return new AirbagTrade( - tradeId, - tradeDate.ToDate(), - airbag.StartDate, - airbag.ExerciseDates.Last(), - QdpConverter.ConvertTradeType(tradeType), - airbag.Notional, - 0.0, - airbag) - { - ValuationParameters = new OptionValuationParameters("RiskFreeDiscountCurve", MarketProxy.ConstantZeroCurve, volSurfaceName, airbag.UnderlyingTickers[0]), - ProtectionRate = principalRate, - ParticipationRate = participationRate, - AnnualizedFactor = annualizeFactor, - OriginalNotional = TradeHelper.GetStockEqvNotional(notional * initialSpotPrice, participationRate, annualizeFactor) - }; - } - #endregion - - #region 收益增强结构 - - private static TradeValueResult ValueUnderlyingEnhance( - PrebuiltQdpMarketProxy marketProxy, - string valueDate, - string underlyingCode, - string underlyingInstrumentType, - double strike, - double annualizedEnhanceRate, - string startDate, - string endDate, - string optionType, - string exerciseType, - double participationRate, - double spotPrice, - double notional, - double riskFreeRate, - double dividendRate, - string volSurfaceName, - string tradeType, - string exerciseDate, - bool isAnnualized, - double annualizeFactor, - bool isMoneynessOption = false, - double initialSpotPrice = 0.0, - string discountCurveName = null, - bool hasNightMarket = false, - bool commodityFuturesPreciseTimeMode = false, - double timeToMaturityDays = double.NaN, - double riskFreeRateOverride = double.NaN, - double dividendRateOverride = double.NaN, - PricingRequest pricingRequest = QdpPricingRequest.BASIC_GREEKS) - { - try - { - if (string.IsNullOrWhiteSpace(volSurfaceName)) - { - volSurfaceName = underlyingCode.GenerateVolSurfaceKey(); - } - - var optionTrade = CreateUnderlyingEnhanceTrade( - null, - volSurfaceName, - valueDate, - underlyingCode, - underlyingInstrumentType, - strike, - startDate, - endDate, - optionType, - exerciseType, - annualizedEnhanceRate, - notional, - tradeType, - exerciseDate, - participationRate, - isAnnualized, - annualizeFactor, - isMoneynessOption, - initialSpotPrice, - null, // dividends - hasNightMarket, - commodityFuturesPreciseTimeMode, - timeToMaturityDays, - riskFreeRateOverride, - dividendRateOverride); - - var market = marketProxy.GetQdpMarket(valueDate); - if (market == null) - { - return null; - } - - 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(underlyingCode, valueDate, spotPrice); - - OptionValuationParameters parameters = null; - string dividendCurveName = null; - if (underlyingInstrumentType == "Stock") - { - //设置DividendCurve - dividendCurveName = Guid.NewGuid().ToString(); - var dividendCurve = CalculatorHelper.CreateConstantRiskFreeCurve(dividendCurveName, dividendRate); - marketProxy.AddYieldCurve(dividendCurveName, valueDate, dividendCurve); - - parameters = new OptionValuationParameters( - discountCurveName, - dividendCurveName, - volSurfaceName, - underlyingCode); - } - else - { - parameters = new OptionValuationParameters( - discountCurveName, - MarketProxy.ConstantZeroCurve, - volSurfaceName, - underlyingCode); - } - - var option = optionTrade.Instrument as UnderlyingPayoffEnhance; - var engine = new AnalyticalUnderlyingPayoffEnhanceEngine(); - - var results = optionTrade.CalculateRisks(marketProxy.GetQdpMarket(valueDate), pricingRequest, engine, parameters); - - if (useLocalDiscountCurve) - { - marketProxy.RemoveYieldCurve(discountCurveName, valueDate); - } - - if (!string.IsNullOrEmpty(dividendCurveName)) - { - marketProxy.RemoveYieldCurve(dividendCurveName, valueDate); - } - - if (results.Succeeded) - { - var ret = new TradeValueResult() - { - UnderlyingCode = underlyingCode, - Pv = results.Pv, - Delta = results.Delta, - Gamma = results.Gamma, - Vega = results.Vega, - CalendarDayTheta = results.Theta, - TradingDayTheta = results.ThetaPnL, - Rho = results.Rho, - DeltaCash = results.DeltaCash, - GammaCash = results.GammaCash, - Vol = results.PricingVol, - RoundedPv = OtcFormatHelper.FormatValue(results.Pv / notional, 2) * notional - }; - return ret; - } - else - { - return null; - } - } - catch (Exception ex) - { - LogFactory.GetLogger("期权计算").Error("ValueUnderlyingEnhance:" + underlyingCode, ex); - throw new Exception($"收益增强结构处理失败[标的:{underlyingCode},开始日:{startDate},结束日:{endDate},行权日:{exerciseDate}]", ex); - } - } - public static UnderlyingPayoffEnhanceTrade CreateUnderlyingEnhanceTrade(string tradeId, - string volSurfaceName, - string tradeDate, - string underlyingTicker, - string underlyingInstrumentType, - double strike, - string startDate, - string endDate, - string optionType, - string exerciseType, - double annualizedEnhanceRate, - double notional, - string tradeType, - string exerciseDate, - double participationRate, - bool isAnnualized, - double annualizeFactor, - bool isMoneynessOption = false, - double initialSpotPrice = 0.0, - Dictionary dividends = null, - bool hasNightMarket = false, - bool commodityFuturesPreciseTimeMode = false, - double timeToMaturityDays = double.NaN, - double riskFreeRateOverride = double.NaN, - double dividendRateOverride = double.NaN) - //string optionDayCount = "Act365") - { - underlyingInstrumentType = ConvertInstrumentType(underlyingInstrumentType); - var exercise = QdpConverter.ConvertExerciseType(exerciseType); - var optionStartDate = startDate.ToDate(); - var underlyingMaturityDate = string.IsNullOrWhiteSpace(endDate) ? null : endDate.ToDate(); - var temp_exerciseDate = exerciseDate.ToDate(); - - if (temp_exerciseDate < optionStartDate) - { - throw new Exception("到期日期不能小于起始日"); - } - - Date[] exerciseDates; - Date[] observationDates; - 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 }; - } - - var optionDayCount = CalculatorHelper.GetTradeDayCount(); - - var pricingTOverride = double.IsNaN(timeToMaturityDays) ? double.NaN : QdpCalendarHelper.CalculateTFromDays(timeToMaturityDays, optionDayCount, optionStartDate.DateTime); - - var underlyingEnhance = - new UnderlyingPayoffEnhance( - optionStartDate, - underlyingMaturityDate, - exercise, - (OptionType)Enum.Parse(typeof(OptionType), optionType), - strike, - (InstrumentType)Enum.Parse(typeof(InstrumentType), underlyingInstrumentType), - CalendarImpl.Get("chn"), - optionDayCount.ToDayCountImpl(), - new Act365(), - CurrencyCode.CNY, - CurrencyCode.CNY, - exerciseDates, - observationDates, - annualizedEnhanceRate, - 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 UnderlyingPayoffEnhanceTrade( - tradeId, - tradeDate.ToDate(), - underlyingEnhance.StartDate, - underlyingEnhance.ExerciseDates.Last(), - QdpConverter.ConvertTradeType(tradeType), - underlyingEnhance.Notional, - 0.0, - underlyingEnhance) - { - - ValuationParameters = new OptionValuationParameters("RiskFreeDiscountCurve", MarketProxy.ConstantZeroCurve, volSurfaceName, underlyingEnhance.UnderlyingTickers[0]) - }; - } - - #endregion - - #region 累计期权 - private static TradeValueResult ValueAccumulatorOptionTrade( - PrebuiltQdpMarketProxy marketProxy, - string valueDate, - string startDate, - string endDate, - string exerciseDate, - string optionType, - string underlyingCode, - string underlyingInstrumentType, - double strike, - string observationDates, - double barrier, - double coupon, - double callMultiplier, - double putMultiplier, - bool earlyTerminate, - bool payCoupon, - double participationRate, - double spotPrice, - double notional, - double riskFreeRate, - double dividendRate, - string volSurfaceName, - string buySell, - bool isAnnualized, - double annualizedFactor, - bool isMoneynessOption, - double initialSpotPrice, - string discountCurveName, - bool hasNightMarket, - bool commodityFuturesPreciseTimeMode, - double timeToMaturityDays, - double riskFreeRateOverride, - double dividendRateOverride, - PricingRequest pricingRequest) - { - try - { - if (string.IsNullOrWhiteSpace(volSurfaceName)) - { - volSurfaceName = underlyingCode.GenerateVolSurfaceKey(); - } - - var optionTrade = CreateAccumulatorOptionTrade( - null, - volSurfaceName, - valueDate, - underlyingCode, - underlyingInstrumentType, - startDate, - endDate, - exerciseDate, - optionType, - strike, - observationDates, - barrier, - coupon, - callMultiplier, - putMultiplier, - earlyTerminate, - payCoupon, - participationRate, - spotPrice, - buySell, - notional, - isAnnualized, - annualizedFactor, - isMoneynessOption, - initialSpotPrice, - hasNightMarket: hasNightMarket, - commodityFuturesPreciseTimeMode: commodityFuturesPreciseTimeMode, - timeToMaturityDays: timeToMaturityDays, - riskFreeRateOverride: riskFreeRateOverride, - dividendRateOverride: dividendRateOverride); - - var market = marketProxy.GetQdpMarket(valueDate); - if (market == null) - { - return null; - } - - 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(underlyingCode, valueDate, spotPrice); - - OptionValuationParameters parameters = null; - string dividendCurveName = null; - if (underlyingInstrumentType == "Stock") - { - //设置DividendCurve - dividendCurveName = Guid.NewGuid().ToString(); - var dividendCurve = CalculatorHelper.CreateConstantRiskFreeCurve(dividendCurveName, dividendRate); - marketProxy.AddYieldCurve(dividendCurveName, valueDate, dividendCurve); - - parameters = new OptionValuationParameters( - discountCurveName, - dividendCurveName, - volSurfaceName, - underlyingCode); - } - else - { - parameters = new OptionValuationParameters( - discountCurveName, - MarketProxy.ConstantZeroCurve, - volSurfaceName, - underlyingCode); - } - - IEngine engine; - if (earlyTerminate) - { - engine = new QuadAccumulatorOptionEngine(); - } - else - { - engine = new AnalyticalAccumulatorOptionEngine(); - } - - var results = optionTrade.CalculateRisks(marketProxy.GetQdpMarket(valueDate), pricingRequest, engine, parameters); - - if (useLocalDiscountCurve) - { - marketProxy.RemoveYieldCurve(discountCurveName, valueDate); - } - - if (!string.IsNullOrEmpty(dividendCurveName)) - { - marketProxy.RemoveYieldCurve(dividendCurveName, valueDate); - } - - if (results.Succeeded) - { - var ret = new TradeValueResult() - { - UnderlyingCode = underlyingCode, - Pv = results.Pv, - Delta = results.Delta, - Gamma = results.Gamma, - Vega = results.Vega, - CalendarDayTheta = results.Theta, - TradingDayTheta = results.ThetaPnL, - Rho = results.Rho, - DeltaCash = results.DeltaCash, - GammaCash = results.GammaCash, - Vol = results.PricingVol, - RoundedPv = OtcFormatHelper.FormatValue(results.Pv / notional, 2) * notional - }; - return ret; - } - else - { - return null; - } - } - catch (Exception ex) - { - LogFactory.GetLogger("期权计算").Error("ValueAccumulatorOptionTrade:" + underlyingCode, ex); - throw new Exception($"累计期权处理失败[标的:{underlyingCode},开始日:{startDate},结束日:{endDate},行权日:{exerciseDate}]", ex); - } - } - - private static AccumulatorOptionTrade CreateAccumulatorOptionTrade( - string tradeId, - string volSurfaceName, - string valueDate, - string underlyingCode, - string underlyingInstrumentType, - string startDate, - string endDate, - string exerciseDate, - string optionType, - double strike, - string observationDateStr, - double barrier, - double coupon, - double callMultiplier, - double putMultiplier, - bool earlyTerminate, - bool payCoupon, - double participationRate, - double spotPrice, - string buySell, - double notional, - bool isAnnualized, - double annualizedFactor, - bool isMoneynessOption, - double initialSpotPrice, - bool hasNightMarket, - bool commodityFuturesPreciseTimeMode, - double timeToMaturityDays, - double riskFreeRateOverride, - double dividendRateOverride) - { - underlyingInstrumentType = ConvertInstrumentType(underlyingInstrumentType); - - var exercise = OptionExercise.European; - 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; - Date[] observationDates = null; - - if (exercise == OptionExercise.American) - { - exerciseDates = CalendarImpl.Get("chn").BizDaysBetweenDatesInclEndDay(optionStartDate, temp_exerciseDate).ToArray(); - if (observationDates == null) - { - observationDates = CalendarImpl.Get("chn").BizDaysBetweenDatesExcluStartDay(optionStartDate, temp_exerciseDate).ToArray(); - } - } - else - { - exerciseDates = new Date[] { temp_exerciseDate }; - if (observationDates == null) - { - observationDates = CalendarImpl.Get("chn").BizDaysBetweenDatesExcluStartDay(optionStartDate, temp_exerciseDate).Union(new[] { temp_exerciseDate }).ToArray(); - } - } - - var customizedResults = QdpHelper.ParseAutocallCustomizedInfo(observationDateStr); - var koObservationDates = customizedResults.Item1; - var customizedKOBarriers = customizedResults.Item2; - var customizedCoupons = customizedResults.Item3; - - if (koObservationDates == null || koObservationDates.Length == 0) - { - koObservationDates = observationDates; - } - - if (customizedKOBarriers == null || customizedKOBarriers.Length == 0) - { - customizedKOBarriers = Enumerable.Repeat(barrier, koObservationDates.Length).ToArray(); - } - - if (customizedCoupons == null || customizedCoupons.Length == 0) - { - customizedCoupons = Enumerable.Repeat(coupon, koObservationDates.Length).ToArray(); - } - - var optionDayCount = CalculatorHelper.GetTradeDayCount(); - - var pricingTOverride = double.IsNaN(timeToMaturityDays) ? double.NaN : QdpCalendarHelper.CalculateTFromDays(timeToMaturityDays, optionDayCount, optionStartDate.DateTime); - - var accumulatorOption = - new AccumulatorOption( - startDate: optionStartDate, - maturityDate: underlyingMaturityDate, - optionType: (OptionType)Enum.Parse(typeof(OptionType), optionType), - strike: strike, - barriers: customizedKOBarriers, - callMultiplier: callMultiplier, - putMultiplier: putMultiplier, - earlyTerminate: earlyTerminate, - underlyingInstrumentType: (InstrumentType)Enum.Parse(typeof(InstrumentType), underlyingInstrumentType), - calendar: CalendarImpl.Get("chn"), - dayCount: optionDayCount.ToDayCountImpl(), - payoffCcy: CurrencyCode.CNY, - settlementCcy: CurrencyCode.CNY, - exerciseDates: exerciseDates, - observationDates: koObservationDates, - //coupons: customizedCoupons, - payCoupon: payCoupon, - notional: notional, - settlementGap: null, - optionPremiumPaymentDate: null, - optionPremium: 0.0, - isMoneynessOption: isMoneynessOption, - initialSpotPrice: initialSpotPrice, - dividends: null, - pricingToverride: pricingTOverride, - hasNightMarket: hasNightMarket, - commodityFuturesPreciseTimeMode: commodityFuturesPreciseTimeMode, - riskFreeRateOverride: riskFreeRateOverride, - dividendRateOverride: dividendRateOverride, - isAnnualized: isAnnualized, - annualizedFactor: annualizedFactor) - { - UnderlyingTickers = new string[] { underlyingCode } - }; - - if (string.IsNullOrWhiteSpace(tradeId)) - { - tradeId = Guid.NewGuid().ToString(); - } - return new AccumulatorOptionTrade( - tradeId, - valueDate.ToDate(), - accumulatorOption.StartDate, - accumulatorOption.ExerciseDates.Last(), - QdpConverter.ConvertTradeType(buySell), - accumulatorOption.Notional, - 0.0, - accumulatorOption) - { - ValuationParameters = new OptionValuationParameters("RiskFreeDiscountCurve", MarketProxy.ConstantZeroCurve, volSurfaceName, accumulatorOption.UnderlyingTickers[0]), - ParticipationRate = participationRate, - AnnualizedFactor = annualizedFactor, - OriginalNotional = TradeHelper.GetStockEqvNotional(notional * initialSpotPrice, participationRate, annualizedFactor) - }; - } - #endregion - - #region 现金流交易 - private static TradeValueResult ValueCashFlowTrade( - PrebuiltQdpMarketProxy marketProxy, - string valueDate, - string startDate, - string endDate, - string underlyingCode, - double notional, - CashFlowRateTypeEnum rateType, - string buySell, - string volSurfaceName, - double profitRate, - double riskFreeRate, - string discountCurveName, - PricingRequest pricingRequest) - { - try - { - if (string.IsNullOrWhiteSpace(volSurfaceName)) - { - volSurfaceName = underlyingCode.GenerateVolSurfaceKey(); - } - - var optionTrade = CreateCashFlowTrade( - null, - valueDate, - startDate, - endDate, - notional, - rateType, - buySell, - profitRate); - - var market = marketProxy.GetQdpMarket(valueDate); - if (market == null) - { - return null; - } - - var useLocalDiscountCurve = string.IsNullOrWhiteSpace(discountCurveName); - - //设置DiscountCurve - if (useLocalDiscountCurve) - { - discountCurveName = Guid.NewGuid().ToString(); - var discountCurve = CalculatorHelper.CreateConstantRiskFreeCurve(discountCurveName, riskFreeRate); - marketProxy.AddYieldCurve(discountCurveName, valueDate, discountCurve); - } - - var parameters = new SimpleCfValuationParameters(discountCurveName, discountCurveName, discountCurveName); - - IEngine engine = new DepositEngine(); - - var results = optionTrade.CalculateRisks(marketProxy.GetQdpMarket(valueDate), pricingRequest, engine, parameters); - - if (useLocalDiscountCurve) - { - marketProxy.RemoveYieldCurve(discountCurveName, valueDate); - } - - if (results.Succeeded) - { - var ret = new TradeValueResult() - { - UnderlyingCode = underlyingCode, - Pv = results.Pv, - Delta = results.Delta, - Gamma = results.Gamma, - Vega = results.Vega, - CalendarDayTheta = results.Theta, - TradingDayTheta = results.ThetaPnL, - Rho = results.Rho, - DeltaCash = results.DeltaCash, - GammaCash = results.GammaCash, - Vol = results.PricingVol, - RoundedPv = OtcFormatHelper.FormatValue(results.Pv / notional, 2) * notional - }; - return ret; - } - else - { - return null; - } - } - catch (Exception ex) - { - LogFactory.GetLogger("期权计算").Error("ValueCashFlowTrade:" + underlyingCode, ex); - throw new Exception($"现金流交易处理失败[标的:{underlyingCode},开始日:{startDate},结束日:{endDate}]", ex); - } - } - - private static DepositTrade CreateCashFlowTrade( - string tradeId, - string valueDate, - string startDate, - string endDate, - double notional, - CashFlowRateTypeEnum rateType, - string buySell, - double profitRate) - { - var optionStartDate = startDate.ToDate(); - var underlyingMaturityDate = string.IsNullOrWhiteSpace(endDate) ? null : endDate.ToDate(); - var optionDayCount = CalculatorHelper.GetTradeDayCount(); - var deposit = new Deposit( - startDate: optionStartDate, - maturityDate: underlyingMaturityDate, - depositRate: profitRate, - dayCount: optionDayCount.ToDayCountImpl(), - calendar: CalendarImpl.Get("chn"), - bda: BusinessDayConvention.None, - currency: CurrencyCode.CNY, - notional: notional, - annualizedRate: rateType == CashFlowRateTypeEnum.年化利率, - payCouponOnly: true - ); - return new DepositTrade( - tradeId: tradeId, - tradeDate: valueDate.ToDate(), - startDate: startDate.ToDate(), - maturityDate: underlyingMaturityDate, - tradeType: QdpConverter.ConvertTradeType(buySell), - notional: notional, - price: 0.0, - instrument: deposit); - } - #endregion - - /// - /// 获取根据rule的补充数据 - /// - public static void OptionQuote(ref TradeValueResult valueResult, List quoteRules, double notional, ref QuotationResult qr) - { - foreach (var rule in quoteRules) - { - OptionQuote(ref valueResult, rule, notional, ref qr); - } - } - - /// - /// 根据规则 调整报价数据 - /// - public static double OptionQuote(ref TradeValueResult valueResult, underlying_parameter quoteRule, double notional, ref QuotationResult qr) - { - var result = double.NaN; - if (valueResult != null && quoteRule != null) - { - result = valueResult.Pv + - (quoteRule.Delta ?? 0.0) * (double.IsNaN(valueResult.Delta) ? 0.0 : valueResult.Delta) + - (quoteRule.Gamma ?? 0.0) * (double.IsNaN(valueResult.Gamma) ? 0.0 : valueResult.Gamma) + - (quoteRule.Vega ?? 0.0) * (double.IsNaN(valueResult.Vega) ? 0.0 : valueResult.Vega) + - (quoteRule.Other ?? 0.0); - } - else if (valueResult != null && quoteRule == null) - { - result = valueResult.Pv; - } - - var roundResult = notional == 0 ? OtcFormatHelper.FormatValue(result, 2) : (OtcFormatHelper.FormatValue(result / notional, 2) * notional); - - //valueResult.TradePrice = result; - //设置 报价结果 - switch (quoteRule.Type) - { - case underlying_parameter.CallAsk: - qr.CallAsk = Math.Abs(result); - valueResult.TradePriceAsk = Math.Abs(result); - valueResult.RoundedTradePriceAsk = Math.Abs(roundResult); - break; - case underlying_parameter.CallBid: - qr.CallBid = Math.Abs(result); - valueResult.TradePriceBid = Math.Abs(result); - valueResult.RoundedTradePriceBid = Math.Abs(roundResult); - break; - case underlying_parameter.PutAsk: - qr.PutAsk = Math.Abs(result); - valueResult.TradePriceAsk = Math.Abs(result); - valueResult.RoundedTradePriceAsk = Math.Abs(roundResult); - break; - case underlying_parameter.PutBid: - qr.PutBid = Math.Abs(result); - valueResult.TradePriceBid = Math.Abs(result); - valueResult.RoundedTradePriceBid = Math.Abs(roundResult); - break; - } - - valueResult.Pv = valueResult.Pv; - valueResult.RoundedPv = valueResult.RoundedPv; - - return result; - } - - /// - /// 获取Qdp数据 - /// - /// - /// - /// - /// - /// - /// 是否使用TradeVol模式计算 - /// - /// - /// - /// 是否使用用户自定义的波动率 - /// 根据申万的要求:需要支持计算时在实际距离到期日天数的基础上,另外加减天数进行调整 - /// 用户可以直接输入timeToMaturityDays来指定距离到期日的天数,指定该参数时,maturityShift和指定到期日都是无效的 - /// - public static TradeValueResult GetOptionValueResult( - string userId, - underlying_manager underlying, - trade trade, - double[] spotPrices, - string fixing = null, - bool useTradeVolMode = false, - bool commodityFuturesPreciseTimeMode = false, - double[] correlations = null, - string discountCurveName = null, - int maturityShift = 0, - double timeToMaturityDays = double.NaN, - string engineName = null, - PricingRequest pricingRequest = QdpPricingRequest.BASIC_GREEKS, - string[] volSurfaceNames = null) - { - if (spotPrices is null || !spotPrices.Any()) - { - throw new ArgumentException("缺少spotPrices", nameof(spotPrices)); - } - - var valueDate = underlying.QuotationDate.Value.ToString("yyyy-MM-dd"); - - if (trade.TTMDays != null && timeToMaturityDays.Equals(double.NaN)) - { - timeToMaturityDays = trade.TTMDays.Value; - } - - var marketProxy = QdpMarketManager.Instance.GetPrebuiltMarketProxy(userId); - - if (volSurfaceNames == null || !volSurfaceNames.Any()) - { - volSurfaceNames = GenerateVolSurfaceName(VolSurfaceInitializerSingleton.VolConstructionType, useTradeVolMode, underlying, trade, null); - } - - var variety = VarietyBLL.GetAllvarietyModel().FirstOrDefault(v => v.id == underlying.UnderlyingTypeId); - - TradeValueResult result = null; - - if (trade.TradeType == "结构化交易") - { - throw new Exception("不支持结构化交易"); - } - else if (trade.TradeType == "彩虹期权") - { - throw new Exception("不支持彩虹期权"); - } - - //股票默认到期日为行权日 - if (underlying.IsStock() || underlying.IsCommoditySpot()) - { - trade.MaturityDate = trade.ExerciseDate ?? DateTime.Today.AddYears(3); - } - else if (trade.MaturityDate == null) - { - trade.MaturityDate = underlying.MaturityDate ?? trade.ExerciseDate ?? DateTime.Today.AddYears(1); - } - - var dayCount = CalculatorHelper.GetTradeDayCount(); - - //endDate必须有值否则QDP会报错 - string endDate = null; - if (trade.MaturityDate != null) - { - endDate = QdpCalendarHelper.BizDayShift(trade.MaturityDate.Value).ToString("yyyy-MM-dd"); - if (maturityShift != 0) - { - endDate = QdpCalendarHelper.ShiftDate(endDate, dayCount, maturityShift); - } - } - - string exerciseDate = null; - if (trade.ExerciseDate != null) - { - exerciseDate = QdpCalendarHelper.BizDayShift(trade.ExerciseDate.Value).ToString("yyyy-MM-dd"); - if (maturityShift != 0) - { - exerciseDate = QdpCalendarHelper.ShiftDate(exerciseDate, dayCount, maturityShift); - } - } - - var tradeNotional = trade.Notional; - - tradeBLL.SetFieldsByTradeType(trade); - - #region 根据不同期权类型调用不同函数计算 - - var isForwardTrade = trade.Comments?.Trim() == "YQ"; - var riskFreeRate = isForwardTrade ? 0 : (trade.NoRiskRate ?? 0); - - switch (trade.TradeType) - { - case null: - case "": - case "香草期权": - result = ValueVanillaOptionTrade( - marketProxy, - valueDate, - underlying.UnderlyingCode, - trade.UnderlyingInstrumentType, - trade.Strike ?? 0, - trade.StartDate.Value.ToString("yyyy-MM-dd"), - endDate, - trade.CallPut, //put call - trade.ExerciseMode, - spotPrices[0], - tradeNotional, //数量 - volSurfaceNames[0], - riskFreeRate, - null, - trade.BuySell, - exerciseDate, - trade.ParticipationRate ?? 1.0, - trade.PrincipalRate ?? 0.0, - trade.IsAnnualized, - trade.AnnualizeFactor ?? 1.0, - trade.DividendRate ?? 0, - trade.IsMoneynessOptionData, - trade.SpotPrice ?? 0, - hasNightMarket: variety != null && variety.HasNightMarket, - commodityFuturesPreciseTimeMode: commodityFuturesPreciseTimeMode, - discountCurveName: discountCurveName, - timeToMaturityDays: (!double.IsNaN(timeToMaturityDays) && timeToMaturityDays > 0) ? timeToMaturityDays : double.NaN, - ignoreSkewMap: useTradeVolMode, - isForwardTrade: isForwardTrade, - riskFreeRateOverride: trade.NoRiskRate ?? double.NaN, - dividendRateOverride: trade.DividendRate ?? double.NaN, - pricingRequest: pricingRequest); - break; - case "彩虹期权": - result = ValueRainbowOptionTrade(marketProxy, - valueDate, - trade.UnderlyingInstrumentType, - trade.trade_rainbow_option.UnderlyingCodes, - volSurfaceNames, - trade.trade_rainbow_option.Strikes, - trade.StartDate.Value.ToString("yyyy-MM-dd"), - endDate, - trade.CallPut, //put call - trade.ExerciseMode,// "European", - trade.trade_rainbow_option.RainbowType, - trade.trade_rainbow_option.CashAmount ?? 0, - spotPrices, - tradeNotional, //数量 - trade.NoRiskRate ?? 0, - trade.trade_rainbow_option.CorRelation ?? 0, - trade.BuySell, - exerciseDate, - trade.ParticipationRate ?? 1.0, - trade.PrincipalRate ?? 0.0, - trade.IsAnnualized, - trade.AnnualizeFactor ?? 1.0, - trade.DividendRate ?? 0, - hasNightMarket: variety != null && variety.HasNightMarket, - commodityFuturesPreciseTimeMode: commodityFuturesPreciseTimeMode, - discountCurveName: discountCurveName, - ignoreSkewMap: useTradeVolMode, - engineName: engineName, - riskFreeRateOverride: trade.NoRiskRate ?? double.NaN, - dividendRateOverride: trade.DividendRate ?? double.NaN, - pricingRequest: pricingRequest); - break; - - case "亚式期权": - var averagingPeriodStartDate = trade.trade_asian_option.AveragingPeriodStartDate.HasValue - ? trade.trade_asian_option.AveragingPeriodStartDate.Value.ToString("yyyy-MM-dd") - : trade.TradeDate.Value.ToString("yyyy-MM-dd"); - result = ValueAsianOptionTrade( - marketProxy, - valueDate, - underlying.UnderlyingCode, - trade.UnderlyingInstrumentType, - trade.Strike ?? 0, - trade.StartDate.Value.ToString("yyyy-MM-dd"), - endDate, - trade.CallPut, //put call - trade.ExerciseMode,//"European", - trade.trade_asian_option.PayoffType, - trade.trade_asian_option.StrikeType, - spotPrices[0], - tradeNotional, //数量 - volSurfaceNames[0], - trade.NoRiskRate ?? 0, - trade.BuySell, - exerciseDate, - trade.IsAnnualized, - trade.AnnualizeFactor ?? 1.0, - trade.DividendRate ?? 0, - trade.IsMoneynessOptionData, - trade.SpotPrice ?? 0, - trade.ParticipationRate ?? 1.0, - trade.PrincipalRate ?? 0.0, - trade.trade_asian_option.StrikeGearingFactor ?? 1.0, - null, - fixing, - averagingPeriodStartDate, - trade.trade_asian_option.ObservationDates, - hasNightMarket: variety != null && variety.HasNightMarket, - commodityFuturesPreciseTimeMode: commodityFuturesPreciseTimeMode, - discountCurveName: discountCurveName, - ignoreSkewMap: useTradeVolMode, - engineName: engineName, - riskFreeRateOverride: trade.NoRiskRate ?? double.NaN, - dividendRateOverride: trade.DividendRate ?? double.NaN, - pricingRequest: pricingRequest); - break; - case "障碍期权": - result = ValueBarrierOptionTrade( - marketProxy, - valueDate, - underlying.UnderlyingCode, - trade.UnderlyingInstrumentType, - trade.Strike ?? 0, - trade.StartDate.Value.ToString("yyyy-MM-dd"), - endDate, - trade.CallPut, //put call - trade.ExerciseMode,// "European", - trade.trade_barrier_option.BarrierTypeEn, - trade.trade_barrier_option.BarrierPrice ?? 0, - trade.trade_barrier_option.UpperBarrierPrice ?? 0, - trade.trade_barrier_option.IsDiscrete, - spotPrices[0], - trade.IsUsePremiumRate.HasValue && trade.IsUsePremiumRate.Value ? ((trade.trade_barrier_option.RebateRate ?? 0) * (trade.SpotPrice ?? 0)) : (trade.trade_barrier_option.Rebate ?? 0), - tradeNotional, //数量 - volSurfaceNames[0], - trade.NoRiskRate ?? 0, - trade.BuySell, - exerciseDate, - trade.trade_barrier_option.RebateType, - trade.trade_barrier_option.RebateAnnualizedAtKO, - trade.trade_barrier_option.RebateDayCount, - trade.ParticipationRate ?? 1.0, - trade.PrincipalRate ?? 0.0, - trade.IsAnnualized, - trade.AnnualizeFactor ?? 1.0, - trade.DividendRate ?? 0, - trade.IsMoneynessOptionData, - trade.SpotPrice ?? 0, - trade.trade_barrier_option.ObservationDates, - null, //dividends - trade.BuySell, - trade.trade_barrier_option.BarrierShift ?? 0.0, - trade.trade_barrier_option.KnockInOutStatus, - hasNightMarket: variety != null && variety.HasNightMarket, - commodityFuturesPreciseTimeMode: commodityFuturesPreciseTimeMode, - discountCurveName: discountCurveName, - ignoreSkewMap: useTradeVolMode, - engineName: engineName, - riskFreeRateOverride: trade.NoRiskRate ?? double.NaN, - dividendRateOverride: trade.DividendRate ?? double.NaN, - pricingRequest: pricingRequest); - break; - case "二元期权": - result = ValueBinaryOptionTrade( - marketProxy, - valueDate, - underlying.UnderlyingCode, - trade.UnderlyingInstrumentType, - trade.Strike ?? 0, - trade.StartDate.Value.ToString("yyyy-MM-dd"), - endDate, - trade.CallPut, //put call - trade.ExerciseMode,// "European", - trade.trade_binary_option.PayoffType, - trade.IsUsePremiumRate.HasValue && trade.IsUsePremiumRate.Value ? ((trade.trade_binary_option.CashOrNothingAmountRate ?? 0) * (trade.SpotPrice ?? 0)) : (trade.trade_binary_option.CashOrNothingAmount ?? 0), - spotPrices[0], - tradeNotional, //数量 - volSurfaceNames[0], - trade.NoRiskRate ?? 0, - trade.BuySell, - exerciseDate, - trade.ParticipationRate ?? 1.0, - trade.PrincipalRate ?? 0.0, - trade.IsAnnualized, - trade.AnnualizeFactor ?? 1.0, - trade.trade_binary_option.UpperBarrier ?? double.NaN, - trade.IsUsePremiumRate.HasValue && trade.IsUsePremiumRate.Value ? - ((trade.trade_binary_option.CashOrNothingAmountHighRate ?? 0) * (trade.SpotPrice ?? 0)) : - (trade.trade_binary_option.CashOrNothingAmountHigh ?? double.NaN), - trade.trade_binary_option.IsDiscreteMonitored, - trade.DividendRate ?? 0, - trade.IsMoneynessOptionData, - trade.SpotPrice ?? 0, - null, - trade.trade_binary_option.RebateType, - valuedateBLL.BinaryReplicationStrategy, - trade.trade_binary_option.Offset ?? (trade.Strike ?? 0) * 0.01, - hasNightMarket: variety != null && variety.HasNightMarket, - commodityFuturesPreciseTimeMode: commodityFuturesPreciseTimeMode, - discountCurveName: discountCurveName, - ignoreSkewMap: useTradeVolMode, - engineName: engineName, - riskFreeRateOverride: trade.NoRiskRate ?? double.NaN, - dividendRateOverride: trade.DividendRate ?? double.NaN, - pricingRequest: pricingRequest); - break; - case "价差期权": - var payoff = new SpreadOptionPayoff(trade.trade_spread_option.Payoff); - result = ValueSpreadOption( - marketProxy, - valueDate, - trade.UnderlyingInstrumentType, - trade.trade_spread_option.UnderlyingAssetCodes(), - payoff.Weights, - payoff.SpreadType, - trade.trade_spread_option.UnderlyingAssetCodes().Select(x => useTradeVolMode ? trade.GenerateVolSurfaceName(x) : x.GenerateVolSurfaceKey()).ToArray(), - trade.Strike ?? 0.0, - trade.StartDate.Value.ToString("yyyy-MM-dd"), - endDate, - trade.CallPut, - trade.ExerciseMode, - spotPrices, - tradeNotional, - trade.NoRiskRate ?? 0.0, - correlations, - trade.BuySell, - exerciseDate, - trade.ParticipationRate ?? 1.0, - trade.IsAnnualized, - trade.AnnualizeFactor ?? 1.0, - hasNightMarket: variety != null && variety.HasNightMarket, - commodityFuturesPreciseTimeMode: commodityFuturesPreciseTimeMode, - discountCurveName: discountCurveName, - engineName: engineName, - riskFreeRateOverride: trade.NoRiskRate ?? double.NaN, - pricingRequest: pricingRequest); - break; - case "亚式合成价差期权": - averagingPeriodStartDate = trade.trade_asian_option.AveragingPeriodStartDate.HasValue - ? trade.trade_asian_option.AveragingPeriodStartDate.Value.ToString("yyyy-MM-dd") - : trade.TradeDate.Value.ToString("yyyy-MM-dd"); - result = ValueAsianSyntheticNormalSpreadOptionTrade( - marketProxy, - valueDate, - underlying.UnderlyingCode, - trade.UnderlyingInstrumentType, - trade.Strike ?? 0, - trade.StartDate.Value.ToString("yyyy-MM-dd"), - endDate, - trade.CallPut, //put call - trade.ExerciseMode,//"European", - trade.trade_asian_option.PayoffType, - trade.trade_asian_option.StrikeType, - spotPrices[0], - tradeNotional, //数量 - volSurfaceNames[0], - trade.NoRiskRate ?? 0, - trade.BuySell, - exerciseDate, - trade.IsAnnualized, - trade.AnnualizeFactor ?? 1.0, - trade.DividendRate ?? 0, - trade.IsMoneynessOptionData, - trade.SpotPrice ?? 0, - null, - fixing, - averagingPeriodStartDate, - hasNightMarket: variety != null && variety.HasNightMarket, - commodityFuturesPreciseTimeMode: commodityFuturesPreciseTimeMode, - discountCurveName: discountCurveName, - ignoreSkewMap: useTradeVolMode, - engineName: engineName, - riskFreeRateOverride: trade.NoRiskRate ?? double.NaN, - dividendRateOverride: trade.DividendRate ?? double.NaN, - pricingRequest: pricingRequest); - break; - - case "远期": - result = ForwardradeCalcService.CalcValue(trade, spotPrices[0]); - break; - case "商品期货": - case "商品现货": - case "股票": - var pv = spotPrices[0] * trade.Notional; - result = new TradeValueResult { Pv = pv, RoundedPv = pv, Delta = trade.Notional, DeltaCash = pv }; - break; - case "场内期权": - result = ValueVanillaOptionTrade( - marketProxy, - valueDate, - underlying.UnderlyingCode, - trade.UnderlyingInstrumentType, - trade.Strike ?? 0, - (trade.StartDate ?? underlying.OpenDate.Value).ToString("yyyy-MM-dd"), - endDate, - trade.CallPut, - trade.ExerciseMode, - spotPrices[0], - tradeNotional, //数量 - volSurfaceNames[0], - riskFreeRate, - null, - "Buy", - exerciseDate, - trade.ParticipationRate ?? 1.0, - trade.PrincipalRate ?? 0, - trade.IsAnnualized, - trade.AnnualizeFactor ?? 1.0, - trade.DividendRate ?? 0, - false, - trade.SpotPrice ?? 0, - hasNightMarket: variety != null && variety.HasNightMarket, - commodityFuturesPreciseTimeMode: commodityFuturesPreciseTimeMode, - discountCurveName: discountCurveName, - ignoreSkewMap: useTradeVolMode, - isForwardTrade: isForwardTrade, - riskFreeRateOverride: trade.NoRiskRate ?? double.NaN, - dividendRateOverride: trade.DividendRate ?? double.NaN, - pricingRequest: pricingRequest); - break; - case "合成价差期权": - result = ValueSyntheticNormalSpreadOptionTrade( - marketProxy, - valueDate, - underlying.UnderlyingCode, - trade.UnderlyingInstrumentType, - trade.Strike ?? 0, - trade.StartDate.Value.ToString("yyyy-MM-dd"), - endDate, - trade.CallPut, //put call - trade.ExerciseMode, - spotPrices[0], - tradeNotional, //数量 - useTradeVolMode ? trade.GenerateVolSurfaceName() : underlying.GenerateVolSurfaceName(), - riskFreeRate, - null, - trade.BuySell, - exerciseDate, - trade.ParticipationRate ?? 1.0, - trade.PrincipalRate ?? 0.0, - trade.IsAnnualized, - trade.AnnualizeFactor ?? 1.0, - trade.DividendRate ?? 0, - trade.IsMoneynessOptionData, - trade.SpotPrice ?? 0, - hasNightMarket: variety != null && variety.HasNightMarket, - commodityFuturesPreciseTimeMode: commodityFuturesPreciseTimeMode, - discountCurveName: discountCurveName, - ignoreSkewMap: useTradeVolMode, - isForwardTrade: isForwardTrade, - engineName: engineName, - riskFreeRateOverride: trade.NoRiskRate ?? double.NaN, - dividendRateOverride: trade.DividendRate ?? double.NaN, - pricingRequest: pricingRequest); - break; - case "双鲨期权": - result = ValueDoubleSharkFinOptionTrade( - marketProxy, - valueDate, - underlying.UnderlyingCode, - trade.UnderlyingInstrumentType, - trade.trade_double_sharkfin_option.StrikeHigh ?? (trade.Strike ?? 0.0), - trade.Strike ?? 0.0, - trade.StartDate.Value.ToString("yyyy-MM-dd"), - endDate, - trade.CallPut, //put call - trade.ExerciseMode,// "European", - trade.trade_double_sharkfin_option.BarrierHigh, - trade.trade_double_sharkfin_option.BarrierLow, - trade.trade_double_sharkfin_option.IsDiscrete, - spotPrices[0], - trade.IsUsePremiumRate.HasValue && trade.IsUsePremiumRate.Value ? ((trade.trade_double_sharkfin_option.RebateRate ?? 0) * (trade.SpotPrice ?? 0)) : (trade.trade_double_sharkfin_option.Rebate ?? 0), - trade.IsUsePremiumRate.HasValue && trade.IsUsePremiumRate.Value ? ((trade.trade_double_sharkfin_option.RebateHighRate ?? 0) * (trade.SpotPrice ?? 0)) : (trade.trade_double_sharkfin_option.RebateHigh ?? 0), - trade.trade_double_sharkfin_option.RebateType, - tradeNotional, //数量 - volSurfaceNames[0], - trade.NoRiskRate ?? 0, - trade.BuySell, - exerciseDate, - trade.ParticipationRate ?? 1.0, - trade.PrincipalRate ?? 0.0, - trade.IsAnnualized, - trade.AnnualizeFactor ?? 1.0, - trade.trade_double_sharkfin_option.CallParticipationRate ?? 1.0, - trade.trade_double_sharkfin_option.PutParticipationRate ?? 1.0, - trade.DividendRate ?? 0, - trade.IsMoneynessOptionData, - trade.SpotPrice ?? 0, - trade.trade_double_sharkfin_option.ObservationDates, - null, //dividends - trade.trade_double_sharkfin_option.KnockInOutStatus, - hasNightMarket: variety != null && variety.HasNightMarket, - commodityFuturesPreciseTimeMode: commodityFuturesPreciseTimeMode, - discountCurveName: discountCurveName, - timeToMaturityDays: (!double.IsNaN(timeToMaturityDays) && timeToMaturityDays > 0) ? timeToMaturityDays : double.NaN, - ignoreSkewMap: useTradeVolMode, - engineName: engineName, - riskFreeRateOverride: trade.NoRiskRate ?? double.NaN, - dividendRateOverride: trade.DividendRate ?? double.NaN, - pricingRequest: pricingRequest); - break; - case "凤凰期权": - result = ValueAutocall( - marketProxy: marketProxy, - valueDate: valueDate, - underlyingCode: underlying.UnderlyingCode, - underlyingInstrumentType: trade.UnderlyingInstrumentType, - startDate: trade.StartDate.Value.ToString("yyyy-MM-dd"), - endDate: endDate, - callPut: trade.CallPut, - koBarrier: trade.trade_autocall.KOBarrier, - kiBarrier: trade.trade_autocall.KIBarrier, - couponBarrier: trade.trade_autocall.CouponBarrier, - koObservationDateStr: trade.trade_autocall.KOObservationDates, - observationDateStr: trade.trade_autocall.ObservationDates, - coupon: trade.trade_autocall.Coupon, - couponPayAtMaturity: trade.trade_autocall.CouponPayAtMaturity, - includeCouponAfterKI: trade.trade_autocall.IncludeCouponAfterKI, - isFixedCoupon: trade.trade_autocall.IsFixedCoupon, - annualizedOptionPayoff: trade.trade_autocall.IsAnnualized2, - participationRate: trade.ParticipationRate ?? 1.0, - principalRate: trade.PrincipalRate ?? 0.0, - spotPrice: spotPrices[0], - notional: tradeNotional, - volSurfaceName: volSurfaceNames[0], - riskFreeRate: trade.NoRiskRate ?? 0.0, - buySell: trade.BuySell, - exerciseDate: exerciseDate, - annualizeFactor: trade.trade_autocall.AnnualizeFactor2 ?? 1.0, - strike: trade.Strike ?? 0.0, - spreadStrike: trade.trade_autocall.SpreadStrike ?? -1, - couponDayCount: trade.trade_autocall.CouponDayCount, - happenedObservations: trade.trade_autocall.HappenedObservations, - dividendRate: trade.DividendRate ?? 0, - isMoneynessOptionData: trade.IsMoneynessOptionData, - initialSpotPrice: trade.SpotPrice ?? 0, - dividends: null, - knockInOutStatus: trade.trade_autocall.KnockInOutStatus, - hasNightMarket: variety != null && variety.HasNightMarket, - commodityFuturesPreciseTimeMode: commodityFuturesPreciseTimeMode, - discountCurveName: discountCurveName, - timeToMaturityDays: (!double.IsNaN(timeToMaturityDays) && timeToMaturityDays > 0) ? timeToMaturityDays : double.NaN, - ignoreSkewMap: useTradeVolMode, - engineName: engineName, - riskFreeRateOverride: trade.NoRiskRate ?? double.NaN, - dividendRateOverride: trade.DividendRate ?? double.NaN, - pricingRequest: pricingRequest); - break; - case "雪球期权": - var snowball = trade.trade_snowball; - result = ValueSnowball( - marketProxy: marketProxy, - valueDate: valueDate, - underlyingCode: underlying.UnderlyingCode, - underlyingInstrumentType: trade.UnderlyingInstrumentType, - startDate: trade.StartDate.Value.ToString("yyyy-MM-dd"), - endDate: endDate, - callPut: trade.CallPut, - koBarrier: snowball.KOBarrier, - kiBarrier: snowball.KIBarrier, - koObservationDateStr: snowball.KOObservationDates, - observationDateStr: snowball.ObservationDates, - coupon: snowball.Coupon, - participationRate: trade.ParticipationRate ?? 1.0, - principalRate: trade.PrincipalRate ?? 0.0, - spotPrice: spotPrices[0], - notional: tradeNotional, - volSurfaceName: volSurfaceNames[0], - riskFreeRate: trade.NoRiskRate ?? 0.0, - buySell: trade.BuySell, - exerciseDate: exerciseDate, - annualizeFactor: snowball.AnnualizeFactor2 ?? 1.0, - strike: trade.Strike ?? 0.0, - spreadStrikeAtKO: snowball.SpreadStrikeAtKO ?? -1, - spreadStrikeAtMaturity: snowball.SpreadStrikeAtMaturity ?? -1, - isFixedCoupon: snowball.IsFixedCoupon, - kORebate: snowball.KORebate, - kOBarrierAdjustStep: snowball.KOBarrierAdjustStep, - //敲出转期权 - useOptionPayoffAtKO: - //敲出转期权 - snowball.KOPayoffType != KOPayoffTypeEnum.Rebate, - //未敲出转期权 - useOptionPayoffAtMaturity: - //未敲出转期权 - snowball.KIPayoffType != KIPayoffTypeEnum.None, - annualizedOptionPayoff: snowball.IsAnnualized2, - couponDayCount: snowball.CouponDayCount, - dividendRate: trade.DividendRate ?? 0, - isMoneynessOptionData: trade.IsMoneynessOptionData, - initialSpotPrice: trade.SpotPrice ?? 0, - dividends: null, - knockInOutStatus: snowball.KnockInOutStatus, - hasNightMarket: variety != null && variety.HasNightMarket, - commodityFuturesPreciseTimeMode: commodityFuturesPreciseTimeMode, - discountCurveName: discountCurveName, - timeToMaturityDays: (!double.IsNaN(timeToMaturityDays) && timeToMaturityDays > 0) ? timeToMaturityDays : double.NaN, - ignoreSkewMap: useTradeVolMode, - engineName: engineName, - riskFreeRateOverride: trade.NoRiskRate ?? double.NaN, - dividendRateOverride: trade.DividendRate ?? double.NaN, - pricingRequest: pricingRequest); - break; - case "区间累积期权": - result = ValueRangeAccrual( - marketProxy, - valueDate, - underlying.UnderlyingCode, - trade.UnderlyingInstrumentType, - trade.StartDate.Value.ToString("yyyy-MM-dd"), - endDate, - trade.ParticipationRate ?? 1.0, - trade.PrincipalRate ?? 0.0, - spotPrices[0], - tradeNotional, - volSurfaceNames[0], - trade.NoRiskRate ?? 0.0, - trade.BuySell, - exerciseDate, - trade.trade_rangeaccrual.LowerRange, - trade.trade_rangeaccrual.UpperRange, - trade.trade_rangeaccrual.BonusRate, - trade.trade_rangeaccrual.ObservationDates, - trade.SettlementDate?.ToString("yyyy-MM-dd"), - trade.AnnualizeFactor ?? 1.0, - trade.Strike ?? 0.0, - trade.IsAnnualized, - trade.trade_rangeaccrual.HappenedObservations, - trade.DividendRate ?? 0, - trade.IsMoneynessOptionData, - trade.SpotPrice ?? 0, - hasNightMarket: variety != null && variety.HasNightMarket, - commodityFuturesPreciseTimeMode: commodityFuturesPreciseTimeMode, - discountCurveName: discountCurveName, - timeToMaturityDays: (!double.IsNaN(timeToMaturityDays) && timeToMaturityDays > 0) ? timeToMaturityDays : double.NaN, - ignoreSkewMap: useTradeVolMode, - engineName: engineName, - riskFreeRateOverride: trade.NoRiskRate ?? double.NaN, - dividendRateOverride: trade.DividendRate ?? double.NaN, - pricingRequest: pricingRequest); - break; - case "气囊结构": - result = ValueAirbag( - marketProxy, - valueDate, - underlying.UnderlyingCode, - trade.UnderlyingInstrumentType, - trade.Strike ?? 0.0, - trade.trade_airbag.HighStrike, - trade.StartDate.Value.ToString("yyyy-MM-dd"), - endDate, - trade.CallPut, - trade.ExerciseMode, - trade.trade_airbag.Barrier, - trade.ParticipationRate ?? 1.0, - trade.trade_airbag.KIParticipationRate, - trade.PrincipalRate ?? 0.0, - trade.trade_airbag.IsDiscreteMonitored, - trade.trade_airbag.HasPayoffLimit, - spotPrices[0], - tradeNotional, - trade.NoRiskRate ?? 0.0, - trade.DividendRate ?? 0, - volSurfaceNames[0], - trade.BuySell, - trade.ExerciseDate.Value.ToString("yyyy-MM-dd"), - trade.IsAnnualized, - trade.AnnualizeFactor ?? 1.0, - trade.IsMoneynessOptionData, - trade.SpotPrice ?? 0, - null, - null, - trade.BuySell, - barrierStatus: "Monitoring", - hasNightMarket: variety != null && variety.HasNightMarket, - commodityFuturesPreciseTimeMode: commodityFuturesPreciseTimeMode, - discountCurveName: discountCurveName, - timeToMaturityDays: (!double.IsNaN(timeToMaturityDays) && timeToMaturityDays > 0) ? timeToMaturityDays : double.NaN, - engineName: engineName, - riskFreeRateOverride: trade.NoRiskRate ?? double.NaN, - dividendRateOverride: trade.DividendRate ?? double.NaN, - pricingRequest: pricingRequest); - break; - case "收益增强结构": - result = ValueUnderlyingEnhance( - marketProxy, - valueDate, - underlying.UnderlyingCode, - trade.UnderlyingInstrumentType, - trade.Strike ?? 0.0, - trade.trade_underlying_enhance.AnnualizedEnhanceRate ?? 0.0, - trade.StartDate.Value.ToString("yyyy-MM-dd"), - endDate, - trade.CallPut, - trade.ExerciseMode, - trade.ParticipationRate ?? 1, - spotPrices[0], - tradeNotional, - trade.NoRiskRate ?? 0.0, - trade.DividendRate ?? 0, - volSurfaceNames[0], - trade.BuySell, - trade.ExerciseDate.Value.ToString("yyyy-MM-dd"), - trade.IsAnnualized, - trade.AnnualizeFactor ?? 1.0, - trade.IsMoneynessOptionData, - trade.SpotPrice ?? 0, - discountCurveName: discountCurveName, - hasNightMarket: variety != null && variety.HasNightMarket, - commodityFuturesPreciseTimeMode: commodityFuturesPreciseTimeMode, - timeToMaturityDays: (!double.IsNaN(timeToMaturityDays) && timeToMaturityDays > 0) ? timeToMaturityDays : double.NaN, - riskFreeRateOverride: trade.NoRiskRate ?? double.NaN, - dividendRateOverride: trade.DividendRate ?? double.NaN, - pricingRequest: pricingRequest); - break; - case "累计期权": - result = ValueAccumulatorOptionTrade( - marketProxy, - valueDate, - trade.StartDate.Value.ToString("yyyy-MM-dd"), - endDate, - trade.ExerciseDate.Value.ToString("yyyy-MM-dd"), - trade.OptionType, - underlying.UnderlyingCode, - trade.UnderlyingInstrumentType, - trade.Strike ?? 0.0, - trade.trade_accumulator_option.ObservationDates, - trade.trade_accumulator_option.Barrier, - trade.trade_accumulator_option.Coupon, - trade.trade_accumulator_option.CallMultiplier ?? 1.0, - trade.trade_accumulator_option.PutMultiplier ?? 1.0, - trade.trade_accumulator_option.EarlyTerminate, - trade.trade_accumulator_option.PayCoupon, - trade.ParticipationRate ?? 1.0, - spotPrices[0], - tradeNotional, - trade.NoRiskRate ?? 0.0, - trade.DividendRate ?? 0, - volSurfaceNames[0], - trade.BuySell, - trade.IsAnnualized, - trade.AnnualizeFactor ?? 1.0, - trade.IsMoneynessOptionData, - trade.SpotPrice ?? 0, - discountCurveName: discountCurveName, - hasNightMarket: variety != null && variety.HasNightMarket, - commodityFuturesPreciseTimeMode: commodityFuturesPreciseTimeMode, - timeToMaturityDays: (!double.IsNaN(timeToMaturityDays) && timeToMaturityDays > 0) ? timeToMaturityDays : double.NaN, - riskFreeRateOverride: trade.NoRiskRate ?? double.NaN, - dividendRateOverride: trade.DividendRate ?? double.NaN, - pricingRequest: pricingRequest); - break; - case "现金流交易": - result = ValueCashFlowTrade( - marketProxy, - valueDate, - trade.StartDate.Value.ToString("yyyy-MM-dd"), - endDate, - underlying.UnderlyingCode, - tradeNotional, - trade.trade_cashflow.RateType, - trade.BuySell, - volSurfaceNames[0], - trade.NoRiskRate ?? 0.0, - trade.trade_cashflow.ProfitRate, - discountCurveName, - pricingRequest); - break; - default: - break; - } - #endregion - - if (result != null) - { - result.Strike = trade.Strike ?? 0; - if (spotPrices != null && spotPrices.Any()) - { - result.SpotPrice = spotPrices[0]; - } - } - return result; - } - - private static string[] GenerateVolSurfaceName( - VolConstructionType volConstructionType, - bool useTradeVolMode, - underlying_manager underlying, - trade trade, - string optionalVolKey = null) - { - if (volConstructionType == VolConstructionType.SkewMap || useTradeVolMode) - { - return new string[] { trade.GenerateVolSurfaceName() }; - } - else if (!useTradeVolMode) - { - return new string[] { underlying.GenerateVolSurfaceName() }; - } - else - { - switch (trade.TradeType) - { - case "彩虹期权": - var rainbowOptionVolKeys = new string[2]; - rainbowOptionVolKeys[0] = trade.GenerateVolSurfaceName(); - rainbowOptionVolKeys[1] = trade.GenerateVolSurfaceName(optionalVolKey); - return useTradeVolMode ? rainbowOptionVolKeys : trade.trade_rainbow_option.UnderlyingCodes.Select(x => x.GenerateVolSurfaceKey()).ToArray(); - default: - return new string[] { useTradeVolMode ? trade.GenerateVolSurfaceName() : underlying.GenerateVolSurfaceName() }; - } - } - } - - public static double GetInterpolatedVolForSkewMapMode( - IQdpMarketProxy marketProxy, - string valueDate, - string underlyingCode, - string exerciseDate, - double strike, - bool isBuy, - bool isCall, - double spotPrice, - int? skewMapVolVar = null, - double timeToMaturityDays = double.NaN) - { - var baseVolSurface = marketProxy.GetSkewMapBaseVolSurface(valueDate, underlyingCode); - var skewMapVolSurface = new SkewMapVolSurface(baseVolSurface.BaseVol); - - //var calendar = CalendarImpl.Get("chn"); - var t = double.IsNaN(timeToMaturityDays) - ? TradeCalcHelper.CalculateTTMDays( - DateTime.Parse(valueDate), - DateTime.Parse(exerciseDate), - varietyid: 0, - precisionOfMinute: false) //calendar.NumberBizDaysBetweenDate(new Date(DateTime.Parse(valueDate)), new Date(DateTime.Parse(exerciseDate)), true) - : timeToMaturityDays; - - var volVar = skewMapVolVar ?? (int)(isBuy ? baseVolSurface.BidVar : baseVolSurface.AskVar); - - return skewMapVolSurface.GetVol( - t: Math.Ceiling(t), //不考虑日内精确时间 - k: strike, - spot: spotPrice, - isCall: isCall, - isBuy: isBuy, - var: volVar); - } - - public static void SetSkewMapVol( - IQdpMarketProxy marketProxy, - string valueDate, - string underlyingCode, - string exerciseDate, - double strike, - bool isBuy, - bool isCall, - string tradeId, - double spotPrice, - int? skewMapVolVar = null, - double timeToMaturityDays = double.NaN) - { - var vol = GetInterpolatedVolForSkewMapMode( - marketProxy, - valueDate, - underlyingCode, - exerciseDate, - strike, - isBuy, - isCall, - spotPrice, - skewMapVolVar, - timeToMaturityDays); - - var underlying = underlying_managerBLL.GetByCode(underlyingCode); - //根据获取的Vol点,构造一个用于该trade的平的波动率曲面 - var flatNormalVolSurface = VolatilityBuilder.CreateMoneynessVolBuilder(DateTime.Parse(valueDate)) - .SetUnderlying(underlying).SetData(vol).Build(); - //.GetDefault(DateTime.Parse(valueDate), underlying, defaultVol: vol); - var initParam = new VolSurfaceInitParamsBuilder() - .SetVolatility(flatNormalVolSurface).SetValueDate(valueDate).Build(tradeId); - VolSurfaceInitializerSingleton.GetInitializer(true).InitializeMarketProxy(marketProxy, initParam); - } - - /// - /// 期货期权卖方交易保证金的收取标准为下列两者中较大者: - ///(1)权利金(期权合约结算价×标的期货合约交易单位)+标的期货合约交易保证金-期权合约虚值额的一半 - ///(2)权利金(期权合约结算价×标的期货合约交易单位)+标的期货合约交易保证金的一半 - ///看涨虚值额 = max(期权合约执行价格 - 标的期货合约当日结算价,0)*合约乘数; - ///看跌虚值额=max(标的期货合约当日结算价 - 期权合约执行价格,0)*合约乘数。 - ///豆粕期权的合约乘数是10、标的期货合约的交易单位是10. - ///所以以上2个公式可以结合成为一个公式: - ///保证金=权利金+MAX(期货保证金-1/2虚值额,1/2期货保证金) - /// - /// 权利金 - /// 交易量 - /// 行权价 - /// 现价 - /// 期货保证金率 - /// 看涨看跌 - /// - public static double CommodityFutureOptionMargin(double premium, double amount, double strike, double spotPrice, double futureMarginRatio, string optionType = "Call") - { - var futureMargin = futureMarginRatio * amount * spotPrice; - var outTheMoney = - (optionType.ToUpper() == "PUT") - ? Math.Max(spotPrice - strike, 0) * amount //看跌虚值额 - : Math.Max(strike - spotPrice, 0) * amount; //看涨虚值额 - - return premium + Math.Max(futureMargin - outTheMoney * 0.5, futureMargin * 0.5); - } - - /// - /// 股指期货类型转换为商品期货类型 - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static string ConvertInstrumentType(string instrumentType) - { - return ConsGlobal.InstrumentType.IsStockIF(instrumentType) ? ConsGlobal.InstrumentType.CommodityFutures : instrumentType; - } - - public static T CheckMaturityDate(this T trade) where T : TradeBase - { - if (trade?.MaturityDate.Year > 2030) - { - trade.MaturityDate = new Date(DateTime.Now.AddYears(3)); - } - return trade; - } - } -} diff --git a/YLErpUnitTest/Modules/ClientModule/ClientPositionServiceTest.cs b/YLErpUnitTest/Modules/ClientModule/ClientPositionServiceTest.cs deleted file mode 100644 index 89fb323a..00000000 --- a/YLErpUnitTest/Modules/ClientModule/ClientPositionServiceTest.cs +++ /dev/null @@ -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); - } - } - } -} diff --git a/YLErpUnitTest/Modules/DataCacheModule/DataCacheTest.cs b/YLErpUnitTest/Modules/DataCacheModule/DataCacheTest.cs deleted file mode 100644 index 54851b3d..00000000 --- a/YLErpUnitTest/Modules/DataCacheModule/DataCacheTest.cs +++ /dev/null @@ -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); - } - } -} diff --git a/YLErpUnitTest/Modules/DataProviderModule/EodExchangeOptionPriceProviderTest.cs b/YLErpUnitTest/Modules/DataProviderModule/EodExchangeOptionPriceProviderTest.cs deleted file mode 100644 index 05b515cf..00000000 --- a/YLErpUnitTest/Modules/DataProviderModule/EodExchangeOptionPriceProviderTest.cs +++ /dev/null @@ -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($"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); - } - } -} diff --git a/YLErpUnitTest/Modules/DataProviderModule/ExchangeOptionPriceProviderTest.cs b/YLErpUnitTest/Modules/DataProviderModule/ExchangeOptionPriceProviderTest.cs deleted file mode 100644 index 8b6849ba..00000000 --- a/YLErpUnitTest/Modules/DataProviderModule/ExchangeOptionPriceProviderTest.cs +++ /dev/null @@ -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($"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); - } - } -} diff --git a/YLErpUnitTest/Modules/DataProviderModule/TradeHisDataProviderTest.cs b/YLErpUnitTest/Modules/DataProviderModule/TradeHisDataProviderTest.cs deleted file mode 100644 index 3a1ce310..00000000 --- a/YLErpUnitTest/Modules/DataProviderModule/TradeHisDataProviderTest.cs +++ /dev/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($"{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($"{nameof(t.TradeId)} in (1)"); - } - } -} diff --git a/YLErpUnitTest/Modules/EodModule/EodSettlementServiceTest.cs b/YLErpUnitTest/Modules/EodModule/EodSettlementServiceTest.cs deleted file mode 100644 index bb5f2786..00000000 --- a/YLErpUnitTest/Modules/EodModule/EodSettlementServiceTest.cs +++ /dev/null @@ -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(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; - } - } - } - } -} diff --git a/YLErpUnitTest/Modules/MarginModule/BasicCalcTest.cs b/YLErpUnitTest/Modules/MarginModule/BasicCalcTest.cs deleted file mode 100644 index bd8ef7bc..00000000 --- a/YLErpUnitTest/Modules/MarginModule/BasicCalcTest.cs +++ /dev/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(); - - 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"); - // } - //} - } - } -} diff --git a/YLErpUnitTest/Modules/MarginModule/MarginParamsProviderTest.cs b/YLErpUnitTest/Modules/MarginModule/MarginParamsProviderTest.cs deleted file mode 100644 index b9d4fcdc..00000000 --- a/YLErpUnitTest/Modules/MarginModule/MarginParamsProviderTest.cs +++ /dev/null @@ -1,10 +0,0 @@ -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace YLErp.Modules.MarginModule -{ - [TestClass] - public class MarginParamsProviderTest : UnitTestBase - { - - } -} diff --git a/YLErpUnitTest/Modules/SalesModule/SalesCommissionServiceTest.cs b/YLErpUnitTest/Modules/SalesModule/SalesCommissionServiceTest.cs deleted file mode 100644 index 4633a00b..00000000 --- a/YLErpUnitTest/Modules/SalesModule/SalesCommissionServiceTest.cs +++ /dev/null @@ -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)); - } - } -} diff --git a/YLErpUnitTest/Modules/TapconsoleModule/HaitongApiTest.cs b/YLErpUnitTest/Modules/TapconsoleModule/HaitongApiTest.cs deleted file mode 100644 index 595d95b0..00000000 --- a/YLErpUnitTest/Modules/TapconsoleModule/HaitongApiTest.cs +++ /dev/null @@ -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); - } - } -} diff --git a/YLErpUnitTest/Modules/TradeModule/OrderModule/OtcTradeImportServiceTest.cs b/YLErpUnitTest/Modules/TradeModule/OrderModule/OtcTradeImportServiceTest.cs deleted file mode 100644 index d5fc6084..00000000 --- a/YLErpUnitTest/Modules/TradeModule/OrderModule/OtcTradeImportServiceTest.cs +++ /dev/null @@ -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 -{ - /// - /// 场外期权交易导入测试 - /// - [TestClass] - public class OtcTradeImportServiceTest : UnitTestBase - { - [TestMethod("测试场外期权雪球交易导入")] - public void TestImportSnowBallTrade() - { - List 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 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; - } - } -} diff --git a/YLErpUnitTest/Modules/TradeModule/OrderModule/OtcTradeSaveServiceTest.cs b/YLErpUnitTest/Modules/TradeModule/OrderModule/OtcTradeSaveServiceTest.cs deleted file mode 100644 index 7feb8d35..00000000 --- a/YLErpUnitTest/Modules/TradeModule/OrderModule/OtcTradeSaveServiceTest.cs +++ /dev/null @@ -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 -{ - /// - /// 测试交易保存服务 - /// - - [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 { 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("亚式期权"); - } - - [TestMethod("测试保存二元期权交易")] - public void TestSaveBinaryOption() - { - InnerTest("二元期权"); - } - - [TestMethod("测试保存障碍期权交易")] - public void TestSaveBarrierOption() - { - InnerTest("障碍期权"); - } - - [TestMethod("测试保存双鲨期权交易")] - public void TestSaveDoubleSharkfinOption() - { - InnerTest("双鲨期权"); - } - - [TestMethod("测试保存区间累积期权交易")] - public void TestSaveRangeAccOption() - { - InnerTest("区间累积期权"); - } - - [TestMethod("测试保存气囊结构交易")] - public void TestSaveAirBagOption() - { - InnerTest("气囊结构"); - } - - [TestMethod("测试保存收益增强结构交易")] - public void TestSaveUnderlyingEnhanceOption() - { - InnerTest("收益增强结构"); - } - - [TestMethod("测试保存雪球期权交易")] - public void TestSaveSnowballOption() - { - InnerTest("雪球期权"); - } - - [TestMethod("测试保存凤凰期权交易")] - public void TestSaveAutoCallOption() - { - InnerTest("凤凰期权"); - } - - private void InnerTest(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("id=" + td.id); - AddClearSQL("TradeId=" + td.id); - AddClearSQL("TradeId=" + td.id); - } - - var map1 = YLAutoMapper.Map(td); - var map2 = YLAutoMapper.Map(dbTrade); - ComparisonResult result = _compareLogic.Compare(map1, map2); - Assert.IsTrue(result.AreEqual, result.DifferencesString); - - var tdex1 = YLAutoMapper.Map(td); - var tdex2 = YLAutoMapper.Map(dbTrade); - Assert.IsTrue(tdex2.TradeId > 0, "TradeId映射失败"); - result = _compareLogic.Compare(tdex1, tdex2); - Assert.IsTrue(result.AreEqual, result.DifferencesString); - } - - class VanillaTrade : TradeExtendBase - { - - } - } -} diff --git a/YLErpUnitTest/Modules/TradeModule/OrderModule/TradeAbstractServiceTest.cs b/YLErpUnitTest/Modules/TradeModule/OrderModule/TradeAbstractServiceTest.cs deleted file mode 100644 index 8c7755c8..00000000 --- a/YLErpUnitTest/Modules/TradeModule/OrderModule/TradeAbstractServiceTest.cs +++ /dev/null @@ -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); - } - } - } -} diff --git a/YLErpUnitTest/Modules/TradeModule/OtcTradeCloseServiceTest.cs b/YLErpUnitTest/Modules/TradeModule/OtcTradeCloseServiceTest.cs deleted file mode 100644 index af0b8e85..00000000 --- a/YLErpUnitTest/Modules/TradeModule/OtcTradeCloseServiceTest.cs +++ /dev/null @@ -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); - } - } -} diff --git a/YLErpUnitTest/Modules/TradeModule/OtcTradeExportServiceTest.cs b/YLErpUnitTest/Modules/TradeModule/OtcTradeExportServiceTest.cs deleted file mode 100644 index 6389b62f..00000000 --- a/YLErpUnitTest/Modules/TradeModule/OtcTradeExportServiceTest.cs +++ /dev/null @@ -1,24 +0,0 @@ -using Microsoft.VisualStudio.TestTools.UnitTesting; -using System.Linq; -using YLErp.Modules.TradeModule.QueryModule; - -namespace YLErp.Modules.TradeModule -{ - /// - /// 场外期权交易导出测试 - /// - [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); - } - } -} diff --git a/YLErpUnitTest/Modules/TradeModule/OtcTradeSaveServiceTest.cs b/YLErpUnitTest/Modules/TradeModule/OtcTradeSaveServiceTest.cs deleted file mode 100644 index 788e48ba..00000000 --- a/YLErpUnitTest/Modules/TradeModule/OtcTradeSaveServiceTest.cs +++ /dev/null @@ -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); - } - } -} diff --git a/YLErpUnitTest/Modules/TradeModule/TradeHisDataServiceTest.cs b/YLErpUnitTest/Modules/TradeModule/TradeHisDataServiceTest.cs deleted file mode 100644 index cd792f9e..00000000 --- a/YLErpUnitTest/Modules/TradeModule/TradeHisDataServiceTest.cs +++ /dev/null @@ -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); - } - } -} diff --git a/YLErpUnitTest/Modules/UnderlyingModule/ApiModuleTest.cs b/YLErpUnitTest/Modules/UnderlyingModule/ApiModuleTest.cs deleted file mode 100644 index 07fe85dc..00000000 --- a/YLErpUnitTest/Modules/UnderlyingModule/ApiModuleTest.cs +++ /dev/null @@ -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()); - } - } -} diff --git a/YLErpUnitTest/Modules/UnderlyingModule/HisDataServiceTest.cs b/YLErpUnitTest/Modules/UnderlyingModule/HisDataServiceTest.cs deleted file mode 100644 index 9dfdf67a..00000000 --- a/YLErpUnitTest/Modules/UnderlyingModule/HisDataServiceTest.cs +++ /dev/null @@ -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("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("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%"); - } - } -} diff --git a/YLErpUnitTest/Modules/UnderlyingModule/MarginParamsImportServiceTest.cs b/YLErpUnitTest/Modules/UnderlyingModule/MarginParamsImportServiceTest.cs deleted file mode 100644 index 5b61c79e..00000000 --- a/YLErpUnitTest/Modules/UnderlyingModule/MarginParamsImportServiceTest.cs +++ /dev/null @@ -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("{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("{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); - } - } - } -} diff --git a/YLErpUnitTest/Modules/VolatilityModule/VarietyVolServiceTest.cs b/YLErpUnitTest/Modules/VolatilityModule/VarietyVolServiceTest.cs deleted file mode 100644 index 843cf694..00000000 --- a/YLErpUnitTest/Modules/VolatilityModule/VarietyVolServiceTest.cs +++ /dev/null @@ -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(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(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(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(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); - } - } -} diff --git a/YLErpUnitTest/Modules/VolatilityModule/VolatilityBasicTest.cs b/YLErpUnitTest/Modules/VolatilityModule/VolatilityBasicTest.cs deleted file mode 100644 index 0912845a..00000000 --- a/YLErpUnitTest/Modules/VolatilityModule/VolatilityBasicTest.cs +++ /dev/null @@ -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>(vola.Data); - - Assert.AreEqual(0.255333, list[0].Vol); - } - } -} diff --git a/YLErpUnitTest/Modules/VolatilityModule/VolatilityQueryServiceTest.cs b/YLErpUnitTest/Modules/VolatilityModule/VolatilityQueryServiceTest.cs deleted file mode 100644 index 08923b87..00000000 --- a/YLErpUnitTest/Modules/VolatilityModule/VolatilityQueryServiceTest.cs +++ /dev/null @@ -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($"{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); - } - } -} diff --git a/YLErpUnitTest/Properties/AssemblyInfo.cs b/YLErpUnitTest/Properties/AssemblyInfo.cs deleted file mode 100644 index ea6c0120..00000000 --- a/YLErpUnitTest/Properties/AssemblyInfo.cs +++ /dev/null @@ -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")] diff --git a/YLErpUnitTest/Properties/Resources.Designer.cs b/YLErpUnitTest/Properties/Resources.Designer.cs deleted file mode 100644 index c073e1e4..00000000 --- a/YLErpUnitTest/Properties/Resources.Designer.cs +++ /dev/null @@ -1,63 +0,0 @@ -//------------------------------------------------------------------------------ -// -// 此代码由工具生成。 -// 运行时版本:4.0.30319.42000 -// -// 对此文件的更改可能会导致不正确的行为,并且如果 -// 重新生成代码,这些更改将会丢失。 -// -//------------------------------------------------------------------------------ - -namespace YLErp.Properties { - using System; - - - /// - /// 一个强类型的资源类,用于查找本地化的字符串等。 - /// - // 此类是由 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() { - } - - /// - /// 返回此类使用的缓存的 ResourceManager 实例。 - /// - [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; - } - } - - /// - /// 重写当前线程的 CurrentUICulture 属性 - /// 重写当前线程的 CurrentUICulture 属性。 - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - } -} diff --git a/YLErpUnitTest/Properties/Resources.resx b/YLErpUnitTest/Properties/Resources.resx deleted file mode 100644 index 1af7de15..00000000 --- a/YLErpUnitTest/Properties/Resources.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/YLErpUnitTest/QdpModule/QdpCalendarTest.cs b/YLErpUnitTest/QdpModule/QdpCalendarTest.cs deleted file mode 100644 index 519621ec..00000000 --- a/YLErpUnitTest/QdpModule/QdpCalendarTest.cs +++ /dev/null @@ -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); - } - } -} diff --git a/YLErpUnitTest/Resources/volatility.json b/YLErpUnitTest/Resources/volatility.json deleted file mode 100644 index 3996008f..00000000 --- a/YLErpUnitTest/Resources/volatility.json +++ /dev/null @@ -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 - } -] \ No newline at end of file diff --git a/YLErpUnitTest/Resources/场外期权导入/场外期权交易导入(凤凰).xlsx b/YLErpUnitTest/Resources/场外期权导入/场外期权交易导入(凤凰).xlsx deleted file mode 100644 index 4d69efe7..00000000 Binary files a/YLErpUnitTest/Resources/场外期权导入/场外期权交易导入(凤凰).xlsx and /dev/null differ diff --git a/YLErpUnitTest/Resources/场外期权导入/场外期权交易导入(雪球).xlsx b/YLErpUnitTest/Resources/场外期权导入/场外期权交易导入(雪球).xlsx deleted file mode 100644 index 0eef2de3..00000000 Binary files a/YLErpUnitTest/Resources/场外期权导入/场外期权交易导入(雪球).xlsx and /dev/null differ diff --git a/YLErpUnitTest/Resources/日终结算/Eod表更新.sql b/YLErpUnitTest/Resources/日终结算/Eod表更新.sql deleted file mode 100644 index 70f207e4..00000000 --- a/YLErpUnitTest/Resources/日终结算/Eod表更新.sql +++ /dev/null @@ -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`; diff --git a/YLErpUnitTest/Resources/日终结算/查询结算数据.sql b/YLErpUnitTest/Resources/日终结算/查询结算数据.sql deleted file mode 100644 index e3091c52..00000000 --- a/YLErpUnitTest/Resources/日终结算/查询结算数据.sql +++ /dev/null @@ -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'; - --------------------------------------------------------- diff --git a/YLErpUnitTest/Resources/日终结算/清空结算数据.sql b/YLErpUnitTest/Resources/日终结算/清空结算数据.sql deleted file mode 100644 index b6992f28..00000000 --- a/YLErpUnitTest/Resources/日终结算/清空结算数据.sql +++ /dev/null @@ -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; \ No newline at end of file diff --git a/YLErpUnitTest/Resources/日终结算/结算数据比较.sql b/YLErpUnitTest/Resources/日终结算/结算数据比较.sql deleted file mode 100644 index 506e5a86..00000000 --- a/YLErpUnitTest/Resources/日终结算/结算数据比较.sql +++ /dev/null @@ -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) \ No newline at end of file diff --git a/YLErpUnitTest/Resources/期权计算/二元期权.json b/YLErpUnitTest/Resources/期权计算/二元期权.json deleted file mode 100644 index a01d7c5d..00000000 --- a/YLErpUnitTest/Resources/期权计算/二元期权.json +++ /dev/null @@ -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" -} \ No newline at end of file diff --git a/YLErpUnitTest/Resources/期权计算/二元期权计算参数.json b/YLErpUnitTest/Resources/期权计算/二元期权计算参数.json deleted file mode 100644 index 0a1528da..00000000 --- a/YLErpUnitTest/Resources/期权计算/二元期权计算参数.json +++ /dev/null @@ -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" - ] -} \ No newline at end of file diff --git a/YLErpUnitTest/UnitTestBase.cs b/YLErpUnitTest/UnitTestBase.cs deleted file mode 100644 index 72271a18..00000000 --- a/YLErpUnitTest/UnitTestBase.cs +++ /dev/null @@ -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(); - } - - /// - /// 生成标的代码为CESHI99X的标的或者RB00(长期固定代码) - /// - 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("UnderlyingCode='{0}'", underlyingCode); - } - } - - return un; - } - - /// - /// 生成标的代码为CESHI99X的标的 - /// - 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("id=" + va.id); - } - } - - return va; - } - - AssetUnit _assetunit; - - /// - /// 获取test1簿记 - /// - 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; - - /// - /// 获取test1客户 - /// - 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(string whereFormat, params object[] args) where TEntity : class - { - var tableName = DbContext.GetTableName(); - - _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(); - } - } - } -} diff --git a/YLErpUnitTest/YLErpUnitTest.csproj b/YLErpUnitTest/YLErpUnitTest.csproj deleted file mode 100644 index 1935b71c..00000000 --- a/YLErpUnitTest/YLErpUnitTest.csproj +++ /dev/null @@ -1,283 +0,0 @@ - - - - - - - Debug - AnyCPU - {12BAF174-CB2F-4A92-9C82-B7AE28C1BAD9} - Library - Properties - YLErp - YLErpUnitTest - v4.7.2 - 512 - {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 15.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages - False - UnitTest - - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - ..\packages\AutoMapper.10.0.0\lib\net461\AutoMapper.dll - - - ..\packages\ClosedXML.0.95.3\lib\net46\ClosedXML.dll - - - ..\packages\Dapper.2.0.35\lib\net461\Dapper.dll - - - ..\packages\DocumentFormat.OpenXml.2.11.3\lib\net46\DocumentFormat.OpenXml.dll - - - ..\packages\EntityFramework.6.4.4\lib\net45\EntityFramework.dll - - - ..\packages\EntityFramework.6.4.4\lib\net45\EntityFramework.SqlServer.dll - - - ..\packages\ExcelDataReader.3.6.0\lib\net45\ExcelDataReader.dll - - - ..\packages\ExcelDataReader.DataSet.3.6.0\lib\net35\ExcelDataReader.DataSet.dll - - - ..\packages\ExcelNumberFormat.1.0.10\lib\net20\ExcelNumberFormat.dll - - - ..\packages\CompareNETObjects.4.66.0\lib\net472\KellermanSoftware.Compare-NET-Objects.dll - - - - ..\packages\MSTest.TestFramework.2.1.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll - - - ..\packages\MSTest.TestFramework.2.1.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll - - - ..\packages\MySql.Data.6.10.9\lib\net452\MySql.Data.dll - - - ..\packages\MySql.Data.Entity.6.10.9\lib\net452\MySql.Data.Entity.EF6.dll - - - ..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll - - - False - ..\DLL\Qdp\Qdp.ComputeService.Data.CommonModels.dll - - - False - ..\DLL\Qdp\Qdp.ComputeServiceV2.Data.CommonModels.dll - - - ..\DLL\Qdp\Qdp.Foundation.dll - - - ..\DLL\Qdp\Qdp.Pricing.Base.dll - - - - ..\DLL\Qdp\Qdp.Pricing.Library.Base.dll - - - False - ..\DLL\Qdp\Qdp.Pricing.Library.Common.dll - - - False - ..\DLL\Qdp\Qdp.Pricing.Library.Equity.dll - - - False - ..\DLL\Qdp\Qdp.Pricing.Library.Options.dll - - - - - - - - - - - - - - ..\packages\System.IO.FileSystem.Primitives.4.3.0\lib\net46\System.IO.FileSystem.Primitives.dll - True - True - - - ..\packages\System.IO.Packaging.4.7.0\lib\net46\System.IO.Packaging.dll - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - True - True - Resources.resx - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - PreserveNewest - - - - - PreserveNewest - - - PreserveNewest - - - Always - - - PreserveNewest - - - - - - - - - {7739DB31-DFEB-4995-97DE-58AD0AEE27CB} - YieldChain.Core - - - {BBE242B4-3BC6-4D19-BF16-47BB3AA79CD9} - YLErp.Core - - - {6ff75ad7-6150-43ca-b603-c085a4e5348c} - YLErp.Office - - - {e398d3c7-d608-43bf-a8dd-9698aead0593} - YLErpDAL - - - - - ResXFileCodeGenerator - Resources.Designer.cs - - - - - Always - - - - - - - - - - - - - - 这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。 - - - - - - - - - \ No newline at end of file diff --git a/YLErpUnitTest/app.config b/YLErpUnitTest/app.config deleted file mode 100644 index b3aaddc7..00000000 --- a/YLErpUnitTest/app.config +++ /dev/null @@ -1,113 +0,0 @@ - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/YLErpUnitTest/packages.config b/YLErpUnitTest/packages.config deleted file mode 100644 index 4d8ec113..00000000 --- a/YLErpUnitTest/packages.config +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - - - - \ No newline at end of file