понедельник, 8 ноября 2021 г.

MathLib, Projects, BlackModel, BlackScholesModel, Cpp,C++

extern "C" MATHLIB_API class BlackScholesModel

    {

    public:

        MATHLIB_API static double premium_call(double S, double K, double T, double sigma, double r, double q);

        MATHLIB_API static double premium_put(double S, double K, double T, double sigma, double r, double q);

        MATHLIB_API static double delta_call(double S, double K, double T, double sigma, double r, double q);

        MATHLIB_API static double delta_put(double S, double K, double T, double sigma, double r, double q);

        MATHLIB_API static double vega(double S, double K, double T, double sigma, double r, double q);

        MATHLIB_API static double theta_call(double S, double K, double T, double sigma, double r, double q);

        MATHLIB_API static double theta_put(double S, double K, double T, double sigma, double r, double q);

    MATHLIB_API static double gamma(double S, double K, double T, double sigma, double r, double q);

        MATHLIB_API static double d1(double S, double K, double T, double sigma, double r, double q);

        MATHLIB_API static double d2(double T, double sigma, double d1);

    };

    extern "C" MATHLIB_API class BlackModel

    {

    public:

        MATHLIB_API static double d1(double F, double K, double T, double sigma);

        MATHLIB_API static double d2(double F, double K, double T, double sigma);

        MATHLIB_API static double d2(double T, double sigma, double d1);

        MATHLIB_API static double premium_call(double F, double K, double T, double sigma, double r);

        MATHLIB_API static double premium_put(double F, double K, double T, double sigma,  double r);

        MATHLIB_API static double delta_call(double F, double K, double T, double sigma, double r);

        MATHLIB_API static double delta_put(double F, double K, double T, double sigma, double r);

        MATHLIB_API static double vega(double F, double K, double T, double sigma, double r);

        MATHLIB_API static double vega_test(double F, double K, double T, double sigma, double r);

        MATHLIB_API static double theta_call(double F, double K, double T, double sigma, double r);

        MATHLIB_API static double theta_put(double F, double K, double T, double sigma, double r);

        MATHLIB_API static double rho_call(double F, double K, double T, double sigma, double r);

        MATHLIB_API static double rho_put(double F, double K, double T, double sigma, double r);

        MATHLIB_API static double gamma(double F, double K, double T, double sigma, double r);

        MATHLIB_API static double gamma_test(double F, double K, double T, double sigma, double r);

        MATHLIB_API static double vanna(double F, double K, double T, double sigma, double r);

        MATHLIB_API static double vanna_test(double F, double K, double T, double sigma, double r);

        MATHLIB_API static double vomma(double F, double K, double T, double sigma, double r);

        MATHLIB_API static double vomma_test(double F, double K, double T, double sigma, double r);

    };

BlackModel: Rho from BlackScholesModel to be uptodate with Quik

суббота, 6 ноября 2021 г.

Lambda, Projects, Cpp, C++

https://docs.microsoft.com/ru-ru/cpp/cpp/lambda-expressions-in-cpp?view=msvc-160

https://en.cppreference.com/w/cpp/language/lambda



[&total, factor]
[factor, &total]
[&, factor]
[factor, &]
[=, &total]
[&total, =]






#include <algorithm>
#include <cmath>

void abssort(float* x, unsigned n) {
    std::sort(x, x + n,
        // Lambda expression begins
        [](float a, float b) {
            return (std::abs(a) < std::abs(b));
        } // end of lambda expression
    );
}

struct S { void f(int i); };

void S::f(int i) {
    [&, i]{};      // OK
    [&, &i]{};     // ERROR: i preceded by & when & is the default
    [=, this]{};   // ERROR: this when = is the default
    [=, *this]{ }; // OK: captures this by value. See below.
    [i, i]{};      // ERROR: i repeated
}

template<class... Args>
void f(Args... args) {
    auto x = [args...] { return g(args...); };
    x();
}

pNums = make_unique<vector<int>>(nums);
//...
      auto a = [ptr = move(pNums)]()
        {
           // use ptr
        };

auto y = [] (int first, int second)
{
    return first + second;
};

auto y = [] (auto first, auto second)
{
    return first + second;
};

// throw_lambda_expression.cpp
// compile with: /W4 /EHsc
int main() // C4297 expected
{
   []() noexcept { throw 5; }();
}

