private void ProcessOrderUpdate(JArray jArr)
        {
            ResponseOrders respOrders = jArr.ToObject <ResponseOrders>();

            Log(String.Format("[ORDER UPDATE] <=={0})", respOrders.ToString()));

            _client.ProcessOrder(respOrders, EnmOrderAction.Update);
        }
        private void ProcessOrderCancell(JArray jarr)
        {
            ResponseOrders respOrders = jarr.ToObject <ResponseOrders>();

            Log(String.Format("[ORDER CANCELL] <== {0}", respOrders.ToString()));


            _client.ProcessOrder(respOrders, EnmOrderAction.Deleted);
        }
        private void ProcessOrderNew(JArray jArr)
        {
            ResponseOrders respOrders = jArr.ToObject <ResponseOrders>();

            Log(String.Format("[ORDER NEW] <=={0})", respOrders.ToString()));


            _client.ProcessOrder(respOrders, EnmOrderAction.Added);
        }
Example #4
0
        public void Update(ResponseOrders [] ro)
        {
            //foreach (ResponseOrders order in ro)
            for (int i = ro.Length - 1; i >= 0; i--)
            {
                ResponseOrders order = ro[i];
                Log(order.ToString());


                DateTime dtUpdate = CUtilTime.DateTimeFromUnixTimestampMillis(
                    Convert.ToInt64(order.MtsUpdate));

                if ((DateTime.UtcNow - dtUpdate).TotalHours > _parHourOld)
                {
                    continue;
                }


                lock (_lstOrders)
                {
                    var res = _lstOrders.Find(el => el.Id == order.Id);
                    if (res == null) //not found do insert
                    {
                        CDBBfxOrder bfxOrder = new CDBBfxOrder
                        {
                            Id          = Convert.ToInt64(order.Id),
                            Gid         = Convert.ToInt64(order.Gid),
                            Symbol      = order.Symbol.Remove(0, 1),
                            MtsCreate   = Convert.ToInt64(order.MtsCreate),
                            MtsUpdate   = Convert.ToInt64(order.MtsUpdate),
                            Amount      = Convert.ToDecimal(order.Amount),
                            AmountOrig  = Convert.ToDecimal(order.AmountOrig),
                            OrderStatus = order.OrderStatus,
                            Price       = Convert.ToDecimal(order.Price),
                            PriceAvg    = Convert.ToDecimal(order.PriceAvg),
                            DtCreate    =
                                CUtilTime.DateTimeFromUnixTimestampMillis(
                                    Convert.ToInt64(order.MtsCreate)),

                            DtUpdate = dtUpdate
                        };

                        _lstOrders.Add(bfxOrder);

                        _client.DBCommunicator.QueueData(bfxOrder);

                        Log(String.Format("Adding to  id={0}", order.Id));

                        if (_lstOrders.Count > 0)
                        {
                            if ((DateTime.UtcNow - _lstOrders[0].DtUpdate).TotalHours > _parHourOld)
                            {
                                _lstOrders.RemoveAt(0);
                                Log(String.Format("Remove first. Count={0}", _lstOrders.Count));
                            }
                        }
                    }
                    else //found process upate
                    {
                        //TODO update
                    }
                }
            }
        }