Click or drag to resize

FIX/FAST connectivity

S#.Data can be used in server mode, in this mode it is possible remotely to connect to S#.Data and get the data available in the storage. The activation of the S#.Data server mode is described in the Settings item.

To connect via Connectors (FIX/FAST) , you need to create and configure FixTrader (Getting started).

C#
...
FixTrader Trader = new FixTrader();
...
var marketDataAdapter = ((FixMessageAdapter) Trader.MarketDataAdapter);
marketDataAdapter.Address = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 5002); 
marketDataAdapter.SenderCompId = "hydra_user";
marketDataAdapter.TargetCompId = "StockSharpHydraMD";
marketDataAdapter.Login = "hydra_user";
marketDataAdapter.Password = "qwerty".To<SecureString>();

var transactionDataAdapter = ((FixMessageAdapter) Trader.TransactionAdapter);
transactionDataAdapter.Address = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 5002);
transactionDataAdapter.SenderCompId = "hydra_user";
transactionDataAdapter.TargetCompId = "StockSharpHydraMD";
transactionDataAdapter.Login = "hydra_user";
transactionDataAdapter.Password = "qwerty".To<SecureString>();

...

To subscribe to getting data events and connect

C#
...
Trader.Connected += () =>
{
    Console.WriteLine("Trader.Connected");
    Trader.LookupSecurities(new Security ());


};
Trader.Disconnected += () =>
{
    Console.WriteLine("Trader.Disconnected");
};

Trader.NewSecurity += security =>
{
    Console.Write("Trader.NewSecurity: ");
    Console.WriteLine(security);
    BuffeSecurity.Add(security);
    if (security.Id == seid)
    {
        Trader.RegisterMarketDepth(security);
        Trader.RegisterTrades(security);
        series.CandleType = typeof (TimeFrameCandle);
        series.Security = security;
        series.Arg = TimeSpan.FromMinutes(5);
        _candleManager.Start(series);
    }
};

Trader.NewTrade += trade =>
{
    Console.WriteLine("Trader.NewTrade");
    Console.WriteLine(trade);
};
Trader.MarketDepthChanged+= depth =>
{
    Console.WriteLine("Trader.MarketDepthChanged");
    Console.WriteLine(depth);
};

Trader.ConnectionError += error =>
{
    Console.WriteLine("Trader.ConnectionError");
    Console.WriteLine(error.Message);
};

Trader.Error += error =>
{
    Console.WriteLine("Trader.Error");
    Console.WriteLine(error.Message);
};

Trader.MarketDataSubscriptionFailed += (security, msg, error) =>
{
    Console.WriteLine("Trader.MarketDataSubscriptionFailed");
    Console.WriteLine(security);
    Console.WriteLine(msg);
    Console.WriteLine(error);
};
...
Trader.Connect();
...