// **********************************************************************

    public void Write(DateTime dateTime, OwnOrder order)
    {
      dw.WriteRecHeader(sid, dateTime);

      if(order.Id == 0 && order.Price == 0)
        dw.Write((byte)OrderFlags.DropAll);
      else
      {
        OrderFlags flags;

        switch(order.Type)
        {
          case OwnOrderType.Regular:
            flags = OrderFlags.Active;
            break;

          case OwnOrderType.Stop:
            flags = OrderFlags.Active | OrderFlags.Stop;
            break;

          default:
            flags = OrderFlags.None;
            break;
        }

        if(order.Id > 0)
          flags |= OrderFlags.External;

        dw.Write((byte)flags);
        dw.WriteLeb128(order.Id);
        dw.WriteLeb128(order.Price);
        dw.WriteLeb128(order.Quantity);
      }
    }
    // **********************************************************************

    public override void Read(bool push)
    {
      OrderFlags flags = (OrderFlags)dr.ReadByte();
      OwnOrder order;

      if((flags & OrderFlags.DropAll) != 0)
        order = new OwnOrder();
      else
      {
        OwnOrderType type;

        if((flags & OrderFlags.Active) != 0)
        {
          if((flags & OrderFlags.Stop) != 0)
            type = OwnOrderType.Stop;
          else
            type = OwnOrderType.Regular;
        }
        else
          type = OwnOrderType.None;

        order = new OwnOrder(type, dr.ReadLeb128(),
          (int)dr.ReadLeb128(), (int)dr.ReadLeb128(), null);
      }

      if(push && Handler != null)
        Handler(Security.Key, order);
    }
Exemple #3
0
        // **********************************************************************

        public override void Read(bool push)
        {
            long id = dr.ReadInt64();
            int  p  = dr.ReadPackInt();
            int  q  = dr.ReadPackInt();

            if (push && Handler != null)
            {
                OwnOrder order;

                if (p < 0)
                {
                    order = new OwnOrder(id, -p);
                }
                else if (id < 0)
                {
                    order = new OwnOrder(OwnOrderType.Stop, id, p, q, null);
                }
                else
                {
                    order = new OwnOrder(OwnOrderType.Regular, id, p, q, null);
                }

                Handler(Security.Key, order);
            }
        }
Exemple #4
0
        void PutOwnOrder(long id, int price, int qty)
        {
            OwnOrder order = new OwnOrder(id, price, qty, "tag");

            if (writeOrders)
            {
                try
                {
                    lock (pLock)
                    {
                        WriteRecHeader(orderId);

                        bw.Write(order.Id);
                        bw.Write(order.IsActive ? order.Price : -order.Price);
                        bw.Write(order.Quantity);
                    }
                }
                catch (Exception e)
                {
                    SetError(e.Message);
                }
            }

            //  Receiver.PutOwnOrder(order);
        }
Exemple #5
0
        // **********************************************************************

        void ActivateStopOrder(Transaction t, OwnAction newAction)
        {
            // MktProvider.Log.Put("Стоп-заявка " + t.Descr + " "
            //     + t.TId + " @" + t.Price + " активирована");

            OwnOrder ownOrder = new OwnOrder(t.TId, t.Price);

            t.Source = newAction;
            t.Execute();
            ProcessTList();

            Position.StopOrderActivated(t);
            MktProvider.Receiver.PutOwnOrder(ownOrder);
        }
    // **********************************************************************

    public override void Read(bool push)
    {
      long id = dr.ReadInt64();
      int p = dr.ReadPackInt();
      int q = dr.ReadPackInt();

      if(push && Handler != null)
      {
        OwnOrder order;

        if(p < 0)
          order = new OwnOrder(id, -p);
        else if(id < 0)
          order = new OwnOrder(OwnOrderType.Stop, id, p, q, null);
        else
          order = new OwnOrder(OwnOrderType.Regular, id, p, q, null);

        Handler(Security.Key, order);
      }
    }
Exemple #7
0
        // **********************************************************************

        public override void Read(bool push)
        {
            OrderFlags flags = (OrderFlags)dr.ReadByte();
            OwnOrder   order;

            if ((flags & OrderFlags.DropAll) != 0)
            {
                order = new OwnOrder();
            }
            else
            {
                OwnOrderType type;

                if ((flags & OrderFlags.Active) != 0)
                {
                    if ((flags & OrderFlags.Stop) != 0)
                    {
                        type = OwnOrderType.Stop;
                    }
                    else
                    {
                        type = OwnOrderType.Regular;
                    }
                }
                else
                {
                    type = OwnOrderType.None;
                }

                order = new OwnOrder(type, dr.ReadLeb128(),
                                     (int)dr.ReadLeb128(), (int)dr.ReadLeb128());
            }

            if (push && Handler != null)
            {
                Handler(Security.Key, order);
            }
        }
Exemple #8
0
        // **********************************************************************

        public void Write(DateTime dateTime, OwnOrder order)
        {
            dw.WriteRecHeader(sid, dateTime);

            if (order.Id == 0 && order.Price == 0)
            {
                dw.Write((byte)OrderFlags.DropAll);
            }
            else
            {
                OrderFlags flags;

                switch (order.Type)
                {
                case OwnOrderType.Regular:
                    flags = OrderFlags.Active;
                    break;

                case OwnOrderType.Stop:
                    flags = OrderFlags.Active | OrderFlags.Stop;
                    break;

                default:
                    flags = OrderFlags.None;
                    break;
                }

                if (order.Id > 0)
                {
                    flags |= OrderFlags.External;
                }

                dw.Write((byte)flags);
                dw.WriteLeb128(order.Id);
                dw.WriteLeb128(order.Price);
                dw.WriteLeb128(order.Quantity);
            }
        }
Exemple #9
0
        // **********************************************************************

        void IDataReceiver.PutOwnOrder(OwnOrder order)
        {
            if (writeOrders)
            {
                try
                {
                    lock (pLock)
                    {
                        WriteRecHeader(orderId);

                        bw.Write(order.Id);
                        bw.Write(order.IsActive ? order.Price : -order.Price);
                        bw.Write(order.Quantity);
                    }
                }
                catch (Exception e)
                {
                    SetError(e.Message);
                }
            }

            Receiver.PutOwnOrder(order);
        }
Exemple #10
0
 void IDataReceiver.PutOwnOrder(OwnOrder order)
 {
 }