суббота, 30 декабря 2023 г.

четверг, 21 декабря 2023 г.

воскресенье, 10 декабря 2023 г.

Boost, Serialization

#include <boost/archive/binary_oarchive.hpp>

#include <boost/archive/binary_iarchive.hpp>

D:\VC\Cpp\Boost01\Boost02\CaSerial01\CaSerial01.vcxproj


std::ofstream ofs(file_path, std::ios::binary);

boost::archive::binary_oarchive oa(ofs);

oa << a;

ofs.close();

std::ifstream ifs(file_path, std::ios::binary);

boost::archive::binary_iarchive ia(ifs);

ia >> b;

ifs.close();

среда, 11 октября 2023 г.

C#, Console.ReadLine, Threads, Blocking

https://stackoverflow.com/questions/37834572/what-happens-when-a-net-console-app-blocks-on-console-readline




static void Test3() from Reffs 2
{
    var cts = new CancellationTokenSource();
    var processingTask = Task.Factory.StartNew(() => GetStreamFromYoutubeDl(),cts.Token);
    var readingFromConsoleTask = Task.Factory.StartNew(() =>
    {
        Console.WriteLine("Press 'q' to exit.");
        while (true)
        {
            var read = Console.ReadKey(true);
            if (read.Key == ConsoleKey.Q)
            {
                cts.Cancel();
                return;
            }
        }
    });

    Task.WaitAny(processingTask, readingFromConsoleTask);
}



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

GS.MicroServices, GS.Trade

Network: TCP, UDP, WebSockets, SignalR, Http2 

1. DDE, Server

2. SimulateTerminal, Server

3. Connectors, Server

4. Eventog, Server

5. TradeStorage, Server

6. Charts, Client

7. Strategies, Client

8. OptionDesk, Client

9. Portfolio, Client

10. Time Service, Server (Quarth)

11. Tickers Service, Server

12. DNS Service, Server

13. MarketData Service, Server


суббота, 30 сентября 2023 г.

GS.Trade, TradeContext51

Serialization string in Anywhere

var x = xDoc.Descendants(root).FirstOrDefault();

TradeContext51

Init()

Dde

Dde = ConfigurationResourse1.Build<IDde, string, ITopicItem>("Dde", "Dde");

Dde.Parent = this;

Dde.Init();

http://localhost/GS.Trade.Web.Mvc.Cfg_01/CfgTrans

Strategies in TradeContext51

Strategies = ConfigurationResourse1.Build<IStrategies>("Strats", "Strategies");

                    if (Strategies == null)

                    { 

                        throw new NullReferenceException("Stategies Build Failure");

                    }

                    Strategies.Parent = this;

                    Strategies.TradeContext = this;


                    Strategies.Init(); ****** 


                    foreach (var s in Strategies.StrategyCollection)

                    {

                        try

                        {

                            TradeStorage.Register(s);

                            TradeStorage.Register(s.Position);

                            TradeStorage.RegisterTotal(s.PositionTotal);

                        }

                        catch (Exception e)

                        {

                            SendExceptionMessage3(FullName, "TradeContext", "Strategy.Register:" + s.StrategyTickerString,

                                "", e);

                            // throw;

                        }

                    }

                    Thread.Sleep(1000);


                    Strategies.StrategyTradeEntityChangedEvent += EventHub.FireEvent;

                    Strategies.ExceptionEvent += EventHub.FireEvent;

Init()

