Esempio n. 1
0
        private async Task DoReceiveBook(BookBase bookBase)
        {
            if (_gdaxFile == null || DateTime.Today != _fileDate)
            {
                OpenFile();
            }

            if (_productBook == null)
            {
                _productBook = await _gdaxClient.GetProductBook(_productType, BookLevel.Full);

                _gdaxFile.Serialize(_productBook, DateTime.UtcNow);
                Program.Log.Info("Product book loaded.");
            }

            if (_productBook.Update(bookBase))
            {
                _gdaxFile.Serialize(bookBase);
            }
            else
            {
                _productBook = null;
                Program.Log.Error("Some event are missing, book order will be fully reloaded.");
            }
        }
Esempio n. 2
0
        private void OpenFile()
        {
            ClosePreviousFile();

            _fileDate = DateTime.Today;

            _filename = Path.Combine(_rootPath, GdaxFile.GetFilename(_fileDate, 60));
            _gdaxFile = GdaxFile.OpenWrite(_filename);
            Program.Log.Info($"File '{_filename}' is open");

            if (_productBook != null)
            {
                _gdaxFile.Serialize(_productBook, DateTime.UtcNow);
                Program.Log.Info("Current product book added to file");
            }
        }