auto x1 = [](int i){ return i; }; // OK: return type is int
auto x2 = []{ return{ 1, 2 }; };  // ERROR: return type is void, deducing
                                  // return type from braced-init-list isn't valid

// captures_lambda_expression.cpp
// compile with: /W4 /EHsc
#include <iostream>
using namespace std;

int main()
{
   int m = 0;
   int n = 0;
   [&, n] (int a) mutable { m = ++n + a; }(4);
   cout << m << endl << n << endl;
}

void fillVector(vector<int>& v)
{
    // A local static variable.
    static int nextValue = 1;

    // The lambda expression that appears in the following call to
    // the generate function modifies and uses the local static
    // variable nextValue.
    generate(v.begin(), v.end(), [] { return nextValue++; });
    //WARNING: this isn't thread-safe and is shown for illustration only
}

// compile with: /W4 /EHsc
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>

using namespace std;

template <typename C> void print(const string& s, const C& c) {
    cout << s;

    for (const auto& e : c) {
        cout << e << " ";
    }

    cout << endl;
}

void fillVector(vector<int>& v)
{
    // A local static variable.
    static int nextValue = 1;

    // The lambda expression that appears in the following call to
    // the generate function modifies and uses the local static
    // variable nextValue.
    generate(v.begin(), v.end(), [] { return nextValue++; });
    //WARNING: this isn't thread-safe and is shown for illustration only
}

int main()
{
    // The number of elements in the vector.
    const int elementCount = 9;

    // Create a vector object with each element set to 1.
    vector<int> v(elementCount, 1);

    // These variables hold the previous two elements of the vector.
    int x = 1;
    int y = 1;

    // Sets each element in the vector to the sum of the
    // previous two elements.
    generate_n(v.begin() + 2,
        elementCount - 2,
        [=]() mutable throw() -> int { // lambda is the 3rd parameter
        // Generate current value.
        int n = x + y;
        // Update previous two values.
        x = y;
        y = n;
        return n;
    });
    print("vector v after call to generate_n() with lambda: ", v);

    // Print the local variables x and y.
    // The values of x and y hold their initial values because
    // they are captured by value.
    cout << "x: " << x << " y: " << y << endl;

    // Fill the vector with a sequence of numbers
    fillVector(v);
    print("vector v after 1st call to fillVector(): ", v);
    // Fill the vector with the next sequence of numbers
    fillVector(v);
    print("vector v after 2nd call to fillVector(): ", v);
}

int y = 32;
    auto answer = [y]() constexpr
    {
        int x = 10;
        return y + x;
    };

    constexpr int Increment(int n)
    {
        return [n] { return n + 1; }();
    }

auto answer = [](int n)
    {
        return 32 + n;
    };

    constexpr int response = answer(10);


auto Sqr = [](int t) __declspec(code_seg("PagedMem")) -> int { return t*t; };

SharedPtr, UniquePtr, Projects, Cpp, C++

 https://docs.microsoft.com/ru-ru/cpp/cpp/how-to-create-and-use-shared-ptr-instances?view=msvc-160#example-4

https://docs.microsoft.com/ru-ru/cpp/cpp/smart-pointers-modern-cpp?view=msvc-160

https://docs.microsoft.com/ru-ru/cpp/cpp/how-to-create-and-use-unique-ptr-instances?view=msvc-160

D:\VC\Cpp\CppSln\Cpp01\CaSharedPtr01\CaSharedPtr01.vcxproj

D:\VC\Cpp\CppSln\Cpp01\CaUniquePtr01\CaUniquePtr01.vcxproj

Next step

https://docs.microsoft.com/ru-ru/cpp/cpp/lambda-expressions-in-cpp?view=msvc-160


четверг, 4 ноября 2021 г.

MathLib, C++, Cpp, Projects, DLL,

 D:\VC\Cpp\CppSln\GS.Math\GS.Math01

NamespaceS

1. HelloWorld - begin

----------------------------------------------------------------------------------------------------

2. Stewbond namespace

http://cplusplus.com/forum/beginner/62864/

// Returns the erf() of a value (not super precice, but ok)

    double erf(double x)

// Returns the probability of x, given the distribution described by mu and sigma.

    double pdf(double x, double mu, double sigma)

 // Returns the probability of [-inf,x] of a gaussian distribution

    double cdf(double x, double mu, double sigma)