IsEvlEnabled = true;

            try

            {

             base.Init(TradeContext.EventLog);

             

            _evl = TradeContext.EventLog;

            //_evl.AddItem(EvlResult.INFO, EvlSubject.TECHNOLOGY, "Strategies",

            //    "Strategies","Init Start", Name + " " + Code, "Count: " + _strategyDictionary.Count());


            Evlm2(EvlResult.INFO, EvlSubject.TECHNOLOGY, "Strategies",

                "Strategies", "Init Start", Name + " " + Code, "Count: " + _strategyDictionary.Count());


             //TradeContext.Orders.StopOrderFilledEvent += StopOrderFilledEventHandler;

            //TradeContext.Orders.LimitOrderFilledEvent += LimitOrderFilledEventHandler;


            //DeSerializationCollection();

            // DeSerializationCollection3();

            DeSerializationCollection32();

            //var badInit = new List<string>();

            //foreach (var s in StrategyCollection)

            //{

            //    ((Strategy)s).SetParent(this);

            //    ((Strategy)s).SetTradeContext(TradeContext);

            //    s.Parent = this;

            //    ((Strategy)s).Init();


            //    if (!s.IsWrong) continue;

            //    badInit.Add(s.Key);

            //    _evl.AddItem(EvlResult.FATAL, EvlSubject.TECHNOLOGY, s.Name, s.Name, "Initialization Failure", s.ToString(), "");

            //}

            //foreach (var k in badInit) _strategyDictionary.Remove(k);


            //_evl.AddItem(EvlResult.INFO, EvlSubject.TECHNOLOGY, "Strategies",

            //    "Strategies", "Init Finish", Name + " " + Code, "Count: " + _strategyDictionary.Count());


            }

            catch (Exception e)

            {

                // throw new NullReferenceException("Strategies.Init Failure:" + e.Message);

                SendException(e);

            }

        }


четверг, 28 сентября 2023 г.

GS, Serialization, Shedevr

public static T BuildTypeWithCollectionInside<T, TKey, TItem>(XDocument xdoc, string root)

            where T : class, IHaveCollection<TKey, TItem>, IHaveUri

            where TItem : class, IHaveKey<TKey>

        {

            T t = null;

            try

            {

                t = DeSerialization2<T>(xdoc, root);

                if (t == null)

                    throw new NullReferenceException("Deserialization Failure");

                if (t is IHaveUri uri && t is IHaveCollection<TKey, TItem> collection)

                {

                    var items = GetElements(xdoc, uri.XPath);

                    foreach (var i in items)

                    {

                        var ty = Type.GetType(i.TypeName, false, true);

                        if (Serialization.Do.DeSerialize(ty, i.XElement, null) is TItem s)

                            collection.Register(s);

                    }

                }

            }

            catch (Exception e)

            {

                 // throw new Exception("Builder DeSerialization Failure in " + root + " " + e.Message);

                 ConsoleSync.WriteLineT($@"{e}");

            }

            return t;

        }

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

GS.dll, Classlibrary, XDocextesions.cs

GS.Dll

XDocExtension

XML, xDoc file

Create Strings for

TypeInString = Namespace.NameOfType,  AssemblyName

Type = Type.GetType(TypeInString, false, true);

//Different Types, but interface is one

public static IEnumerable<string> GetTypeNameStrListEnumerable(string uri, string nodePath, string namesp)

        {

            var xdoc = XDocument.Load(uri);

            var node = xdoc.Element(nodePath);

            var nodeNamespace = node?.Attribute("ns")?.Value ?? namesp;

            if (node == null) yield break;

            if (!node.HasElements) yield break;


            foreach (var n in node.Elements())

            {

                // var ns = n.Attribute("ns")?.Value ?? namesp;

                var ns = n.Attribute("ns")?.Value ?? nodeNamespace;

                var str = ns + '.' + n.Name.ToString().Trim();

                yield return str;

            }

        }

        public static IEnumerable<string> GetTypeNameStrListEnumerable(string uri, string nodePath, 

                                    string namesp, string assemblyName)

        {

            var xdoc = XDocument.Load(uri);

            var node = xdoc.Element(nodePath);

            if (node == null) yield break;

            if (!node.HasElements) yield break;


            var nodeNamespace = node.Attribute("ns")?.Value ?? namesp;

            var asmName = node.Attribute("as")?.Value ?? assemblyName;


            foreach (var n in node.Elements())

            {

                var ns = n.Attribute("ns")?.Value ?? nodeNamespace;

                var asm = n.Attribute("as")?.Value ?? asmName;

                var str = ns + '.' + n.Name.ToString().Trim() + ", " + asm;

                yield return str;

            }

        }

    }

