{"id":481486,"date":"2026-05-29T04:19:57","date_gmt":"2026-05-29T04:19:57","guid":{"rendered":"https:\/\/savepearlharbor.com\/?p=481486"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=481486","title":{"rendered":"\u041c\u0438\u043a\u0440\u043e\u0441\u0435\u043a\u0443\u043d\u0434\u043d\u044b\u0435 \u043e\u0446\u0435\u043d\u043a\u0438 \u043e\u043f\u0446\u0438\u043e\u043d\u043e\u0432: \u043a\u0430\u043a \u043f\u0435\u0440\u0435\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u043f\u043e\u0440\u0442\u0444\u0435\u043b\u044c \u0438\u0437 200k \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0437\u0430 10 \u043c\u0441"},"content":{"rendered":"<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0424\u0438\u043d\u0430\u043d\u0441\u043e\u0432\u044b\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043f\u0440\u0435\u0434\u044a\u044f\u0432\u043b\u044f\u044e\u0442 \u0436\u0451\u0441\u0442\u043a\u0438\u0435 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f \u043a \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>\u0420\u0438\u0441\u043a-\u0434\u0435\u043f\u0430\u0440\u0442\u0430\u043c\u0435\u043d\u0442 \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u043e\u0446\u0435\u043d\u043a\u0443 \u043f\u043e\u0440\u0442\u0444\u0435\u043b\u044f \u0438\u0437 200 000 \u043e\u043f\u0446\u0438\u043e\u043d\u043e\u0432. \u041c\u0430\u0440\u0436\u0438\u043d\u0430\u043b\u044c\u043d\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043f\u0435\u0440\u0435\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0432\u0441\u0435 \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u043f\u043e\u0441\u043b\u0435 \u0441\u0438\u043b\u044c\u043d\u043e\u0433\u043e \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f \u0440\u044b\u043d\u043a\u0430. \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0442\u0440\u0435\u0439\u0434\u0435\u0440 \u0445\u043e\u0447\u0435\u0442 \u043e\u0446\u0435\u043d\u0438\u0442\u044c Greeks \u0434\u043b\u044f \u0442\u044b\u0441\u044f\u0447 \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u0441\u0434\u0435\u043b\u043e\u043a \u0437\u0430 \u043c\u0438\u043b\u043b\u0438\u0441\u0435\u043a\u0443\u043d\u0434\u044b.<\/p>\n<p>\u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044b \u043d\u0430 .NET \u0434\u0430\u044e\u0442 \u0441\u0431\u043e\u0439 \u043f\u043e \u0442\u0440\u0451\u043c \u043f\u0440\u0438\u0447\u0438\u043d\u0430\u043c.<\/p>\n<p><strong>\u041f\u0440\u0438\u0447\u0438\u043d\u0430 1: \u041e\u0431\u044a\u0435\u043a\u0442\u043d\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c<\/strong><\/p>\n<p>\u041a\u0430\u0436\u0434\u044b\u0439 \u043e\u043f\u0446\u0438\u043e\u043d \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u043c \u0432 \u043a\u0443\u0447\u0435. \u0412\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b, \u0441\u0441\u044b\u043b\u043a\u0438, \u0440\u0430\u0437\u0440\u043e\u0437\u043d\u0435\u043d\u043d\u043e\u0435 \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438. \u0414\u043b\u044f 200 000 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u2014 \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u044b \u0431\u0430\u0439\u0442\u043e\u0432, GC-\u043f\u0430\u0443\u0437\u044b \u043d\u0430 \u0441\u0431\u043e\u0440\u043a\u0443, \u043f\u0440\u043e\u043c\u0430\u0445\u0438 \u043a\u044d\u0448\u0430 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430.<\/p>\n<p><strong>\u041f\u0440\u0438\u0447\u0438\u043d\u0430 2: \u041f\u043e\u0437\u043b\u0435\u043c\u0435\u043d\u0442\u043d\u044b\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f<\/strong><\/p>\n<p>\u0412\u044b\u0437\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0446\u0435\u043d\u043e\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0432 \u0446\u0438\u043a\u043b\u0435 \u2014 \u043f\u043b\u043e\u0445\u043e. \u041f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0432\u0435\u043a\u0442\u043e\u0440\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u0434, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043d\u0435 \u0432\u0438\u0434\u0438\u0442 \u0432\u0441\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u0443 \u0446\u0435\u043b\u0438\u043a\u043e\u043c. SIMD-\u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u043f\u0440\u043e\u0441\u0442\u0430\u0438\u0432\u0430\u044e\u0442.<\/p>\n<p><strong>\u041f\u0440\u0438\u0447\u0438\u043d\u0430 3: \u0410\u043b\u043b\u043e\u043a\u0430\u0446\u0438\u0438 \u0432 \u0433\u043e\u0440\u044f\u0447\u0435\u043c \u043f\u0443\u0442\u0438<\/strong><\/p>\n<p>\u041a\u0430\u0436\u0434\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 <code>new double[100000]<\/code> \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0445 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u2014 \u044d\u0442\u043e \u0434\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u0430 GC. \u0412 24\/7 \u0441\u0435\u0440\u0432\u0438\u0441\u0435 \u0442\u0430\u043a\u0438\u0435 \u0430\u043b\u043b\u043e\u043a\u0430\u0446\u0438\u0438 \u043d\u0430\u043a\u0430\u043f\u043b\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0442 \u043d\u0435\u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u044b\u0435 \u043f\u0430\u0443\u0437\u044b.<\/p>\n<p><strong>\u0422\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f \u043a \u0440\u0435\u0448\u0435\u043d\u0438\u044e<\/strong><\/p>\n<ul>\n<li>\n<p>\u0411\u0430\u0442\u0447\u0435\u0432\u0430\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430: \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u043c \u043c\u0430\u0441\u0441\u0438\u0432\u044b \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043c\u0430\u0441\u0441\u0438\u0432\u044b \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u0437\u0430 \u043e\u0434\u0438\u043d \u0432\u044b\u0437\u043e\u0432.<\/p>\n<\/li>\n<li>\n<p>Zero-\u0430\u043b\u043b\u043e\u043a\u0430\u0446\u0438\u0438 \u0432 \u0433\u043e\u0440\u044f\u0447\u0435\u043c \u043f\u0443\u0442\u0438: \u0432\u0441\u0435 \u0431\u0443\u0444\u0435\u0440\u044b \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u043a\u043e\u0434.<\/p>\n<\/li>\n<li>\n<p>SIMD-\u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043c\u0430\u0442\u0440\u0438\u0447\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439.<\/p>\n<\/li>\n<li>\n<p>\u0414\u0435\u0442\u0435\u0440\u043c\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0441\u0442\u044c: \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0439 \u0432\u0445\u043e\u0434 \u2192 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0439 \u0432\u044b\u0445\u043e\u0434 (\u0432\u0430\u0436\u043d\u043e \u0434\u043b\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u043e\u043d\u043d\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f).<\/p>\n<\/li>\n<li>\n<p>\u041a\u043e\u043c\u043f\u0430\u043a\u0442\u043d\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445: \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b, \u0430 \u043d\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b.<\/p>\n<\/li>\n<\/ul>\n<h3>\u0420\u0435\u0448\u0435\u043d\u0438\u0435: QuantCore.Net<\/h3>\n<p>QuantCore.Net \u2014 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0434\u043b\u044f .NET 8.0+, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0449\u0430\u044f \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0435 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u044b.<\/p>\n<pre><code class=\"cs\">dotnet add package QuantCore.Net --version 0.1.5<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:87px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0447\u0435\u0442\u044b\u0440\u0451\u0445 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0445 \u043c\u043e\u0434\u0443\u043b\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438.<\/p>\n<h3>\u041c\u043e\u0434\u0443\u043b\u044c 1: Black\u2013Scholes \u0446\u0435\u043d\u043e\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435<\/h3>\n<h4>\u041e\u0434\u0438\u043d\u043e\u0447\u043d\u044b\u0439 \u0440\u0430\u0441\u0447\u0451\u0442 (\u0434\u043b\u044f \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f)<\/h4>\n<pre><code class=\"cs\">using QuantCore.Net;using QuantCore.Net.Pricing;double price = BlackScholes.Price(    type: OptionType.Call,    s: 100.0,      \/\/ \u0441\u043f\u043e\u0442    k: 100.0,      \/\/ \u0441\u0442\u0440\u0430\u0439\u043a    r: 0.03,       \/\/ \u0431\u0435\u0437\u0440\u0438\u0441\u043a\u043e\u0432\u0430\u044f \u0441\u0442\u0430\u0432\u043a\u0430    q: 0.01,       \/\/ \u0434\u0438\u0432\u0438\u0434\u0435\u043d\u0434\u043d\u0430\u044f \u0434\u043e\u0445\u043e\u0434\u043d\u043e\u0441\u0442\u044c    sigma: 0.20,   \/\/ \u0432\u043e\u043b\u0430\u0442\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u044c    t: 0.5         \/\/ \u0432\u0440\u0435\u043c\u044f \u0434\u043e \u044d\u043a\u0441\u043f\u0438\u0440\u0430\u0446\u0438\u0438 (\u0433\u043e\u0434\u044b));\/\/ price = ~7.96<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<h4>\u0411\u0430\u0442\u0447\u0435\u0432\u044b\u0439 \u0440\u0430\u0441\u0447\u0451\u0442 (\u0434\u043b\u044f production)<\/h4>\n<p>\u0421\u0430\u043c\u044b\u0439 \u0432\u0430\u0436\u043d\u044b\u0439 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439: \u043e\u0446\u0435\u043d\u0438\u0442\u044c 100 000 \u043e\u043f\u0446\u0438\u043e\u043d\u043e\u0432 \u0437\u0430 \u043e\u0434\u0438\u043d \u0432\u044b\u0437\u043e\u0432 \u0431\u0435\u0437 \u0430\u043b\u043b\u043e\u043a\u0430\u0446\u0438\u0439.<\/p>\n<pre><code class=\"cs\">int batchSize = 100000;\/\/ \u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b (\u043c\u0430\u0441\u0441\u0438\u0432\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u043f\u0440\u0435\u0434\u0432\u044b\u0434\u0435\u043b\u0435\u043d\u044b)double[] spots = new double[batchSize];double[] strikes = new double[batchSize];double[] rates = new double[batchSize];double[] dividends = new double[batchSize];double[] vols = new double[batchSize];double[] times = new double[batchSize];double[] prices = new double[batchSize];\/\/ ... \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0432\u0445\u043e\u0434\u043d\u044b\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u044b \u0434\u0430\u043d\u043d\u044b\u043c\u0438 ...BlackScholes.PriceBatch(    type: OptionType.Call,    s: spots,    k: strikes,    r: rates,    q: dividends,    sigma: vols,    t: times,    outPrice: prices  \/\/ &lt;- \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u044d\u0442\u043e\u0442 \u043c\u0430\u0441\u0441\u0438\u0432);\/\/ prices[i] \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0446\u0435\u043d\u0443 i-\u0433\u043e \u043e\u043f\u0446\u0438\u043e\u043d\u0430<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p><strong>\u041a\u043b\u044e\u0447\u0435\u0432\u0430\u044f \u0434\u0435\u0442\u0430\u043b\u044c:<\/strong> <code>outPrice<\/code> \u2014 \u044d\u0442\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440, \u0430 \u043d\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435. \u0412\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u0442\u0435 \u0441\u0432\u043e\u0439 \u043c\u0430\u0441\u0441\u0438\u0432, \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0435\u0433\u043e \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u0442. \u041d\u0438 \u043e\u0434\u043d\u043e\u0439 \u0430\u043b\u043b\u043e\u043a\u0430\u0446\u0438\u0438 \u0432\u043d\u0443\u0442\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0430.<\/p>\n<h4>\u0411\u0430\u0442\u0447\u0435\u0432\u044b\u0435 \u0433\u0440\u0435\u043a\u0438<\/h4>\n<pre><code class=\"cs\">\/\/ \u041c\u0430\u0441\u0441\u0438\u0432 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440 Greeks (\u0434\u0435\u043b\u044c\u0442\u0430, \u0433\u0430\u043c\u043c\u0430, \u0432\u0435\u0433\u0430, \u0442\u0435\u0442\u0430, \u0440\u043e)Greeks[] greeks = new Greeks[batchSize];BlackScholes.GreeksBatch(    type: OptionType.Put,    s: spots,    k: strikes,    r: rates,    q: dividends,    sigma: vols,    t: times,    outGreeks: greeks);\/\/ \u0414\u043e\u0441\u0442\u0443\u043f \u043a \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043cfor (int i = 0; i &lt; batchSize; i++){    double delta = greeks[i].Delta;    double gamma = greeks[i].Gamma;    double vega = greeks[i].Vega;    \/\/ ...}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<h3>\u041c\u043e\u0434\u0443\u043b\u044c 2: Monte Carlo \u0434\u043b\u044f \u0435\u0432\u0440\u043e\u043f\u0435\u0439\u0441\u043a\u0438\u0445 \u043e\u043f\u0446\u0438\u043e\u043d\u043e\u0432<\/h3>\n<p>\u041a\u043e\u0433\u0434\u0430 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0444\u043e\u0440\u043c\u0443\u043b\u044b \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u0443\u0441\u043b\u043e\u0432\u0438\u0439), \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0441\u0438\u043c\u0443\u043b\u044f\u0446\u0438\u044f.<\/p>\n<pre><code class=\"cs\">using QuantCore.Net.MonteCarlo;double mcPrice = MonteCarloOptionPricing.PriceEuropeanGbmAntithetic(    type: OptionType.Call,    s: 100.0,    k: 100.0,    r: 0.03,    q: 0.01,    sigma: 0.20,    t: 0.5,    paths: 10000,    seed: 12345        \/\/ \u0434\u0435\u0442\u0435\u0440\u043c\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440);<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p><strong>\u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438:<\/strong><\/p>\n<ul>\n<li>\n<p>\u0410\u043d\u0442\u0438\u0442\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u044e\u0442 \u0434\u0438\u0441\u043f\u0435\u0440\u0441\u0438\u044e \u0431\u0435\u0437 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u044f \u0447\u0438\u0441\u043b\u0430 \u043f\u0443\u0442\u0435\u0439.<\/p>\n<\/li>\n<li>\n<p>\u0413\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 XorShift128Plus \u0434\u0430\u0451\u0442 \u0434\u0435\u0442\u0435\u0440\u043c\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043f\u0440\u0438 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e\u043c seed.<\/p>\n<\/li>\n<li>\n<p>\u042d\u0442\u043e \u0432\u0430\u0436\u043d\u043e \u0434\u043b\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u043e\u043d\u043d\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f: \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u043a\u043e\u0434\u0430 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0441 \u044d\u0442\u0430\u043b\u043e\u043d\u043e\u043c.<\/p>\n<\/li>\n<\/ul>\n<h3>\u041c\u043e\u0434\u0443\u043b\u044c 3: \u0418\u0441\u0442\u043e\u0440\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0440\u0438\u0441\u043a (VaR \u0438 Expected Shortfall)<\/h3>\n<p>\u0414\u043b\u044f \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0438\u0441\u0442\u043e\u0440\u0438\u0447\u0435\u0441\u043a\u0438\u0445 PnL (\u043f\u0440\u0438\u0431\u044b\u043b\u0435\u0439 \u0438 \u0443\u0431\u044b\u0442\u043a\u043e\u0432) \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 \u0440\u0438\u0441\u043a-\u043c\u0435\u0442\u0440\u0438\u043a\u0438.<\/p>\n<pre><code class=\"cs\">using QuantCore.Net.Risk;double[] dailyPnl = LoadHistoricalPnl(); \/\/ \u043c\u0430\u0441\u0441\u0438\u0432 \u0434\u043d\u0435\u0432\u043d\u044b\u0445 PnL\/\/ Value at Risk \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 99%double var99 = HistoricalRisk.ValueAtRisk(dailyPnl, alpha: 0.99);\/\/ Expected Shortfall (CVaR) \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 99%double es99 = HistoricalRisk.ExpectedShortfall(dailyPnl, alpha: 0.99);<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<h4>Zero-\u0430\u043b\u043b\u043e\u043a\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 (\u0441 \u043f\u0443\u043b\u043e\u043c \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432)<\/h4>\n<p>\u0412\u043d\u0443\u0442\u0440\u0438 <code>ValueAtRisk<\/code> \u043e\u0431\u044b\u0447\u043d\u043e \u0441\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u0442 \u043c\u0430\u0441\u0441\u0438\u0432 PnL. \u0421\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u0442 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432. \u0415\u0441\u043b\u0438 \u0432\u044b \u043d\u0435 \u0445\u043e\u0442\u0438\u0442\u0435 \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u0438\u043b\u0438 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043a\u043e\u043f\u0438\u044e, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 overload \u0441 <code>ArrayPool<\/code>:<\/p>\n<pre><code class=\"cs\">double var99 = HistoricalRisk.ValueAtRisk(dailyPnl, alpha: 0.99, usePool: true);\/\/ \u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0430\u0440\u0435\u043d\u0434\u0443\u0435\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u0438\u0437 \u043f\u0443\u043b\u0430, \u0441\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u0442 \u0435\u0433\u043e,\/\/ \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0432 \u043f\u0443\u043b \u043f\u043e\u0441\u043b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f. \u0410\u043b\u043b\u043e\u043a\u0430\u0446\u0438\u044f \u2014 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u043c \u0432\u044b\u0437\u043e\u0432\u0435.<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0434\u043b\u044f Expected Shortfall:<\/p>\n<pre><code class=\"cs\">double es99 = HistoricalRisk.ExpectedShortfall(dailyPnl, alpha: 0.99, usePool: true);<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<h3>\u041c\u043e\u0434\u0443\u043b\u044c 4: \u0424\u0430\u043a\u0442\u043e\u0440\u043d\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c PnL (SIMD)<\/h3>\n<p>\u0412 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u043c \u0430\u043d\u0430\u043b\u0438\u0437\u0435 \u0447\u0430\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0430\u043f\u043f\u0440\u043e\u043a\u0441\u0438\u043c\u0430\u0446\u0438\u044f:<\/p>\n<p><strong>PnL \u2248 \u03a3(\u044d\u043a\u0441\u043f\u043e\u0437\u0438\u0446\u0438\u044f_\u0444\u0430\u043a\u0442\u043e\u0440 \u00d7 \u0434\u043e\u0445\u043e\u0434\u043d\u043e\u0441\u0442\u044c_\u0444\u0430\u043a\u0442\u043e\u0440\u0430) \u00d7 \u043d\u043e\u043c\u0438\u043d\u0430\u043b<\/strong><\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, 100 000 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432, 32 \u0444\u0430\u043a\u0442\u043e\u0440\u0430 (\u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043d\u044b\u0435 \u0441\u0442\u0430\u0432\u043a\u0438, \u0432\u0430\u043b\u044e\u0442\u043d\u044b\u0435 \u043a\u0443\u0440\u0441\u044b, \u0446\u0435\u043d\u044b \u0441\u044b\u0440\u044c\u044f \u0438 \u0442.\u0434.).<\/p>\n<pre><code class=\"cs\">using QuantCore.Net.Risk;using SlidingRank.FastOps;int instruments = 100000;int factors = 32;\/\/ \u041c\u0430\u0442\u0440\u0438\u0446\u0430 \u044d\u043a\u0441\u043f\u043e\u0437\u0438\u0446\u0438\u0439: instruments \u00d7 factors (row-major)float[] exposures = new float[instruments * factors];\/\/ \u0412\u0435\u043a\u0442\u043e\u0440 \u0444\u0430\u043a\u0442\u043e\u0440\u043d\u044b\u0445 \u0434\u043e\u0445\u043e\u0434\u043d\u043e\u0441\u0442\u0435\u0439float[] factorReturns = new float[factors];\/\/ \u041d\u043e\u043c\u0438\u043d\u0430\u043b\u044b \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432float[] notionals = new float[instruments];\/\/ \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442: PnL \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430float[] pnl = new float[instruments];\/\/ ... \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0432\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 ...FactorModelPnlFast.ComputePnL(    exposures: exposures,    factorReturns: factorReturns,    notionals: notionals,    outPnl: pnl);<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0412\u043d\u0443\u0442\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f SIMD-\u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435 \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u043d\u0430 \u0432\u0435\u043a\u0442\u043e\u0440 \u0447\u0435\u0440\u0435\u0437 <code>SlidingRank.FastOps<\/code>. \u0414\u043b\u044f 100 000 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0438 32 \u0444\u0430\u043a\u0442\u043e\u0440\u043e\u0432 \u2014 <strong>~2.77 \u043c\u0441<\/strong>.<\/p>\n<h3>\u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c<\/h3>\n<p>\u0422\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u0441\u0442\u0435\u043d\u0434: <strong>Intel Core i5-11400F (6 \u044f\u0434\u0435\u0440, 12 \u043f\u043e\u0442\u043e\u043a\u043e\u0432), Windows 11, .NET 8.0, BenchmarkDotNet 0.15.8<\/strong><\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>\n<p align=\"left\">\u041c\u0435\u0442\u043e\u0434<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u0420\u0430\u0437\u043c\u0435\u0440 \u0431\u0430\u0442\u0447\u0430<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u0421\u0440\u0435\u0434\u043d\u0435\u0435 \u0432\u0440\u0435\u043c\u044f<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u041f\u0440\u043e\u043f\u0443\u0441\u043a\u043d\u0430\u044f \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u044c<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>BlackScholes.PriceBatch<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">100 000<\/p>\n<\/td>\n<td>\n<p align=\"left\">5.12 ms<\/p>\n<\/td>\n<td>\n<p align=\"left\"><strong>~19.5 \u043c\u043b\u043d \u043e\u043f\u0446\u0438\u043e\u043d\u043e\u0432\/\u0441\u0435\u043a<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>BlackScholes.GreeksBatch<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">100 000<\/p>\n<\/td>\n<td>\n<p align=\"left\">10.43 ms<\/p>\n<\/td>\n<td>\n<p align=\"left\"><strong>~9.6 \u043c\u043b\u043d \u043e\u043f\u0446\u0438\u043e\u043d\u043e\u0432\/\u0441\u0435\u043a<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>MonteCarlo.EuropeanGBM<\/code><\/p>\n<\/td>\n<td>\n<p align=\"left\">10 000 \u043f\u0443\u0442\u0435\u0439<\/p>\n<\/td>\n<td>\n<p align=\"left\">0.264 ms<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u2014<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>HistoricalRisk.ValueAtRisk<\/code> (usePool)<\/p>\n<\/td>\n<td>\n<p align=\"left\">100 000<\/p>\n<\/td>\n<td>\n<p align=\"left\">0.44 ms<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u2014<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>HistoricalRisk.ExpectedShortfall<\/code> (usePool)<\/p>\n<\/td>\n<td>\n<p align=\"left\">100 000<\/p>\n<\/td>\n<td>\n<p align=\"left\">0.487 ms<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u2014<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>FactorModelPnL<\/code> (32 \u0444\u0430\u043a\u0442\u043e\u0440\u0430)<\/p>\n<\/td>\n<td>\n<p align=\"left\">100 000<\/p>\n<\/td>\n<td>\n<p align=\"left\">2.77 ms<\/p>\n<\/td>\n<td>\n<p align=\"left\"><strong>36 \u043c\u043b\u043d \u00ab\u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u00d7\u0444\u0430\u043a\u0442\u043e\u0440\u00bb\/\u0441\u0435\u043a<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>FactorModelPnL<\/code> (64 \u0444\u0430\u043a\u0442\u043e\u0440\u0430)<\/p>\n<\/td>\n<td>\n<p align=\"left\">100 000<\/p>\n<\/td>\n<td>\n<p align=\"left\">5.04 ms<\/p>\n<\/td>\n<td>\n<p align=\"left\"><strong>1.27 \u043c\u043b\u0440\u0434 \u00ab\u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u00d7\u0444\u0430\u043a\u0442\u043e\u0440\u00bb\/\u0441\u0435\u043a<\/strong><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p><strong>\u041f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0441\u043c\u044b\u0441\u043b:<\/strong> \u043f\u043e\u0440\u0442\u0444\u0435\u043b\u044c \u0438\u0437 200 000 \u043e\u043f\u0446\u0438\u043e\u043d\u043e\u0432 \u043f\u0435\u0440\u0435\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0437\u0430 ~10\u201320 \u043c\u0441. \u042d\u0442\u043e \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0437\u0430\u043f\u0430\u0441 \u043d\u0430 \u0441\u0435\u0442\u044c, \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u043d\u0430\u043a\u043b\u0430\u0434\u043d\u044b\u0435 \u0440\u0430\u0441\u0445\u043e\u0434\u044b \u0434\u0430\u0436\u0435 \u043f\u0440\u0438 \u0436\u0451\u0441\u0442\u043a\u043e\u043c SLA \u0432 50 \u043c\u0441.<\/p>\n<h3>\u041f\u043e\u0448\u0430\u0433\u043e\u0432\u0430\u044f \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044f \u0432 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u043f\u0440\u043e\u0435\u043a\u0442<\/h3>\n<h4>\u0428\u0430\u0433 1. \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430<\/h4>\n<pre><code class=\"cs\">dotnet add package QuantCore.Net --version 0.1.5<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<h4>\u0428\u0430\u0433 2. \u041f\u0440\u0435\u0434\u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0431\u0443\u0444\u0435\u0440\u043e\u0432 (\u043e\u0434\u0438\u043d \u0440\u0430\u0437 \u043f\u0440\u0438 \u0441\u0442\u0430\u0440\u0442\u0435)<\/h4>\n<pre><code class=\"cs\">public class PricingService{    private readonly double[] _spots;    private readonly double[] _strikes;    private readonly double[] _rates;    private readonly double[] _dividends;    private readonly double[] _vols;    private readonly double[] _times;    private readonly double[] _prices;    private readonly Greeks[] _greeks;    public PricingService(int maxBatchSize)    {        _spots = new double[maxBatchSize];        _strikes = new double[maxBatchSize];        _rates = new double[maxBatchSize];        _dividends = new double[maxBatchSize];        _vols = new double[maxBatchSize];        _times = new double[maxBatchSize];        _prices = new double[maxBatchSize];        _greeks = new Greeks[maxBatchSize];    }        \/\/ ...}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<h4>\u0428\u0430\u0433 3. \u0417\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445<\/h4>\n<pre><code class=\"cs\">public void LoadPortfolio(Portfolio portfolio){    for (int i = 0; i &lt; portfolio.Instruments.Count; i++)    {        var opt = portfolio.Instruments[i];        _spots[i] = opt.Spot;        _strikes[i] = opt.Strike;        _rates[i] = opt.RiskFreeRate;        _dividends[i] = opt.DividendYield;        _vols[i] = opt.ImpliedVolatility;        _times[i] = opt.TimeToExpiry;    }}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<h4>\u0428\u0430\u0433 4. \u0412\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0440\u0430\u0441\u0447\u0451\u0442\u0430<\/h4>\n<pre><code class=\"cs\">public double[] CalculatePrices(){    BlackScholes.PriceBatch(        type: OptionType.Call,        s: _spots,        k: _strikes,        r: _rates,        q: _dividends,        sigma: _vols,        t: _times,        outPrice: _prices    );        return _prices;}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<h4>\u0428\u0430\u0433 5. \u041f\u043e\u043b\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440: \u0441\u0435\u0440\u0432\u0438\u0441 \u043f\u0435\u0440\u0435\u043e\u0446\u0435\u043d\u043a\u0438 \u043f\u043e\u0440\u0442\u0444\u0435\u043b\u044f<\/h4>\n<pre><code class=\"cs\">public class PortfolioRevaluationService{    private readonly PricingService _pricing;    private readonly RiskCalculator _risk;        public async Task&lt;PortfolioMetrics&gt; Revaluate(Portfolio portfolio)    {        \/\/ 1. \u0426\u0435\u043d\u044b \u0438 \u0433\u0440\u0435\u043a\u0438        var prices = _pricing.CalculatePrices(portfolio.Options);        var greeks = _pricing.CalculateGreeks(portfolio.Options);                \/\/ 2. PnL \u043f\u043e \u0444\u0430\u043a\u0442\u043e\u0440\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438        var factorPnl = _risk.CalculateFactorPnL(portfolio.Exposures);                \/\/ 3. Risk metrics        var var95 = HistoricalRisk.ValueAtRisk(portfolio.HistoricalPnl, 0.95);        var es95 = HistoricalRisk.ExpectedShortfall(portfolio.HistoricalPnl, 0.95);                return new PortfolioMetrics        {            TotalValue = prices.Sum(),            WeightedDelta = greeks.Sum(g =&gt; g.Delta),            WeightedGamma = greeks.Sum(g =&gt; g.Gamma),            VaR95 = var95,            ES95 = es95        };    }}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<h3>\u041a\u043e\u0433\u0434\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c, \u0430 \u043a\u043e\u0433\u0434\u0430 \u043d\u0435\u0442<\/h3>\n<p><strong>\u041f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f:<\/strong><\/p>\n<ul>\n<li>\n<p>\u0412\u044b\u0441\u043e\u043a\u043e\u0447\u0430\u0441\u0442\u043e\u0442\u043d\u0430\u044f \u043f\u0435\u0440\u0435\u043e\u0446\u0435\u043d\u043a\u0430 \u043f\u043e\u0440\u0442\u0444\u0435\u043b\u0435\u0439 (\u0440\u0438\u0441\u043a-\u043c\u0435\u043d\u0435\u0434\u0436\u043c\u0435\u043d\u0442, \u043c\u0430\u0440\u0436\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435)<\/p>\n<\/li>\n<li>\n<p>\u0411\u0430\u0442\u0447\u0435\u0432\u044b\u0435 \u0440\u0430\u0441\u0447\u0451\u0442\u044b \u0432 \u0442\u043e\u0440\u0433\u043e\u0432\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445<\/p>\n<\/li>\n<li>\n<p>\u0420\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u043e\u043d\u043d\u043e\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 quantitative-\u043c\u043e\u0434\u0435\u043b\u0435\u0439 (\u0434\u0435\u0442\u0435\u0440\u043c\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 MC)<\/p>\n<\/li>\n<li>\n<p>\u0412\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u043d\u0438\u0435 \u0432 .NET-\u0441\u0435\u0440\u0432\u0438\u0441\u044b \u0431\u0435\u0437 \u0432\u043d\u0435\u0448\u043d\u0438\u0445 C++ \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439<\/p>\n<\/li>\n<\/ul>\n<p><strong>\u041d\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f:<\/strong><\/p>\n<ul>\n<li>\n<p>\u042d\u043a\u0437\u043e\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043e\u043f\u0446\u0438\u043e\u043d\u043e\u0432 \u0441 \u0431\u0430\u0440\u044c\u0435\u0440\u0430\u043c\u0438, \u043e\u0442\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u043c\u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u044f\u043c\u0438 \u0438 \u0442.\u0434. (\u043d\u0443\u0436\u043d\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435)<\/p>\n<\/li>\n<li>\n<p>\u0418\u043d\u0442\u0435\u0440\u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0445 Excel-\u043d\u0430\u0434\u0441\u0442\u0440\u043e\u0435\u043a \u0441 \u0442\u044b\u0441\u044f\u0447\u0430\u043c\u0438 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 (\u043b\u0443\u0447\u0448\u0435 \u0431\u0430\u0442\u0447\u0435\u0432\u044b\u0439 API)<\/p>\n<\/li>\n<li>\n<p>\u0421\u0438\u0442\u0443\u0430\u0446\u0438\u0439, \u0433\u0434\u0435 \u043d\u0443\u0436\u043d\u0430 double-\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u0434\u043b\u044f \u044d\u043a\u0441\u0442\u0440\u0435\u043c\u0430\u043b\u044c\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0447\u0438\u0441\u0435\u043b (\u043d\u043e float \u0438 \u0442\u0430\u043a \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e \u0434\u043b\u044f \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0430 risk-\u043c\u0435\u0442\u0440\u0438\u043a)<\/p>\n<\/li>\n<\/ul>\n<p><strong>\u0411\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u043e\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 <\/strong>\u2014 \u0434\u043b\u044f \u043e\u0446\u0435\u043d\u043a\u0438 \u0438 \u043d\u0435\u043a\u043e\u043c\u043c\u0435\u0440\u0447\u0435\u0441\u043a\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432. \u041a\u043e\u043c\u043c\u0435\u0440\u0447\u0435\u0441\u043a\u043e\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043f\u043e\u043a\u0443\u043f\u043a\u0438 \u043b\u0438\u0446\u0435\u043d\u0437\u0438\u0438.<\/p>\n<h3>\u0413\u0434\u0435 \u0432\u0437\u044f\u0442\u044c<\/h3>\n<p><strong>NuGet:<\/strong> <code>dotnet add package QuantCore.Net<\/code><\/p>\n<p><strong>Github<\/strong> (\u0431\u0435\u043d\u0447\u043c\u0430\u0440\u043a\u0438 \u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u044b) &#8212; <a href=\"https:\/\/github.com\/likeslines-maker\/QuantCore.Net\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/likeslines-maker\/QuantCore.Net<\/a><\/p>\n<p>QuantCore.Net \u2014 \u044d\u0442\u043e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0434\u043b\u044f \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0445 \u0440\u0430\u0441\u0447\u0451\u0442\u043e\u0432 \u043d\u0430 .NET, \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u0430\u044f \u0432\u043e\u043a\u0440\u0443\u0433 \u0442\u0440\u0451\u0445 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u043e\u0432: \u0431\u0430\u0442\u0447\u0435\u0432\u043e\u0441\u0442\u044c, zero-\u0430\u043b\u043b\u043e\u043a\u0430\u0446\u0438\u0438, SIMD.<\/p>\n<p>\u041e\u043d\u0430 \u043d\u0435 \u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u044b\u0435 quantitative-\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0432\u0440\u043e\u0434\u0435 QuantLib. \u041e\u043d\u0430 \u0440\u0435\u0448\u0430\u0435\u0442 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u0443\u044e \u0443\u0437\u043a\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443: \u0431\u044b\u0441\u0442\u0440\u043e\u0435 in-process \u0446\u0435\u043d\u043e\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435, \u0440\u0438\u0441\u043a-\u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u0438 \u0444\u0430\u043a\u0442\u043e\u0440\u043d\u044b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u043b\u044f \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043f\u043e\u0440\u0442\u0444\u0435\u043b\u0435\u0439.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0430\u0448 \u0440\u0438\u0441\u043a-\u0441\u0435\u0440\u0432\u0438\u0441 \u0442\u043e\u0440\u043c\u043e\u0437\u0438\u0442 \u043d\u0430 \u043f\u043e\u0440\u0442\u0444\u0435\u043b\u0435 \u0438\u0437 50 000 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u2014 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0439\u0442\u0435 QuantCore.Net. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0432\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u0447\u0438\u0442\u0430\u043b\u0438 \u043d\u0435 \u0442\u0435\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c.<\/p>\n<\/div>\n<p>\u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/1040914\/\">https:\/\/habr.com\/ru\/articles\/1040914\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0424\u0438\u043d\u0430\u043d\u0441\u043e\u0432\u044b\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043f\u0440\u0435\u0434\u044a\u044f\u0432\u043b\u044f\u044e\u0442 \u0436\u0451\u0441\u0442\u043a\u0438\u0435 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f \u043a \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438.\u0420\u0438\u0441\u043a-\u0434\u0435\u043f\u0430\u0440\u0442\u0430\u043c\u0435\u043d\u0442 \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u043e\u0446\u0435\u043d\u043a\u0443 \u043f\u043e\u0440\u0442\u0444\u0435\u043b\u044f \u0438\u0437 200 000 \u043e\u043f\u0446\u0438\u043e\u043d\u043e\u0432. \u041c\u0430\u0440\u0436\u0438\u043d\u0430\u043b\u044c\u043d\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043f\u0435\u0440\u0435\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0432\u0441\u0435 \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u043f\u043e\u0441\u043b\u0435 \u0441\u0438\u043b\u044c\u043d\u043e\u0433\u043e \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f \u0440\u044b\u043d\u043a\u0430. \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0442\u0440\u0435\u0439\u0434\u0435\u0440 \u0445\u043e\u0447\u0435\u0442 \u043e\u0446\u0435\u043d\u0438\u0442\u044c Greeks \u0434\u043b\u044f \u0442\u044b\u0441\u044f\u0447 \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u0441\u0434\u0435\u043b\u043e\u043a \u0437\u0430 \u043c\u0438\u043b\u043b\u0438\u0441\u0435\u043a\u0443\u043d\u0434\u044b.\u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044b \u043d\u0430 .NET \u0434\u0430\u044e\u0442 \u0441\u0431\u043e\u0439 \u043f\u043e \u0442\u0440\u0451\u043c \u043f\u0440\u0438\u0447\u0438\u043d\u0430\u043c.\u041f\u0440\u0438\u0447\u0438\u043d\u0430 1: \u041e\u0431\u044a\u0435\u043a\u0442\u043d\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c\u041a\u0430\u0436\u0434\u044b\u0439 \u043e\u043f\u0446\u0438\u043e\u043d \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u043c \u0432 \u043a\u0443\u0447\u0435. \u0412\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b, \u0441\u0441\u044b\u043b\u043a\u0438, \u0440\u0430\u0437\u0440\u043e\u0437\u043d\u0435\u043d\u043d\u043e\u0435 \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438. \u0414\u043b\u044f 200 000 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u2014 \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u044b \u0431\u0430\u0439\u0442\u043e\u0432, GC-\u043f\u0430\u0443\u0437\u044b \u043d\u0430 \u0441\u0431\u043e\u0440\u043a\u0443, \u043f\u0440\u043e\u043c\u0430\u0445\u0438 \u043a\u044d\u0448\u0430 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430.\u041f\u0440\u0438\u0447\u0438\u043d\u0430 2: \u041f\u043e\u0437\u043b\u0435\u043c\u0435\u043d\u0442\u043d\u044b\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f\u0412\u044b\u0437\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0446\u0435\u043d\u043e\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0432 \u0446\u0438\u043a\u043b\u0435 \u2014 \u043f\u043b\u043e\u0445\u043e. \u041f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0432\u0435\u043a\u0442\u043e\u0440\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u0434, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043d\u0435 \u0432\u0438\u0434\u0438\u0442 \u0432\u0441\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u0443 \u0446\u0435\u043b\u0438\u043a\u043e\u043c. SIMD-\u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u043f\u0440\u043e\u0441\u0442\u0430\u0438\u0432\u0430\u044e\u0442.\u041f\u0440\u0438\u0447\u0438\u043d\u0430 3: \u0410\u043b\u043b\u043e\u043a\u0430\u0446\u0438\u0438 \u0432 \u0433\u043e\u0440\u044f\u0447\u0435\u043c \u043f\u0443\u0442\u0438\u041a\u0430\u0436\u0434\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 new double[100000] \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0445 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u2014 \u044d\u0442\u043e \u0434\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u0430 GC. \u0412 24\/7 \u0441\u0435\u0440\u0432\u0438\u0441\u0435 \u0442\u0430\u043a\u0438\u0435 \u0430\u043b\u043b\u043e\u043a\u0430\u0446\u0438\u0438 \u043d\u0430\u043a\u0430\u043f\u043b\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0442 \u043d\u0435\u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u044b\u0435 \u043f\u0430\u0443\u0437\u044b.\u0422\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f \u043a \u0440\u0435\u0448\u0435\u043d\u0438\u044e\u0411\u0430\u0442\u0447\u0435\u0432\u0430\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430: \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u043c \u043c\u0430\u0441\u0441\u0438\u0432\u044b \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043c\u0430\u0441\u0441\u0438\u0432\u044b \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u0437\u0430 \u043e\u0434\u0438\u043d \u0432\u044b\u0437\u043e\u0432.Zero-\u0430\u043b\u043b\u043e\u043a\u0430\u0446\u0438\u0438 \u0432 \u0433\u043e\u0440\u044f\u0447\u0435\u043c \u043f\u0443\u0442\u0438: \u0432\u0441\u0435 \u0431\u0443\u0444\u0435\u0440\u044b \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u043a\u043e\u0434.SIMD-\u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043c\u0430\u0442\u0440\u0438\u0447\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439.\u0414\u0435\u0442\u0435\u0440\u043c\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0441\u0442\u044c: \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0439 \u0432\u0445\u043e\u0434 \u2192 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0439 \u0432\u044b\u0445\u043e\u0434 (\u0432\u0430\u0436\u043d\u043e \u0434\u043b\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u043e\u043d\u043d\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f).\u041a\u043e\u043c\u043f\u0430\u043a\u0442\u043d\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445: \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b, \u0430 \u043d\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b.\u0420\u0435\u0448\u0435\u043d\u0438\u0435: QuantCore.NetQuantCore.Net \u2014 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0434\u043b\u044f .NET 8.0+, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0449\u0430\u044f \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0435 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u044b.dotnet add package QuantCore.Net &#8212;version 0.1.5\u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0447\u0435\u0442\u044b\u0440\u0451\u0445 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0445 \u043c\u043e\u0434\u0443\u043b\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438.\u041c\u043e\u0434\u0443\u043b\u044c 1: Black\u2013Scholes \u0446\u0435\u043d\u043e\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u041e\u0434\u0438\u043d\u043e\u0447\u043d\u044b\u0439 \u0440\u0430\u0441\u0447\u0451\u0442 (\u0434\u043b\u044f \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f)using QuantCore.Net;using QuantCore.Net.Pricing;double price = BlackScholes.Price(    type: OptionType.Call,    s: 100.0,      \/\/ \u0441\u043f\u043e\u0442    k: 100.0,      \/\/ \u0441\u0442\u0440\u0430\u0439\u043a    r: 0.03,       \/\/ \u0431\u0435\u0437\u0440\u0438\u0441\u043a\u043e\u0432\u0430\u044f \u0441\u0442\u0430\u0432\u043a\u0430    q: 0.01,       \/\/ \u0434\u0438\u0432\u0438\u0434\u0435\u043d\u0434\u043d\u0430\u044f \u0434\u043e\u0445\u043e\u0434\u043d\u043e\u0441\u0442\u044c    sigma: 0.20,   \/\/ \u0432\u043e\u043b\u0430\u0442\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u044c    t: 0.5         \/\/ \u0432\u0440\u0435\u043c\u044f \u0434\u043e \u044d\u043a\u0441\u043f\u0438\u0440\u0430\u0446\u0438\u0438 (\u0433\u043e\u0434\u044b));\/\/ price = ~7.96\u0411\u0430\u0442\u0447\u0435\u0432\u044b\u0439 \u0440\u0430\u0441\u0447\u0451\u0442 (\u0434\u043b\u044f production)\u0421\u0430\u043c\u044b\u0439 \u0432\u0430\u0436\u043d\u044b\u0439 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439: \u043e\u0446\u0435\u043d\u0438\u0442\u044c 100 000 \u043e\u043f\u0446\u0438\u043e\u043d\u043e\u0432 \u0437\u0430 \u043e\u0434\u0438\u043d \u0432\u044b\u0437\u043e\u0432 \u0431\u0435\u0437 \u0430\u043b\u043b\u043e\u043a\u0430\u0446\u0438\u0439.int batchSize = 100000;\/\/ \u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b (\u043c\u0430\u0441\u0441\u0438\u0432\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u043f\u0440\u0435\u0434\u0432\u044b\u0434\u0435\u043b\u0435\u043d\u044b)double[] spots = new double[batchSize];double[] strikes = new double[batchSize];double[] rates = new double[batchSize];double[] dividends = new double[batchSize];double[] vols = new double[batchSize];double[] times = new double[batchSize];double[] prices = new double[batchSize];\/\/ &#8230; \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0432\u0445\u043e\u0434\u043d\u044b\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u044b \u0434\u0430\u043d\u043d\u044b\u043c\u0438 &#8230;BlackScholes.PriceBatch(    type: OptionType.Call,    s: spots,    k: strikes,    r: rates,    q: dividends,    sigma: vols,    t: times,    outPrice: prices  \/\/ &lt;- \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u044d\u0442\u043e\u0442 \u043c\u0430\u0441\u0441\u0438\u0432);\/\/ prices[i] \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0446\u0435\u043d\u0443 i-\u0433\u043e \u043e\u043f\u0446\u0438\u043e\u043d\u0430\u041a\u043b\u044e\u0447\u0435\u0432\u0430\u044f \u0434\u0435\u0442\u0430\u043b\u044c: outPrice \u2014 \u044d\u0442\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440, \u0430 \u043d\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435. \u0412\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u0442\u0435 \u0441\u0432\u043e\u0439 \u043c\u0430\u0441\u0441\u0438\u0432, \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0435\u0433\u043e \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u0442. \u041d\u0438 \u043e\u0434\u043d\u043e\u0439 \u0430\u043b\u043b\u043e\u043a\u0430\u0446\u0438\u0438 \u0432\u043d\u0443\u0442\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0430.\u0411\u0430\u0442\u0447\u0435\u0432\u044b\u0435 \u0433\u0440\u0435\u043a\u0438\/\/ \u041c\u0430\u0441\u0441\u0438\u0432 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440 Greeks (\u0434\u0435\u043b\u044c\u0442\u0430, \u0433\u0430\u043c\u043c\u0430, \u0432\u0435\u0433\u0430, \u0442\u0435\u0442\u0430, \u0440\u043e)Greeks[] greeks = new Greeks[batchSize];BlackScholes.GreeksBatch(    type: OptionType.Put,    s: spots,    k: strikes,    r: rates,    q: dividends,    sigma: vols,    t: times,    outGreeks: greeks);\/\/ \u0414\u043e\u0441\u0442\u0443\u043f \u043a \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043cfor (int i = 0; i &lt; batchSize; i++){    double delta = greeks[i].Delta;    double gamma = greeks[i].Gamma;    double vega = greeks[i].Vega;    \/\/ &#8230;}\u041c\u043e\u0434\u0443\u043b\u044c 2: Monte Carlo \u0434\u043b\u044f \u0435\u0432\u0440\u043e\u043f\u0435\u0439\u0441\u043a\u0438\u0445 \u043e\u043f\u0446\u0438\u043e\u043d\u043e\u0432\u041a\u043e\u0433\u0434\u0430 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0444\u043e\u0440\u043c\u0443\u043b\u044b \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u0443\u0441\u043b\u043e\u0432\u0438\u0439), \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0441\u0438\u043c\u0443\u043b\u044f\u0446\u0438\u044f.using QuantCore.Net.MonteCarlo;double mcPrice = MonteCarloOptionPricing.PriceEuropeanGbmAntithetic(    type: OptionType.Call,    s: 100.0,    k: 100.0,    r: 0.03,    q: 0.01,    sigma: 0.20,    t: 0.5,    paths: 10000,    seed: 12345        \/\/ \u0434\u0435\u0442\u0435\u0440\u043c\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440);\u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438:\u0410\u043d\u0442\u0438\u0442\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u044e\u0442 \u0434\u0438\u0441\u043f\u0435\u0440\u0441\u0438\u044e \u0431\u0435\u0437 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u044f \u0447\u0438\u0441\u043b\u0430 \u043f\u0443\u0442\u0435\u0439.\u0413\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 XorShift128Plus \u0434\u0430\u0451\u0442 \u0434\u0435\u0442\u0435\u0440\u043c\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043f\u0440\u0438 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e\u043c seed.\u042d\u0442\u043e \u0432\u0430\u0436\u043d\u043e \u0434\u043b\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u043e\u043d\u043d\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f: \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u043a\u043e\u0434\u0430 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0441 \u044d\u0442\u0430\u043b\u043e\u043d\u043e\u043c.\u041c\u043e\u0434\u0443\u043b\u044c 3: \u0418\u0441\u0442\u043e\u0440\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0440\u0438\u0441\u043a (VaR \u0438 Expected Shortfall)\u0414\u043b\u044f \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0438\u0441\u0442\u043e\u0440\u0438\u0447\u0435\u0441\u043a\u0438\u0445 PnL (\u043f\u0440\u0438\u0431\u044b\u043b\u0435\u0439 \u0438 \u0443\u0431\u044b\u0442\u043a\u043e\u0432) \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 \u0440\u0438\u0441\u043a-\u043c\u0435\u0442\u0440\u0438\u043a\u0438.using QuantCore.Net.Risk;double[] dailyPnl = LoadHistoricalPnl(); \/\/ \u043c\u0430\u0441\u0441\u0438\u0432 \u0434\u043d\u0435\u0432\u043d\u044b\u0445 PnL\/\/ Value at Risk \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 99%double var99 = HistoricalRisk.ValueAtRisk(dailyPnl, alpha: 0.99);\/\/ Expected Shortfall (CVaR) \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 99%double es99 = HistoricalRisk.ExpectedShortfall(dailyPnl, alpha: 0.99);Zero-\u0430\u043b\u043b\u043e\u043a\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 (\u0441 \u043f\u0443\u043b\u043e\u043c \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432)\u0412\u043d\u0443\u0442\u0440\u0438 ValueAtRisk \u043e\u0431\u044b\u0447\u043d\u043e \u0441\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u0442 \u043c\u0430\u0441\u0441\u0438\u0432 PnL. \u0421\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u0442 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432. \u0415\u0441\u043b\u0438 \u0432\u044b \u043d\u0435 \u0445\u043e\u0442\u0438\u0442\u0435 \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u0438\u043b\u0438 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043a\u043e\u043f\u0438\u044e, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 overload \u0441 ArrayPool:double var99 = HistoricalRisk.ValueAtRisk(dailyPnl, alpha: 0.99, usePool: true);\/\/ \u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0430\u0440\u0435\u043d\u0434\u0443\u0435\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u0438\u0437 \u043f\u0443\u043b\u0430, \u0441\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u0442 \u0435\u0433\u043e,\/\/ \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0432 \u043f\u0443\u043b \u043f\u043e\u0441\u043b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f. \u0410\u043b\u043b\u043e\u043a\u0430\u0446\u0438\u044f \u2014 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u043c \u0432\u044b\u0437\u043e\u0432\u0435.\u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0434\u043b\u044f Expected Shortfall:double es99 = HistoricalRisk.ExpectedShortfall(dailyPnl, alpha: 0.99, usePool: true);\u041c\u043e\u0434\u0443\u043b\u044c 4: \u0424\u0430\u043a\u0442\u043e\u0440\u043d\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c PnL (SIMD)\u0412 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u043c \u0430\u043d\u0430\u043b\u0438\u0437\u0435 \u0447\u0430\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0430\u043f\u043f\u0440\u043e\u043a\u0441\u0438\u043c\u0430\u0446\u0438\u044f:PnL \u2248 \u03a3(\u044d\u043a\u0441\u043f\u043e\u0437\u0438\u0446\u0438\u044f_\u0444\u0430\u043a\u0442\u043e\u0440 \u00d7 \u0434\u043e\u0445\u043e\u0434\u043d\u043e\u0441\u0442\u044c_\u0444\u0430\u043a\u0442\u043e\u0440\u0430) \u00d7 \u043d\u043e\u043c\u0438\u043d\u0430\u043b\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, 100 000 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432, 32 \u0444\u0430\u043a\u0442\u043e\u0440\u0430 (\u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043d\u044b\u0435 \u0441\u0442\u0430\u0432\u043a\u0438, \u0432\u0430\u043b\u044e\u0442\u043d\u044b\u0435 \u043a\u0443\u0440\u0441\u044b, \u0446\u0435\u043d\u044b \u0441\u044b\u0440\u044c\u044f \u0438 \u0442.\u0434.).using QuantCore.Net.Risk;using SlidingRank.FastOps;int instruments = 100000;int factors = 32;\/\/ \u041c\u0430\u0442\u0440\u0438\u0446\u0430 \u044d\u043a\u0441\u043f\u043e\u0437\u0438\u0446\u0438\u0439: instruments \u00d7 factors (row-major)float[] exposures = new float[instruments * factors];\/\/ \u0412\u0435\u043a\u0442\u043e\u0440 \u0444\u0430\u043a\u0442\u043e\u0440\u043d\u044b\u0445 \u0434\u043e\u0445\u043e\u0434\u043d\u043e\u0441\u0442\u0435\u0439float[] factorReturns = new float[factors];\/\/ \u041d\u043e\u043c\u0438\u043d\u0430\u043b\u044b \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432float[] notionals = new float[instruments];\/\/ \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442: PnL \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430float[] pnl = new float[instruments];\/\/ &#8230; \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0432\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 &#8230;FactorModelPnlFast.ComputePnL(    exposures: exposures,    factorReturns: factorReturns,    notionals: notionals,    outPnl: pnl);\u0412\u043d\u0443\u0442\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f SIMD-\u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435 \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u043d\u0430 \u0432\u0435\u043a\u0442\u043e\u0440 \u0447\u0435\u0440\u0435\u0437 SlidingRank.FastOps. \u0414\u043b\u044f 100 000 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0438 32 \u0444\u0430\u043a\u0442\u043e\u0440\u043e\u0432 \u2014 ~2.77 \u043c\u0441.\u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c\u0422\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u0441\u0442\u0435\u043d\u0434: Intel Core i5-11400F (6 \u044f\u0434\u0435\u0440, 12 \u043f\u043e\u0442\u043e\u043a\u043e\u0432), Windows 11, .NET 8.0, BenchmarkDotNet 0.15.8\u041c\u0435\u0442\u043e\u0434\u0420\u0430\u0437\u043c\u0435\u0440 \u0431\u0430\u0442\u0447\u0430\u0421\u0440\u0435\u0434\u043d\u0435\u0435 \u0432\u0440\u0435\u043c\u044f\u041f\u0440\u043e\u043f\u0443\u0441\u043a\u043d\u0430\u044f \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u044cBlackScholes.PriceBatch100 0005.12 ms~19.5 \u043c\u043b\u043d \u043e\u043f\u0446\u0438\u043e\u043d\u043e\u0432\/\u0441\u0435\u043aBlackScholes.GreeksBatch100 00010.43 ms~9.6 \u043c\u043b\u043d \u043e\u043f\u0446\u0438\u043e\u043d\u043e\u0432\/\u0441\u0435\u043aMonteCarlo.EuropeanGBM10 000 \u043f\u0443\u0442\u0435\u04390.264 ms\u2014HistoricalRisk.ValueAtRisk (usePool)100 0000.44 ms\u2014HistoricalRisk.ExpectedShortfall (usePool)100 0000.487 ms\u2014FactorModelPnL (32 \u0444\u0430\u043a\u0442\u043e\u0440\u0430)100 0002.77 ms36 \u043c\u043b\u043d \u00ab\u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u00d7\u0444\u0430\u043a\u0442\u043e\u0440\u00bb\/\u0441\u0435\u043aFactorModelPnL (64 \u0444\u0430\u043a\u0442\u043e\u0440\u0430)100 0005.04 ms1.27 \u043c\u043b\u0440\u0434 \u00ab\u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u00d7\u0444\u0430\u043a\u0442\u043e\u0440\u00bb\/\u0441\u0435\u043a\u041f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0441\u043c\u044b\u0441\u043b: \u043f\u043e\u0440\u0442\u0444\u0435\u043b\u044c \u0438\u0437 200 000 \u043e\u043f\u0446\u0438\u043e\u043d\u043e\u0432 \u043f\u0435\u0440\u0435\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0437\u0430 ~10\u201320 \u043c\u0441. \u042d\u0442\u043e \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0437\u0430\u043f\u0430\u0441 \u043d\u0430 \u0441\u0435\u0442\u044c, \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u043d\u0430\u043a\u043b\u0430\u0434\u043d\u044b\u0435 \u0440\u0430\u0441\u0445\u043e\u0434\u044b \u0434\u0430\u0436\u0435 \u043f\u0440\u0438 \u0436\u0451\u0441\u0442\u043a\u043e\u043c SLA \u0432 50 \u043c\u0441.\u041f\u043e\u0448\u0430\u0433\u043e\u0432\u0430\u044f \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044f \u0432 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u043f\u0440\u043e\u0435\u043a\u0442\u0428\u0430\u0433 1. \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430dotnet add package QuantCore.Net &#8212;version 0.1.5\u0428\u0430\u0433 2. \u041f\u0440\u0435\u0434\u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0431\u0443\u0444\u0435\u0440\u043e\u0432 (\u043e\u0434\u0438\u043d \u0440\u0430\u0437 \u043f\u0440\u0438 \u0441\u0442\u0430\u0440\u0442\u0435)public class PricingService{    private readonly double[] _spots;    private readonly double[] _strikes;    private readonly double[] _rates;    private readonly double[] _dividends;    private readonly double[] _vols;    private readonly double[] _times;    private readonly double[] _prices;    private readonly Greeks[] _greeks;    public PricingService(int maxBatchSize)    {        _spots = new double[maxBatchSize];        _strikes = new double[maxBatchSize];        _rates = new double[maxBatchSize];        _dividends = new double[maxBatchSize];        _vols = new double[maxBatchSize];        _times = new double[maxBatchSize];        _prices = new double[maxBatchSize];        _greeks = new Greeks[maxBatchSize];    }        \/\/ &#8230;}\u0428\u0430\u0433 3. \u0417\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445public void LoadPortfolio(Portfolio portfolio){    for (int i = 0; i &lt; portfolio.Instruments.Count; i++)    {        var opt = portfolio.Instruments[i];        _spots[i] = opt.Spot;        _strikes[i] = opt.Strike;        _rates[i] = opt.RiskFreeRate;        _dividends[i] = opt.DividendYield;        _vols[i] = opt.ImpliedVolatility;        _times[i] = opt.TimeToExpiry;    }}\u0428\u0430\u0433 4. \u0412\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0440\u0430\u0441\u0447\u0451\u0442\u0430public double[] CalculatePrices(){    BlackScholes.PriceBatch(        type: OptionType.Call,        s: _spots,        k: _strikes,        r: _rates,        q: _dividends,        sigma: _vols,        t: _times,        outPrice: _prices    );        return _prices;}\u0428\u0430\u0433 5. \u041f\u043e\u043b\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440: \u0441\u0435\u0440\u0432\u0438\u0441 \u043f\u0435\u0440\u0435\u043e\u0446\u0435\u043d\u043a\u0438 \u043f\u043e\u0440\u0442\u0444\u0435\u043b\u044fpublic class PortfolioRevaluationService{    private readonly PricingService _pricing;    private readonly RiskCalculator _risk;        public async Task&lt;PortfolioMetrics&gt; Revaluate(Portfolio portfolio)    {        \/\/ 1. \u0426\u0435\u043d\u044b \u0438 \u0433\u0440\u0435\u043a\u0438        var prices = _pricing.CalculatePrices(portfolio.Options);        var greeks = _pricing.CalculateGreeks(portfolio.Options);                \/\/ 2. PnL \u043f\u043e \u0444\u0430\u043a\u0442\u043e\u0440\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438        var factorPnl = _risk.CalculateFactorPnL(portfolio.Exposures);                \/\/ 3. Risk metrics        var var95 = HistoricalRisk.ValueAtRisk(portfolio.HistoricalPnl, 0.95);        var es95 = HistoricalRisk.ExpectedShortfall(portfolio.HistoricalPnl, 0.95);                return new PortfolioMetrics        {            TotalValue = prices.Sum(),            WeightedDelta = greeks.Sum(g =&gt; g.Delta),            WeightedGamma = greeks.Sum(g =&gt; g.Gamma),            VaR95 = var95,            ES95 = es95        };    }}\u041a\u043e\u0433\u0434\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c, \u0430 \u043a\u043e\u0433\u0434\u0430 \u043d\u0435\u0442\u041f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f:\u0412\u044b\u0441\u043e\u043a\u043e\u0447\u0430\u0441\u0442\u043e\u0442\u043d\u0430\u044f \u043f\u0435\u0440\u0435\u043e\u0446\u0435\u043d\u043a\u0430 \u043f\u043e\u0440\u0442\u0444\u0435\u043b\u0435\u0439 (\u0440\u0438\u0441\u043a-\u043c\u0435\u043d\u0435\u0434\u0436\u043c\u0435\u043d\u0442, \u043c\u0430\u0440\u0436\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435)\u0411\u0430\u0442\u0447\u0435\u0432\u044b\u0435 \u0440\u0430\u0441\u0447\u0451\u0442\u044b \u0432 \u0442\u043e\u0440\u0433\u043e\u0432\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445\u0420\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u043e\u043d\u043d\u043e\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 quantitative-\u043c\u043e\u0434\u0435\u043b\u0435\u0439 (\u0434\u0435\u0442\u0435\u0440\u043c\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 MC)\u0412\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u043d\u0438\u0435 \u0432 .NET-\u0441\u0435\u0440\u0432\u0438\u0441\u044b \u0431\u0435\u0437 \u0432\u043d\u0435\u0448\u043d\u0438\u0445 C++ \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439\u041d\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f:\u042d\u043a\u0437\u043e\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043e\u043f\u0446\u0438\u043e\u043d\u043e\u0432 \u0441 \u0431\u0430\u0440\u044c\u0435\u0440\u0430\u043c\u0438, \u043e\u0442\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u043c\u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u044f\u043c\u0438 \u0438 \u0442.\u0434. (\u043d\u0443\u0436\u043d\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435)\u0418\u043d\u0442\u0435\u0440\u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0445 Excel-\u043d\u0430\u0434\u0441\u0442\u0440\u043e\u0435\u043a \u0441 \u0442\u044b\u0441\u044f\u0447\u0430\u043c\u0438 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 (\u043b\u0443\u0447\u0448\u0435 \u0431\u0430\u0442\u0447\u0435\u0432\u044b\u0439 API)\u0421\u0438\u0442\u0443\u0430\u0446\u0438\u0439, \u0433\u0434\u0435 \u043d\u0443\u0436\u043d\u0430 double-\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u0434\u043b\u044f \u044d\u043a\u0441\u0442\u0440\u0435\u043c\u0430\u043b\u044c\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0447\u0438\u0441\u0435\u043b (\u043d\u043e float \u0438 \u0442\u0430\u043a \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-481486","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/481486","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=481486"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/481486\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=481486"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=481486"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=481486"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}