private static void ConnectToEventstore() { OutputWriter.WriteLine(ConsoleColor.Yellow, "Connecting to eventstore..."); _eventstoreHandler = new EventStoreHandler(GlobalConfig.EventstoreEndpoint); _eventstoreHandler.Connect(); OutputWriter.WriteLine(ConsoleColor.Green, "Yay, I am connected!"); }
private static List <Ticker> GetLastTickersFromEventstore(int tickersToFetch) { using (var eventStoreHandler = new EventStoreHandler(GlobalConfig.EventstoreEndpoint)) { eventStoreHandler.Connect(); var eventstoreEvents = eventStoreHandler.ReadLastEvents(GlobalConfig.TickerStreamName, tickersToFetch); var tickers = eventstoreEvents.Select(GetTickerFromEvent).ToList(); return(tickers); } }
static void Main(string[] args) { List <Ticker> trainingTickers = GetLastTickersFromEventstore(tickersToFetch: 4000); #region Train prediction network var predictionConfig = new PredictionConfig() { NumberOfPreviousTickers = 10, //input nodes PredictedColumnName = "last_price", //output node InputColumnNames = trainingTickers.First().Keys.ToList() //input columns }; var factory = new PredictionMachineFactory(predictionConfig, trainingTickers); var predictionMachine = factory.CreateAndTrainMachine(); #endregion TestPredictionsInSimulator(predictionMachine, trainingTickers); #region Save predictionMachine in Eventstore var serializedPredictionMachine = SerializationHelper.SerializeBot(predictionMachine); using (var eventStoreHandler = new EventStoreHandler(GlobalConfig.EventstoreEndpoint)) { eventStoreHandler.Connect(); eventStoreHandler.WriteBytes( streamId: GlobalConfig.PredictionMachinesStreamName, data: serializedPredictionMachine, datatype: predictionMachine.GetType().FullName, metadata: Encoding.UTF8.GetBytes(""), isJson: false ).Wait(); } #endregion OutputWriter.WriteLine(); OutputWriter.WriteLine("Press enter to exit"); Console.ReadLine(); }