// Returns the integral from -inf to x of any function that accepts x and 2 other parameters

    double cdf_func(double x, double mu, double sigma, double(*ptr_pdf)(double, double, double))

 // function which will approximate an integral of f(x) between a and b:

    double integral(double a, double b, double(*f)(double))

    class NormalDistribution

    Stewbond::NormalDistribution(double _mu, double _sigma) : mu(_mu), sigma(_sigma) 

    inline double Stewbond::NormalDistribution::pdf(double x) const

    double Stewbond::NormalDistribution::cdf(double x) const

-----------------------------------------------------------------------------------------------------------------

3. Horner Namespace

1. Horner functions. Poly 10 degree

Armstrong norm_cdv, norm_cdf_inverse

double norm_cdf(double x)

double norm_cdf_inverse(double x)

MathLib-Test1 Google Test OK

UnitTest_MathLib std::cout does not work

пятница, 29 октября 2021 г.

BlackScholes, Model, Project, Options

VC\OptionsBS\BlackScholesOptions\OptionModels

VC\OptionsBS\BlackScholesOptions\OptionModels\BlackScholesOptionModel Kono

VC\OptionsBS\BlackScholesOptions\OptionModels\GS.Options

Helpers, Interfaces,Enums, Data

VC\OptionsBS\BlackScholesOptions\OptionModels\OptionModelTest

Numericals

Variations

VC\OptionsBS\BlackScholesOptions\OptionModels\OptionPricingModels


понедельник, 25 октября 2021 г.

OptionDesk, Dde, GS.Trade.Dde, Project, Test, OptionInfo, Parse, OptionTicker, OptionDeskItem, MoexTicker

GS.Trade.Dde.sln CA_Test_Dde_02

GS.Trade.Data OptionTicker, OptionDeskItem

GS.Moex MoexTicker ISS

CircularArray, GS, GS.Buffers, Project, Indexator, IEnumerable, UnSafe

With Indexator, IEnumerable<T>

public class CircularArray<T> : IEnumerable<T> 

public T this[int i]