суббота, 23 сентября 2023 г.

GS.Trade, Project, Assemblies

GS -

GS.Time

GS.Trade.Data -

GS.Trade -

GS.Trade.Strategies 

GS.Trade.Trades

GS.Trade.TradeTerminals

WebClients -

AssemblyInfoList.xml

<?xml version="1.0" encoding="utf-8"?>

<!--<AssemblyInfoList xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">-->

<AssemblyInfoList ns="GS.Assemblies" as="GS">

  <Assemblies>

    <AssemblyInfo>

      <Name>GS</Name>

      <FullName>GS, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</FullName>

      <Path>D:\VC\1305\gs.trade\GS\GS\bin\Debug\GS.dll</Path>

      <Enabled>false</Enabled>

      <Dependencies />

    </AssemblyInfo>

    <AssemblyInfo>

      <Name>GS.Time</Name>

      <FullName>GS.Time, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</FullName>

      <Path>D:\VC\1305\gs.trade\GS.Time\bin\Debug\GS.Time.dll</Path>

      <Enabled>false</Enabled>

      <Dependencies>

        <string>GS</string>

      </Dependencies>

    </AssemblyInfo>

    <AssemblyInfo>

      <Name>GS.Trade</Name>

      <FullName>GS.Trade, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</FullName>

      <Path>D:\VC\1305\gs.trade\GS.Trade\GS.Trade\bin\Debug\GS.Trade.dll</Path>

      <Enabled>false</Enabled>

      <Dependencies>

        <string>GS</string>

        <string>GS.Time</string>

      </Dependencies>

    </AssemblyInfo>

    <AssemblyInfo>

      <Name>GS.Trade.Trades</Name>

      <FullName>GS.Trade.Trades, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</FullName>

      <Path>D:\VC\1305\gs.trade\GS.Trade.Trades\bin\Debug\GS.Trade.Trades.dll</Path>

      <Enabled>false</Enabled>

      <Dependencies>

        <string>GS</string>

        <string>GS.Trade</string>

      </Dependencies>

    </AssemblyInfo>

    <AssemblyInfo>

      <Name>GS.Trade.Data</Name>

      <FullName>GS.Trade.Data, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</FullName>

      <Path>D:\VC\1305\gs.trade\GS.Trade.Data\bin\Debug\GS.Trade.Data.dll</Path>

      <Enabled>false</Enabled>

      <Dependencies>

        <string>GS</string>

        <string>GS.Trade</string>

        <string>WebClients</string>

      </Dependencies>

    </AssemblyInfo>

    <AssemblyInfo>

      <Name>GS.Trade.TradeTerminals</Name>

      <FullName>GS.Trade.TradeTerminals, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</FullName>

      <Path>D:\VC\1305\gs.trade\GS.TradeTerminal\bin\Debug\GS.Trade.TradeTerminals.dll</Path>

      <Enabled>false</Enabled>

      <Dependencies>

        <string>GS</string>

        <string>GS.Trade.Data</string>

        <string>GS.Trade.Trades</string>

      </Dependencies>

    </AssemblyInfo>

    <AssemblyInfo>

      <Name>GS.Trade.Strategies</Name>

      <FullName>GS.Trade.Strategies, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</FullName>

      <Path>D:\VC\1305\gs.trade\GS.Trade.Strategies\bin\Debug\GS.Trade.Strategies.dll</Path>

      <Enabled>true</Enabled>

      <Dependencies>

        <string>GS</string>

        <!--<string>GS.Time</string>-->

        <string>GS.Trade</string>

        <!--<string>GS.Trade.Data</string>-->

        <string>GS.Trade.Trades</string>

        <string>GS.Trade.TradeTerminals</string>

        <string>WebClients</string>

      </Dependencies>

    </AssemblyInfo>

    <AssemblyInfo>

      <Name>WebClients</Name>

      <FullName>WebClients, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</FullName>

      <Path>D:\VC\1305\gs.trade\GS.Web.Clients\WebClients\bin\Debug\WebClients.dll</Path>

      <Enabled>false</Enabled>

      <Dependencies>

        <string>GS</string>

        <string>GS.Time</string>

        <string>GS.Trade</string>

      </Dependencies>

    </AssemblyInfo> 

  </Assemblies>

