Пример #1
0
 public void DoCancel(string Account, string OrderPID, OrderProcessor.Side Side)
 {
     lock (this)
     {
         var orders = from order in Order.Valids(OrderPID)
                      where order.BuySell == Side
                      select order.KeyNo;
         _Cancel(Account, orders);
     }
 }
Пример #2
0
 public void DoCancel(string Account, string OrderPID, OrderProcessor.Side Side, double Max, double Min)
 {
     lock (this)
     {
         var orders = from order in Order.Valids(OrderPID)
                      where order.Price > Max || order.Price < Min
                      select order.KeyNo;
         _Cancel(Account, orders);
     }
 }
Пример #3
0
 public string OrderStatus(string OrderPID, OrderProcessor.Side side, double max, double min)
 {
     if (string.IsNullOrEmpty(OrderPID) || (max == 0D && min == 0D))
     {
         return(string.Empty);
     }
     lock (this)
     {
         var orders = from order in Order.Valids(OrderPID)
                      where order.BuySell == side && (order.Price > max || order.Price < min)
                      select new SelectedOrder
         {
             Qty   = order.AfterQty,
             OrdNo = order.OrdNo
         };
         int qty = orders.Sum(e => e.Qty);
         return(qty == 0 ? "" : qty.ToString());
     }
 }
Пример #4
0
 public string OrderStatus(string OrderPID, OrderProcessor.Side side)
 {
     if (string.IsNullOrEmpty(OrderPID))
     {
         return(string.Empty);
     }
     lock (this)
     {
         var orders = from order in Order.Valids(OrderPID)
                      where order.BuySell == side
                      select new SelectedOrder
         {
             Qty   = order.SumQty,
             OrdNo = order.OrdNo
         };
         int qty = orders.Sum(e => e.Qty);
         return(qty == 0 ? "" : qty.ToString());
     }
 }
Пример #5
0
        private void OnClick(CellBase sender, EventArgs e)
        {
            MouseEventArgs me    = (MouseEventArgs)e;
            double         price = (double)((TextCell)sender.Tag).Cell.Value;

            OrderProcessor.Side side = OrderProcessor.Side.B;
            if ((sender.Cell.Column.Index + 1) == (int)ColumnType.Sell)
            {
                side = OrderProcessor.Side.S;
            }
            if (me.Button == MouseButtons.Left)
            {
                Utility.Log(this, "Order", $"{side} Side: {price}");

                Core.Instance.DoOrder(Account, Exchange, OrderHead, YM, YM2, side, price);
            }
            else if (me.Button == MouseButtons.Right)
            {
                Utility.Log(this, "Cancel", $"{side} Side: {price}");
                Core.Instance.DoCancel(Account, OrderPID, side, price);
            }
        }
Пример #6
0
        public void DoOrder(string Account, string Exchange, string OrderHead, string YM, string YM2, OrderProcessor.Side Side, double Price, int qty = -1)
        {
            if (!_CanOrder(Exchange, OrderHead, YM, YM2, Price))
            {
                return;
            }

            string msg;

            //int qty = Utility.Load<int>("ORDERSETTING", "LOTS");
            if (qty == -1)
            {
                qty = Utility.Load <int>("ORDERSETTING", "LOTS");
            }

            if (Utility.Load <bool>("ORDERSETTING", "ORDERALERT"))
            {
                //下單前詢問
                Color color = Side == OrderProcessor.Side.B ? Color.Crimson : Color.ForestGreen;
                if (!AlertBox.Alert(null, AlertBoxButton.OKCancel, "下單",
                                    new MsgLine("帳號", Account, color),
                                    new MsgLine("交易所", Exchange, color),
                                    new MsgLine("商品", OrderHead, color),
                                    new MsgLine("月份", !string.IsNullOrEmpty(YM2) ? $"{YM}/{YM2}" : YM, color),
                                    new MsgLine("買賣", Side, color),
                                    new MsgLine("口數", qty.ToString("#,##0"), color),
                                    new MsgLine("價格", Price, color)))
                {
                    Utility.Log(this, "Order", "Cancel");
                    return;
                }
            }

            if (string.IsNullOrEmpty(YM2))
            {
                bool re = Order.Order(Account, Exchange, OrderHead, YM, Side, qty, Price, out msg);
                Utility.Log(this, "Order", msg);
                if (!re)
                {
                    AlertBox.AlertWithoutReply(null, AlertBoxButton.Error_OK, "下單錯誤",
                                               new MsgLine("帳號", Account),
                                               new MsgLine("交易所", Exchange),
                                               new MsgLine("商品", OrderHead),
                                               new MsgLine("月份", YM),
                                               new MsgLine("買賣", Side),
                                               new MsgLine("口數", qty),
                                               new MsgLine("價格", Price),
                                               new MsgLine("錯誤", msg, Color.Crimson));
                }
            }
            else
            {
                bool re = Order.SpreadOrder(Account, Exchange, OrderHead, YM, YM2, Side, qty, Price, out msg);
                Utility.Log(this, "SpreadOrder", msg);
                if (!re)
                {
                    AlertBox.AlertWithoutReply(null, AlertBoxButton.Error_OK, "轉倉下單錯誤",
                                               new MsgLine("帳號", Account),
                                               new MsgLine("交易所", Exchange),
                                               new MsgLine("商品", OrderHead),
                                               new MsgLine("月份", !string.IsNullOrEmpty(YM2) ? $"{YM}/{YM2}" : YM),
                                               new MsgLine("買賣", Side),
                                               new MsgLine("口數", qty),
                                               new MsgLine("價格", Price),
                                               new MsgLine("錯誤", msg, Color.Crimson));
                }
            }
        }
Пример #7
0
 public void DoOrder(Tick t, OrderProcessor.Side Side, double Price)
 {
     DoOrder(t.Account, t.Exchange, t.OrderHead, t.YM, t.YM2, Side, Price);
 }