Ejemplo n.º 1
0
        protected void ApplyIncrementalUpdate(string rateString, string amountString, List <OrderBookEntry> list, bool ascending)
        {
            double value  = FastValueConverter.Convert(rateString);
            double value2 = Convert.ToDouble(rateString);

            if (!IsEqual(value, value2))
            {
                throw new Exception();
            }
            double amount = FastValueConverter.Convert(amountString);
            int    index  = 0;

            if (amount == 0)
            {
                foreach (OrderBookEntry e in list)
                {
                    if (IsEqual(e.Value, value))
                    {
                        list.Remove(e);
                        return;
                    }
                }
                throw new DllNotFoundException("entry not found -> with value " + value + " and amount " + amount);
            }
            if (ascending)
            {
                foreach (OrderBookEntry e in list)
                {
                    if (IsEqual(e.Value, value))
                    {
                        e.AmountString = amountString;
                        //if(!e.ValueString.StartsWith(rateString))
                        //    throw new DllNotFoundException();
                        return;
                    }
                    if (e.Value > value)
                    {
                        OrderBookEntry ee = new OrderBookEntry()
                        {
                            ValueString = rateString, AmountString = amountString
                        };
                        list.Insert(index, ee);
                        return;
                    }
                    index++;
                }
            }
            else
            {
                foreach (OrderBookEntry e in list)
                {
                    if (IsEqual(e.Value, value))
                    {
                        e.AmountString = amountString;
                        //if(!e.ValueString.StartsWith(rateString))
                        //    throw new DllNotFoundException();
                        return;
                    }
                    if (e.Value < value)
                    {
                        OrderBookEntry ee = new OrderBookEntry()
                        {
                            ValueString = rateString, AmountString = amountString
                        };
                        list.Insert(index, ee);
                        return;
                    }
                    index++;
                }
            }
            OrderBookEntry addE = new OrderBookEntry()
            {
                ValueString = rateString, AmountString = amountString
            };

            list.Add(addE);
        }
Ejemplo n.º 2
0
        protected void ApplyIncrementalUpdate(string rateString, string amountString, List <OrderBookEntry> list, bool ascending)
        {
            double value  = FastValueConverter.Convert(rateString);
            double amount = FastValueConverter.Convert(amountString);
            int    index  = 0;

            if (amount == 0)
            {
                for (int i = 0; i < list.Count; i++)
                {
                    OrderBookEntry e = list[i];
                    if (IsEqual(e.Value, value))
                    {
                        list.Remove(e);
                        return;
                    }
                }
                if (EnableValidationOnRemove)
                {
                    IsDirty = true;
                }
                return;
            }
            if (ascending)
            {
                for (int i = 0; i < list.Count; i++)
                {
                    OrderBookEntry e = list[i];
                    if (IsEqual(e.Value, value))
                    {
                        e.AmountString = amountString;
                        return;
                    }
                    if (e.Value > value)
                    {
                        OrderBookEntry ee = new OrderBookEntry()
                        {
                            ValueString = rateString, AmountString = amountString
                        };
                        list.Insert(index, ee);
                        return;
                    }
                    index++;
                }
            }
            else
            {
                for (int i = 0; i < list.Count; i++)
                {
                    OrderBookEntry e = list[i];
                    if (IsEqual(e.Value, value))
                    {
                        e.AmountString = amountString;
                        return;
                    }
                    if (e.Value < value)
                    {
                        OrderBookEntry ee = new OrderBookEntry()
                        {
                            ValueString = rateString, AmountString = amountString
                        };
                        list.Insert(index, ee);
                        return;
                    }
                    index++;
                }
            }
            OrderBookEntry addE = new OrderBookEntry()
            {
                ValueString = rateString, AmountString = amountString
            };

            list.Add(addE);
        }
Ejemplo n.º 3
0
        protected void ApplyIncrementalUpdate(long id, OrderBookUpdateType type, string rateString, string amountString, List <OrderBookEntry> list, bool ascending)
        {
            int index = 0;

            if (type == OrderBookUpdateType.Remove)
            {
                foreach (OrderBookEntry e in list)
                {
                    if (e.Id == id)
                    {
                        list.Remove(e);
                        return;
                    }
                }
                //throw new DllNotFoundException("entry not found -> with value " + value + " and amount " + amount);
                return;
            }
            double amount = FastValueConverter.Convert(amountString);

            if (type == OrderBookUpdateType.Modify)
            {
                foreach (OrderBookEntry e in list)
                {
                    if (e.Id == id)
                    {
                        e.Amount = amount;
                        return;
                    }
                }
                //throw new DllNotFoundException("entry not found -> with value " + value + " and amount " + amount);
                return;
            }
            double value = FastValueConverter.Convert(rateString);

            if (ascending)
            {
                foreach (OrderBookEntry e in list)
                {
                    if (e.Value > value)
                    {
                        OrderBookEntry ee = new OrderBookEntry()
                        {
                            ValueString = rateString, AmountString = amountString, Id = id
                        };
                        list.Insert(index, ee);
                        return;
                    }
                    index++;
                }
            }
            else
            {
                foreach (OrderBookEntry e in list)
                {
                    if (e.Value < value)
                    {
                        OrderBookEntry ee = new OrderBookEntry()
                        {
                            ValueString = rateString, AmountString = amountString, Id = id
                        };
                        list.Insert(index, ee);
                        return;
                    }
                    index++;
                }
            }
            OrderBookEntry addE = new OrderBookEntry()
            {
                ValueString = rateString, AmountString = amountString, Id = id
            };

            list.Add(addE);
        }
Ejemplo n.º 4
0
        protected void ApplyIncrementalUpdate(long id, OrderBookUpdateType type, string rateString, string amountString, List <OrderBookEntry> list, bool ascending)
        {
            int index = 0;

            if (type == OrderBookUpdateType.Remove)
            {
                for (int i = 0; i < list.Count; i++)
                {
                    OrderBookEntry e = list[i];
                    if (e.Id == id)
                    {
                        list.Remove(e);
                        return;
                    }
                }
                if (EnableValidationOnRemove)
                {
                    IsDirty = true;
                }
                return;
            }
            double amount = FastValueConverter.Convert(amountString);

            if (type == OrderBookUpdateType.Modify)
            {
                for (int i = 0; i < list.Count; i++)
                {
                    OrderBookEntry e = list[i];
                    if (e.Id == id)
                    {
                        e.Amount = amount;
                        return;
                    }
                }
                if (EnableValidationOnRemove)
                {
                    IsDirty = true;
                }
                return;
            }
            double value = FastValueConverter.Convert(rateString);

            if (ascending)
            {
                for (int i = 0; i < list.Count; i++)
                {
                    OrderBookEntry e = list[i];
                    if (e.Value > value)
                    {
                        OrderBookEntry ee = new OrderBookEntry()
                        {
                            ValueString = rateString, AmountString = amountString, Id = id
                        };
                        list.Insert(index, ee);
                        return;
                    }
                    index++;
                }
            }
            else
            {
                for (int i = 0; i < list.Count; i++)
                {
                    OrderBookEntry e = list[i];
                    if (e.Value < value)
                    {
                        OrderBookEntry ee = new OrderBookEntry()
                        {
                            ValueString = rateString, AmountString = amountString, Id = id
                        };
                        list.Insert(index, ee);
                        return;
                    }
                    index++;
                }
            }
            OrderBookEntry addE = new OrderBookEntry()
            {
                ValueString = rateString, AmountString = amountString, Id = id
            };

            list.Add(addE);
        }