Exemplo n.º 1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="contract"></param>
 /// <param name="number"></param>
 public void SaveCode(TradeContract contract, long number)
 {
     if (contract != null)
     {
         contract.Number = number;
     }
 }
Exemplo n.º 2
0
        public async Task ProcessTrades(TradeContract trade)
        {
            var contract = new TradeClientContract
            {
                Id          = trade.Id,
                AssetPairId = trade.AssetPairId,
                Date        = trade.Date,
                OrderId     = trade.OrderId,
                Price       = trade.Price,
                Type        = trade.Type.ToType <TradeClientType>(),
                Volume      = trade.Volume
            };

            _tradesSubject.OnNext(contract);
            await Task.FromResult(0);
        }
Exemplo n.º 3
0
        public void ConsumeEvent(object sender, OrderExecutedEventArgs ea)
        {
            var tradeType = ea.Order.Direction.ToType <TradeType>();

            var trade = new TradeContract
            {
                Id          = ea.Order.Id,
                AccountId   = ea.Order.AccountId,
                OrderId     = ea.Order.Id,
                AssetPairId = ea.Order.AssetPairId,
                Date        = ea.Order.Executed.Value,
                Price       = ea.Order.ExecutionPrice.Value,
                Volume      = ea.Order.Volume,
                Type        = tradeType
            };

            _rabbitMqNotifyService.NewTrade(trade);
        }
Exemplo n.º 4
0
        public void ConsumeEvent(object sender, OrderClosedEventArgs ea)
        {
            if (ea.Order.IsClosed())
            {
                var trade = new TradeContract
                {
                    Id          = Guid.NewGuid().ToString("N"),
                    AccountId   = ea.Order.AccountId,
                    ClientId    = ea.Order.ClientId,
                    OrderId     = ea.Order.Id,
                    AssetPairId = ea.Order.Instrument,
                    Date        = ea.Order.CloseDate.Value,
                    Price       = ea.Order.ClosePrice,
                    Volume      = ea.Order.MatchedCloseOrders.SummaryVolume,
                    Type        = ea.Order.GetCloseType().ToType <TradeType>()
                };

                _rabbitMqNotifyService.NewTrade(trade);
            }
        }
Exemplo n.º 5
0
        private void RunJsonProxy()
        {
            string baseAddress = "http://" + Environment.MachineName + ":8000/Service.svc";

            WebHttpBinding webBinding = new WebHttpBinding
            {
                ContentTypeMapper      = new RawContentMapper(),
                MaxReceivedMessageSize = 4194304,
                MaxBufferSize          = 4194304,
                SendTimeout            = TimeSpan.FromMinutes(4)
            };

            EndpointAddress endpoint = new EndpointAddress(baseAddress + "/json");

            using (SalesService proxy = new SalesService(webBinding, endpoint))
            {
                proxy.Endpoint.Behaviors.Add(new WebHttpJsonNetBehavior());

                try
                {
                    Agency ag = proxy.GetAgency(1);
                    Console.WriteLine(ag);
                    Console.WriteLine();

                    Salesman cons = proxy.GetSalesman(1);
                    Console.WriteLine(cons);
                    Console.WriteLine();

                    Salesman res = proxy.GetFirstSalesman(0, 10);
                    Console.WriteLine(res);
                    Console.WriteLine();

                    IEnumerable <Salesman> conss = proxy.GetPagedSalesman(0, 2);
                    Console.WriteLine(conss);
                    Console.WriteLine();

                    IEnumerable <TradeContract> ctr = proxy.GetPagedContract(0, 10);
                    Console.WriteLine(ctr);
                    Console.WriteLine();

                    var sal = proxy.UpdateCode(new Salesman(true)
                    {
                        Name = "Manuel", Surname = "Lara"
                    }, 150);
                    Console.WriteLine(sal);
                    Console.WriteLine();

                    var sal2 = proxy.UpdateCode(null, 200);
                    Console.WriteLine("sal2 value:{0}", sal2);
                    Console.WriteLine();

                    IList <TradeContract> ctrs = new List <TradeContract>();
                    ctrs.Add(new CarContract {
                        Price = 10000, Description = "price car"
                    });
                    ctrs.Add(new HomeContract {
                        Price = 250000, Description = "price home", Town = "sex city"
                    });
                    var col = proxy.VerifyContracts(ctrs);
                    Console.WriteLine(col);
                    Console.WriteLine();

                    var col2 = proxy.VerifyContracts(null);
                    Console.WriteLine("col2 value: {0}", col2);
                    Console.WriteLine();

                    proxy.SaveCode(new CarContract {
                        Description = "my car", Price = 25000
                    }, 200);
                    Console.WriteLine("TradeContract saved");
                    Console.WriteLine();

                    TradeContract contract = proxy.GetContract(1);
                    Console.WriteLine("TradeContract value: {0}", contract.Owner);
                    Console.WriteLine();

                    Console.WriteLine("Press <ENTER> to terminate client.");
                    Console.ReadLine();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);

                    Console.WriteLine("Inner message:");
                    Console.WriteLine(ex.InnerException == null ? string.Empty : ex.InnerException.Message);
                    Console.WriteLine();

                    Console.ReadLine();
                }
            }
        }
 public async Task NewTrade(TradeContract trade)
 {
     throw new System.NotImplementedException();
 }
Exemplo n.º 7
0
 public Task NewTrade(TradeContract trade)
 {
     return(TryProduceMessageAsync(_settings.RabbitMqQueues.Trades.ExchangeName, trade,
                                   _settings.RabbitMqQueues.Trades.LogEventPublishing));
 }
Exemplo n.º 8
0
 public void SaveCode(TradeContract contract, long number)
 {
     this.Channel.SaveCode(contract, number);
 }
Exemplo n.º 9
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="contract"></param>
 /// <param name="number"></param>
 public void SaveCode(TradeContract contract, long number)
 {
     if (contract != null)
         contract.Number = number;
 }