public void OnNext(byte[] data, long sequence, bool endOfBatch)
        {
            object getObject = StreamConversion.ByteArrayToObject(data);

            if (getObject is Order)
            {
                _receviedOrder = getObject as Order;
            }
            if (getObject is Trade)
            {
                _receivedTrade = getObject as Trade;
            }
            if (getObject is LimitOrderBook)
            {
                _receivedLimitOrderBook = getObject as LimitOrderBook;
            }
            if (getObject is Depth)
            {
                _receivedDepth = getObject as Depth;
            }
            if (getObject is BBO)
            {
                _receivedBbo = getObject as BBO;
            }
        }
Beispiel #2
0
 /// <summary>
 /// Deep copy
 /// </summary>
 /// <returns></returns>
 public object Clone()
 {
     // using (MemoryStream stream = new MemoryStream())
     //{
     if (this.GetType().IsSerializable)
     {
         return(StreamConversion.ByteArrayToObject(StreamConversion.ObjectToByteArray(this)));
     }
     return(null);
     // }
 }
Beispiel #3
0
 public void OnNext(byte[] data, long sequence, bool endOfBatch)
 {
     try
     {
         object obj = StreamConversion.ByteArrayToObject(data);
         _persistRepository.AddUpdate(obj);
     }
     catch (Exception exception)
     {
         Logger.Error(exception, _type.FullName, "OnNext");
     }
 }
        /// <summary>
        /// Event handler for the LimitOrderBook changed event published by the output disruptor
        /// </summary>
        /// <param name="data"></param>
        /// <param name="sequence"></param>
        /// <param name="endOfBatch"></param>
        public void OnNext(byte[] data, long sequence, bool endOfBatch)
        {
            object getObject = StreamConversion.ByteArrayToObject(data);

            if (getObject is LimitOrderBook)
            {
                this.OnOrderBookChanged(getObject as LimitOrderBook);
            }
            else
            {
                throw new FormatException("Expected a type of CoinExchange.TradesDomain.Model.OrderMatchingEngine.LimitOrderBook but was " + getObject.GetType());
            }
        }
        /// <summary>
        /// Load last snaphost
        /// </summary>
        /// <returns></returns>
        public ExchangeEssentialsList LoadLastSnapshot()
        {
            Snapshot snapshot   = null;
            var      initialize = _store.Advanced.GetFrom(Constants.LastSnapshotSearch).GroupBy(i => i.StreamId).Select(g => g.First()).ToList();

            for (int i = 0; i < initialize.Count; i++)
            {
                snapshot = _store.Advanced.GetSnapshot(initialize[i].StreamId, int.MaxValue);
            }
            _lastSnaphot = snapshot;
            if (snapshot != null)
            {
                JObject jObject = JObject.Parse(snapshot.Payload.ToString());
                byte[]  array   = jObject["$value"].ToObject <byte[]>();
                object  list    = StreamConversion.ByteArrayToObject(array);
                ExchangeEssentialsList exchangeEssentialsList = list as ExchangeEssentialsList;
                _loadFrom = exchangeEssentialsList.LastSnapshotDateTime;
                return(exchangeEssentialsList);
            }
            return(null);
        }