Test02 Add
Position:5 Count:5 Size:10 First:1 Last:5
Cnt: 5 4 3 2 1 
All: 5 4 3 2 1 0 0 0 0 0 
Raw: 0 0 0 0 0 5 4 3 2 1 
FoE: 5 4 3 2 1 
Idx: 5 4 3 2 1 
Idx: 5 4 3 2 1 CircularArray`1 get_Item: Index out of range. Count:5 Idx:5
0 CircularArray`1 get_Item: Index out of range. Count:5 Idx:6
0 CircularArray`1 get_Item: Index out of range. Count:5 Idx:7
0 CircularArray`1 get_Item: Index out of range. Count:5 Idx:8
0 CircularArray`1 get_Item: Index out of range. Count:5 Idx:9
Position:5 Count:10 Size:10 First:6 Last:15
Cnt: 15 14 13 12 11 10 9 8 7 6 
All: 15 14 13 12 11 10 9 8 7 6 
Raw: 10 9 8 7 6 15 14 13 12 11 
FoE: 15 14 13 12 11 10 9 8 7 6 
Idx: 15 14 13 12 11 10 9 8 7 6 
Idx: 15 14 13 12 11 10 9 8 7 6 
Position:1 Count:10 Size:10 First:10 Last:19
Cnt: 19 18 17 16 15 14 13 12 11 10 
All: 19 18 17 16 15 14 13 12 11 10 
Raw: 10 19 18 17 16 15 14 13 12 11 
FoE: 19 18 17 16 15 14 13 12 11 10 
Idx: 19 18 17 16 15 14 13 12 11 10 
Idx: 19 18 17 16 15 14 13 12 11 10 
Position:4 Count:10 Size:10 First:17 Last:26
Cnt: 26 25 24 23 22 21 20 19 18 17 
All: 26 25 24 23 22 21 20 19 18 17 
Raw: 20 19 18 17 26 25 24 23 22 21 
FoE: 26 25 24 23 22 21 20 19 18 17 
Idx: 26 25 24 23 22 21 20 19 18 17 
Idx: 26 25 24 23 22 21 20 19 18 17 

суббота, 23 октября 2021 г.

Circular, Buffer, List, Array, CodeProject, Cpp, C#, Normal, Distribution, Math, Statistics, Servers, Portable, Asp.Net

https://www.codeproject.com/

DownLoads\CodeProject\CircularBuffer

---------------------------------------------------------------------------------------------------------

Circular character buffer C++ David Habbard

https://www.codeproject.com/Articles/139/A-circular-character-buffer

---------------------------------------------------------------------------------------

Circular Buffer character C++ 3


-------------------------------------------------------------------------------------------------------------

Circular Buffer Made Easy C++

A circular buffer with thread safe read/write operations.
_________________________________________________________________________


--------------------------------------------------------------------------------------------------------------

A Circular List C#

https://www.codeproject.com/Articles/283025/Simple-Carousel-Control-for-Windows-Forms

----------------------------------------------------------------------------------------------------------

Generic Circular Array C#

https://www.codeproject.com/Articles/31652/A-Generic-Circular-Array

----------------------------------------------------------------------------------------

A Generic Circular Buffer in C#


A circular buffer allows for rapid pushing and popping from the front and back of the container. These operations are O(1) while other inserts and removes are O(n) assuming no reallocations.

This makes the buffer suitable as a generic stack or queue. The reason one might want to use this class this way despite Microsoft's stack or queue is that this class allows access by index, and fully implements IList<T>


-----------------------------------------------------------------------------------------------------------

DList<T>: The Circular List<T> C#

DList<T> is a “circular buffer”. A circular buffer is a region of memory organized so that you can efficiently add or remove items at both ends, and is commonly used to implement queues (it’s called a “circular queue”).

http://core.loyc.net/

http://core.loyc.net/collections/internal-list.html

https://www.nuget.org/packages/LoycCore/

https://www.nuget.org/packages/LoycCore/

--------------------------------------------------------------------------------------------------------------

The Bip Buffer - The Circular Buffer with a Twist C++

A bi-partite circular buffer for high performance buffering, where it comes from, and why you'd want to use it.

In this article, you will learn about a bi-partite circular buffer for high performance buffering. You will also see where it comes from, and why you'd want to use it.

----------------------------------------------------------------------------------------------------------------

Performance of a Circular Buffer vs. Vector, Deque, and List C++


This article reviews performance of C++ standard library sequence containers on frequently occurring operations, and examines performance of another container class, the ring, or circular buffer, that is a candidate for inclusion in a future edition of C++.

boost::circular_buffer

A sort of spec sheet for a circular buffer container class like boost::circular_buffer might look like this:

  • Sequence container

  • Insert or remove: from front or back O(1), from elsewhere O(n)

  • Index time: by position, O(1)

  • Sort: O(n log2 n).

  • Search: O(log2 n) if sorted, else O(n)

  • Iterators and references to an item are invalidated when the item is removed. Iterators and references to the item at one end of the circular buffer are invalidated when an item is inserted on the other end of the circular buffer, and the circular buffer is already full. All iterators and references are invalidated when the capacity is increased.

  • Iterators are random-access iterators.

  • Iterators produce items front-to-back or back-to-front.

  • Fixed-capacity data structure

-------------------------------------------------------------------------------------------------------------

Real-time Feed Distribution using Circular Shared Queue C++

RealTIme Feed for many Clients


---------------------------------------------------------------------------------------------------------------------

Yet another implementation of a lock-free circular array queue


------------------------------------------------------------------------------------------------------------------------

Circular Values Math and  with C++11


------------------------------------------------------------------------------------------------------------------------

List of Portable ASP.NET Servers






CodeProject, CircularBuffer, HttpServer, Wpf, Mvvm, RealTime, Trading

https://www.codeproject.com/

A circular character buffer

A single-threaded HTTP server

https://www.codeproject.com/Articles/12462/A-single-threaded-HTTP-server

WPF / MVVM Real-Time Trading Application

понедельник, 26 июля 2021 г.

Chartdirector

1. C#

Net2107

Demo

Wpf

NetWPFCharts.sln 

CSharpWPFCharts project

Pro

Wpf

D:\VC\Finance\ChartFinance\ChartFinance.sln

-----------------------------------------------------------

2. AspNetCore

Demo

MVC

NetCoreMvcCharts.sln

Pro

D:\VC\AspNetCore\AncCharts\AncCharts.sln

FinanceChart01

Financedemo - controller

=======================================

C++

cpp2107

cppdemo

c++20

only save image to harddisk

F:\DownLoads\Charts\ChartDirector\cpp2107\ChartDirector\cppdemo\bubble\bubble.sln

F:\DownLoads\Charts\ChartDirector\cpp2107\ChartDirector\cppdemo\finance\finance.sln

---------------------------------------------------------------------

mfcdemo does mot work in c++20 thanks to MFC