</AssemblyInfoList>

AutoResetEvent, Project

D:\VC\1305\AutoReset

четверг, 21 сентября 2023 г.

GS.EventLog, Connection,

D:\VC\1305\gs.trade\GS.EventLog\GS.EventLog2\CApp.GS.Web.Api.Evl.Server01

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
  <connectionStrings>
    <!--<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\aspnet-GS.Trade.Web.Api.TimeSeries01-20150405123739.mdf;Initial Catalog=aspnet-GS.Trade.Web.Api.TimeSeries01-20150405123739;Integrated Security=True"
      providerName="System.Data.SqlClient" />-->
    <!--<add name="DefaultConnection" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=Users;Integrated Security=True" providerName="System.Data.SqlClient" />-->
    <add name="Expr14.EventLog1" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=EventLog1;Integrated Security=True" providerName="System.Data.SqlClient" />
    <add name="Dvlp14.EventLog1" connectionString="Data Source=.\SQLDVLP14;Initial Catalog=EventLog1;Integrated Security=True" providerName="System.Data.SqlClient" />
  </connectionStrings>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1" />
  </startup>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
  </entityFramework>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

понедельник, 11 сентября 2023 г.

четверг, 7 сентября 2023 г.

SignalR,StockTicker , IIS, Console, Sample

Sample

dotnet add package Microsoft.AspNet.SignalR.Sample --version 2.2.2

1.

IIS App IISExpress Firefox

With Color Flashing strings

D:\VC\Web\SignalR.StockTicker

D:\VC\Web\SignalR.StockTicker\SignalR.StockTicker.sln

VS2019

NetFramework 4.5

Work well

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

2.

D:\VC\Web\SignalrChat19\SignalrChat19.sln

D:\VC\Web\SignalrChat19\SignalrChat01\SignalrChat01.csproj

Console App

Work in Browser

Net 5.0

VS2019

Work well

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

3.

D:\VC\Web\SignalRChat\SignalRChat.sln

CAppClient, CAppServer, WebClient

WinFormsClient, WinFormsServer

WPFClient, WPFServer

VS2019

Netframework 4.5.1

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

4. 

D:\VC\Web\SignalrStockTicker17\SignalrStockTicker17.sln

SgnStockTicker01

Netframework 4.7.1

To WebApp : True  - Not working

----

Try to convert to WebApp

D:\VC\Web\SignalrStockTicker17W\SignalrStockTicker17.sln

SgnStockTicker01

Netframework 4.8




пятница, 1 сентября 2023 г.

TcpIpClient Task, Process Task. WoaitForCompleting

1. Task WiatHandling
2. TcpIpHandler ProcessTask for Message Proccesing
3. TaskBase vs Task01

TcpIpHandlerParametrization

TcpIpServicies:
EvetntLog
WindowsWpf
DddSevice

Dde with Topic support

TradeTerminalServicies

Subscribing to Topics in TcpIpServicies

Trade: Options Desk

ClientId Create Save and Percistence

TcpIpServer -> EventHub for subscribers

TcpIpClient -. EventHub for Internal Methods

Projects:
GS.TcpIp.Sockets
GS.Test.Tasks
GS.WorkTasks
TasksTest