private static Ticker ExtractTickerFromEvent(EventstoreEvent incomingEvent) { var json = Encoding.UTF8.GetString(incomingEvent.Data); var ticker = JsonConvert.DeserializeObject <Ticker>(json); return(ticker); }
private static Ticker GetTickerFromEvent(EventstoreEvent rawTicker) { string json = Encoding.UTF8.GetString(rawTicker.Data); var ticker = JsonConvert.DeserializeObject <Ticker>(json); ticker.Remove("timestamp"); return(ticker); }
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); }
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}"); } }
private static void HandleNewTicker(EventstoreEvent incomingEvent) { Ticker ticker = ExtractTickerFromEvent(incomingEvent); _simulator.NewTickerArrived(ticker); }