private void OnUpdateOpenedOrders(AccountInfo account, Ticker ticker, byte[] data)
        {
            string text  = UTF8Encoding.Default.GetString(data);
            JArray items = (JArray)JsonConvert.DeserializeObject(text);
            List <OpenedOrderInfo> openedOrders = ticker == null ? account.OpenedOrders : ticker.OpenedOrders;

            lock (openedOrders) {
                openedOrders.Clear();

                foreach (JObject item in items)
                {
                    string          symbol = item.Value <string>("symbol");
                    OpenedOrderInfo info   = new OpenedOrderInfo(account, ticker);
                    info.OrderId      = item.Value <string>("orderId");
                    info.Type         = item.Value <string>("side")[0] == 'B' ? OrderType.Buy : OrderType.Sell;
                    info.ValueString  = item.Value <string>("price");
                    info.AmountString = item.Value <string>("orderQty");
                    info.TotalString  = info.AmountString;
                    info.DateString   = item.Value <string>("transactTime");
                    info.TickerName   = symbol;
                    openedOrders.Add(info);
                }
            }
            if (ticker != null)
            {
                ticker.RaiseOpenedOrdersChanged();
            }
        }
示例#2
0
        public List <string> GetOpenedOrdersChangeNotifications()
        {
            List <string> res = new List <string>();

            if (PrevOpenedOrders == null)
            {
                PrevOpenedOrders = new OpenedOrderInfo[0];
            }
            for (int i = 0; i < PrevOpenedOrders.Length; i++)
            {
                var po = PrevOpenedOrders[i];
                var oo = OpenedOrders.FirstOrDefault(o => o.OrderId == PrevOpenedOrders[i].OrderId);
                if (oo == null)
                {
                    res.Add("Order " + po.OrderId + " completely filled");
                }
                else if (oo.Amount != po.Amount)
                {
                    res.Add("Order " + po.OrderId + " partially filled");
                }
            }
            for (int i = 0; i < OpenedOrders.Count; i++)
            {
                var oo = OpenedOrders[i];
                var po = PrevOpenedOrders.FirstOrDefault(p => p.OrderId == oo.OrderId);
                if (po == null)
                {
                    res.Add("New order '" + oo.OrderId + "' added. " + oo.TickerName + " rate = " + oo.ValueString + " amount = " + oo.AmountString);
                }
            }
            PrevOpenedOrders = new OpenedOrderInfo[OpenedOrders.Count];
            OpenedOrders.CopyTo(PrevOpenedOrders);
            return(res);
        }
示例#3
0
 internal void SaveOpenedOrders()
 {
     PrevOpenedOrders = new OpenedOrderInfo[OpenedOrders.Count];
     for (int i = 0; i < OpenedOrders.Count; i++)
     {
         PrevOpenedOrders[i] = OpenedOrders[i];
     }
 }
示例#4
0
        protected override OpenedOrderInfo InitializeOpenedOrderItem(string[] item, Ticker ticker)
        {
            OpenedOrderInfo t = new OpenedOrderInfo(null, ticker);

            t.OrderId      = item[0];
            t.Ticker       = ticker;
            t.ValueString  = item[4];
            t.AmountString = item[6];
            t.TotalString  = item[7];
            t.Type         = item[13][0] == 'B'? OrderType.Buy: OrderType.Sell;
            t.Date         = FromUnixTime(FastValueConverter.ConvertPositiveLong(item[19]));

            return(t);
        }
        protected void MakeCancel()
        {
            OpenedOrderInfo info = (OpenedOrderInfo)this.gvOpenedOrders.GetFocusedRow();

            if (info == null)
            {
                return;
            }
            if (!Ticker.Cancel(info))
            {
                XtraMessageBox.Show("Error canceling order. Try again later.");
            }
            Ticker.UpdateOpenedOrders();
            this.gvOpenedOrders.RefreshData();
        }
        protected void MakeCancel()
        {
            OpenedOrderInfo info = (OpenedOrderInfo)this.gvOpenedOrders.GetFocusedRow();

            if (info == null)
            {
                return;
            }
            if (!Ticker.Cancel(info))
            {
                NotificationManager.Notify("Cancel Order", "Error canceling order. Check Log for last errors.");
                return;
            }
            Ticker.UpdateOpenedOrders();
            this.gvOpenedOrders.RefreshData();
        }
示例#7
0
 public bool Cancel(OpenedOrderInfo info)
 {
     return(Exchange.Cancel(Exchange.DefaultAccount, info.OrderId));
 }
 public override bool CancelOrder(TickerBase ticker, OpenedOrderInfo info)
 {
     throw new NotImplementedException();
 }