Example #1
0
        private static Ticker ExtractTickerFromEvent(EventstoreEvent incomingEvent)
        {
            var json = Encoding.UTF8.GetString(incomingEvent.Data);

            var ticker = JsonConvert.DeserializeObject <Ticker>(json);

            return(ticker);
        }
Example #2
0
        private static Ticker GetTickerFromEvent(EventstoreEvent rawTicker)
        {
            string json = Encoding.UTF8.GetString(rawTicker.Data);

            var ticker = JsonConvert.DeserializeObject <Ticker>(json);

            ticker.Remove("timestamp");

            return(ticker);
        }
Example #3
0
        private EventstoreEvent MapEventstoreEvent(ResolvedEvent resolvedEvent)
        {
            var resultingEvent = new EventstoreEvent()
            {
                Data         = resolvedEvent.Event.Data,
                Metadata     = Encoding.UTF8.GetString(resolvedEvent.Event.Metadata),
                TimestampUtc = resolvedEvent.Event.Created,
                Datatype     = resolvedEvent.Event.EventType,
            };

            return(resultingEvent);
        }
Example #4
0
        private static void HandleNewPredictionMachine(EventstoreEvent incomingEvent)
        {
            try
            {
                IPredictionMachine newPredictionMachine = SerializationHelper.DeserializeBot(incomingEvent.Data);
                _simulator.UpdatePredictionMachine(newPredictionMachine);

                OutputWriter.WriteLine(ConsoleColor.Cyan, "Got new PredictionMachine, updated!");

                PreloadPreviousTickersToWarmUp(EventstoreHandler);
            }
            catch (Exception ex)
            {
                OutputWriter.WriteLine(ConsoleColor.Red, $"Could not update prediction machine :(  {ex.Message}");
            }
        }
Example #5
0
        private static void HandleNewTicker(EventstoreEvent incomingEvent)
        {
            Ticker ticker = ExtractTickerFromEvent(incomingEvent);

            _simulator.NewTickerArrived(ticker);
        }