Exemple #1
0
        static async Task Main(string[] args)
        {
            var client = new TcpMatchingEngineClient(
                new MeClientSettings
            {
                Endpoint      = new IPEndPoint(IPAddress.Parse(Dns.GetHostAddresses("me.me.svc.cluster.local")[0].ToString()), 8888),
                EnableRetries = true
            }, EmptyLogFactory.Instance);

            Thread.Sleep(100);
            client.Start();
            Thread.Sleep(100);

            var res = await client.PlaceLimitOrderAsync(
                new LimitOrderModel
            {
                Id          = Guid.NewGuid().ToString(),
                AssetPairId = "BTCUSD",
                ClientId    = "954dd309-1f64-481f-9059-99d541bd4349",
                OrderAction = OrderAction.Buy,
                Price       = 12000,
                Volume      = 0.001
            });

            Console.WriteLine(res.Status);
        }
        public MeTests(ITestOutputHelper log)
        {
            _log = log;
            var url = "";

            _client = new TcpMatchingEngineClient(new IPEndPoint(IPAddress.Parse(Dns.GetHostAddresses(url)[0].ToString()), 8888), EmptyLogFactory.Instance, true);
            Thread.Sleep(100);
            _client.Start();
            Thread.Sleep(100);
        }
Exemple #3
0
        public static IMatchingEngineClient CreateConnection(string url)
        {
            if (string.IsNullOrEmpty(url))
            {
                throw new ArgumentNullException(nameof(url), "Url must be specified");
            }

            var client =
                new TcpMatchingEngineClient(new IPEndPoint(IPAddress.Parse(Dns.GetHostAddresses(url)[0].ToString()),
                                                           8888), EmptyLogFactory.Instance, true);

            client.Start();
            return(client);
        }
        public static IServiceCollection AddMatchingEngineClient(
            this IServiceCollection services,
            IPEndPoint endpoint)
        {
            return(services
                   .AddSingleton <IMatchingEngineClient>(x =>
            {
                var meClient = new TcpMatchingEngineClient(endpoint, EmptyLogFactory.Instance);

                meClient.Start();

                return meClient;
            }));
        }
Exemple #5
0
        public static void RegisterMeClient(
            this IServiceCollection services,
            IPEndPoint ipEndPoint, bool enableRetries)
        {
            services.AddSingleton(s =>
            {
                var client = new TcpMatchingEngineClient(ipEndPoint, s.GetRequiredService <ILogFactory>(), enableRetries);

                client.Start();

                return(client);
            });
            services.AddSingleton <IMatchingEngineClient>(s => s.GetRequiredService <TcpMatchingEngineClient>());
        }
Exemple #6
0
        public void Connect()
        {
            IPHostEntry hostEntry = Dns.GetHostEntry(_hostName);

            if (hostEntry.AddressList.Length > 0)
            {
                IPEndPoint remoteEndpoint = new IPEndPoint(hostEntry.AddressList[0], _port);
                _client = new TcpMatchingEngineClient(remoteEndpoint);
                _client.Start();
            }
            else
            {
                throw new ArgumentException();
            }
        }
        public static void RegisgterMeClient(
            this ContainerBuilder ioc,
            IPEndPoint ipEndPoint, bool enableRetries)
        {
            ioc.Register(s =>
            {
                var tcpMeClient = new TcpMatchingEngineClient(ipEndPoint, s.Resolve <ILogFactory>(), enableRetries);

                tcpMeClient.Start();

                return(tcpMeClient);
            })
            .As <IMatchingEngineClient>()
            .As <TcpMatchingEngineClient>()
            .SingleInstance();
        }
        /// <summary>
        /// Registers <see cref="IMatchingEngineClient"/> in <paramref name="ioc"/>
        /// </summary>
        /// <remarks><see cref="ILogFactory"/> should be registered in the container.</remarks>
        /// <param name="ioc">Autofac container builder</param>
        /// <param name="settings">ME connection settings</param>
        public static void RegisterMeClient(
            this ContainerBuilder ioc,
            MeClientSettings settings)
        {
            ioc.Register(s =>
            {
                var tcpMeClient = new TcpMatchingEngineClient(
                    settings,
                    s.Resolve <ILogFactory>());

                tcpMeClient.Start();

                return(tcpMeClient);
            })
            .As <IMatchingEngineClient>()
            .As <TcpMatchingEngineClient>()
            .SingleInstance();
        }
Exemple #9
0
        static async Task Main(string[] args)
        {
            if (args.Length != 2)
            {
                Console.WriteLine("Specify clientId and assetPairId");
                return;
            }

            var config = new ConfigurationBuilder()
                         .AddJsonFile("appsettings.json")
                         .Build();

            var settings = new AppSettings();

            config.Bind(settings);

            string clientId    = args[0];
            string assetPairId = args[1];

            var client = new TcpMatchingEngineClient(new IPEndPoint(IPAddress.Parse(Dns.GetHostAddresses(settings.Host)[0].ToString()), settings.Port),
                                                     EmptyLogFactory.Instance, true);

            client.Start();
            await Task.Delay(300);

            int i = 0;

            Console.Clear();

            var res = await client.MassCancelLimitOrdersAsync(new LimitOrderMassCancelModel
            {
                Id          = Guid.NewGuid().ToString(),
                AssetPairId = assetPairId,
                ClientId    = clientId
            });

            Console.WriteLine($"Response: {res.Status}");
        }