private static async Task GenerateAsstToBitgoMap()
        {
            var broker         = "jetwallet";
            var nosqlWriterUrl = "http://192.168.10.80:5123";

            var clientAsset = new MyNoSqlServer.DataWriter.MyNoSqlServerDataWriter <BitgoAssetMapEntity>(() => nosqlWriterUrl, BitgoAssetMapEntity.TableName, true);

            var list = new List <BitgoAssetMapEntity>();

            list.Add(BitgoAssetMapEntity.Create(broker, "BTC", "6054ba9ca9cc0e0024a867a7d8b401b2", "tbtc"));
            list.Add(BitgoAssetMapEntity.Create(broker, "XLM", "6054bc003dc1af002b0d54bf5b552f28", "txlm"));
            list.Add(BitgoAssetMapEntity.Create(broker, "LTC", "6054be73b765620006aa87311f43bd47", "tltc"));
            list.Add(BitgoAssetMapEntity.Create(broker, "XRP", "60584aaded0090000628ce59c01f3a5e", "txrp"));
            list.Add(BitgoAssetMapEntity.Create(broker, "BCH", "60584b79fd3e0500669e2cf9654d726b", "tbch"));
            list.Add(BitgoAssetMapEntity.Create(broker, "ALGO", "60584becbc3e2600240548d78e61c02b", "talgo"));
            list.Add(BitgoAssetMapEntity.Create(broker, "EOS", "60584dcc6f5d31001d5a59371aeeb60a", "teos"));

            await clientAsset.CleanAndKeepMaxPartitions(0);

            await clientAsset.BulkInsertOrReplaceAsync(list);



            var clientCoin = new MyNoSqlServer.DataWriter.MyNoSqlServerDataWriter <BitgoCoinEntity>(() => nosqlWriterUrl, BitgoCoinEntity.TableName, true);

            var listCoin = new List <BitgoCoinEntity>();

            listCoin.Add(BitgoCoinEntity.Create("algo", 6));
            listCoin.Add(BitgoCoinEntity.Create("bch", 8));
            listCoin.Add(BitgoCoinEntity.Create("btc", 8));
            listCoin.Add(BitgoCoinEntity.Create("dash", 6));
            listCoin.Add(BitgoCoinEntity.Create("eos", 4));
            //listCoin.Add(BitgoCoinEntity.Create("eth", 18));
            //listCoin.Add(BitgoCoinEntity.Create("hbar", 0));
            listCoin.Add(BitgoCoinEntity.Create("ltc", 8));
            listCoin.Add(BitgoCoinEntity.Create("trx", 6));
            listCoin.Add(BitgoCoinEntity.Create("xlm", 7));
            listCoin.Add(BitgoCoinEntity.Create("xrp", 6));
            listCoin.Add(BitgoCoinEntity.Create("zec", 8));

            listCoin.Add(BitgoCoinEntity.Create("talgo", 6));
            listCoin.Add(BitgoCoinEntity.Create("tbch", 8));
            listCoin.Add(BitgoCoinEntity.Create("tbtc", 8));
            listCoin.Add(BitgoCoinEntity.Create("tdash", 6));
            listCoin.Add(BitgoCoinEntity.Create("teos", 4));
            //listCoin.Add(BitgoCoinEntity.Create("teth", 18));
            //listCoin.Add(BitgoCoinEntity.Create("thbar", 0));
            listCoin.Add(BitgoCoinEntity.Create("tltc", 8));
            listCoin.Add(BitgoCoinEntity.Create("ttrx", 6));
            listCoin.Add(BitgoCoinEntity.Create("txlm", 7));
            listCoin.Add(BitgoCoinEntity.Create("txrp", 6));
            listCoin.Add(BitgoCoinEntity.Create("tzec", 8));

            await clientCoin.CleanAndKeepMaxRecords(BitgoCoinEntity.TableName, 0);

            await clientCoin.BulkInsertOrReplaceAsync(listCoin);
        }
Exemple #2
0
        private async Task DoProcess()
        {
            try
            {
                while (!_token.IsCancellationRequested)
                {
                    try
                    {
                        foreach (var pair in _brokers.ToList())
                        {
                            var brokerId = pair.Key;
                            var symbol   = pair.Value;

                            var writerBidAsk = new MyNoSqlServer.DataWriter.MyNoSqlServerDataWriter <CandleBidAskNoSql>(
                                Program.ReloadedSettings(model => model.MyNoSqlWriterUrl),
                                CandleBidAskNoSql.TableNameMinute(brokerId), true);

                            await writerBidAsk.CleanAndKeepMaxRecords(CandleBidAskNoSql.GeneratePartitionKey(symbol, DateTime.UtcNow.AddDays(-Program.Settings.DaysToKeepMinutes - 1).Date), 0);

                            await writerBidAsk.CleanAndKeepMaxRecords(CandleBidAskNoSql.GeneratePartitionKey(symbol, DateTime.UtcNow.AddDays(-Program.Settings.DaysToKeepMinutes - 2).Date), 0);

                            await writerBidAsk.CleanAndKeepMaxRecords(CandleBidAskNoSql.GeneratePartitionKey(symbol, DateTime.UtcNow.AddDays(-Program.Settings.DaysToKeepMinutes - 3).Date), 0);

                            await writerBidAsk.CleanAndKeepMaxRecords(CandleBidAskNoSql.GeneratePartitionKey(symbol, DateTime.UtcNow.AddDays(-Program.Settings.DaysToKeepMinutes - 4).Date), 0);

                            await writerBidAsk.CleanAndKeepMaxRecords(CandleBidAskNoSql.GeneratePartitionKey(symbol, DateTime.UtcNow.AddDays(-Program.Settings.DaysToKeepMinutes - 5).Date), 0);

                            await writerBidAsk.CleanAndKeepMaxRecords(CandleBidAskNoSql.GeneratePartitionKey(symbol, DateTime.UtcNow.AddDays(-Program.Settings.DaysToKeepMinutes - 6).Date), 0);

                            await writerBidAsk.CleanAndKeepMaxRecords(CandleBidAskNoSql.GeneratePartitionKey(symbol, DateTime.UtcNow.AddDays(-Program.Settings.DaysToKeepMinutes - 7).Date), 0);

                            var writerTrade = new MyNoSqlServer.DataWriter.MyNoSqlServerDataWriter <CandleTradeNoSql>(
                                Program.ReloadedSettings(model => model.MyNoSqlWriterUrl),
                                CandleTradeNoSql.TableNameMinute(brokerId), true);

                            await writerTrade.CleanAndKeepMaxRecords(CandleTradeNoSql.GeneratePartitionKey(symbol, DateTime.UtcNow.AddDays(-Program.Settings.DaysToKeepMinutes - 1).Date), 0);

                            await writerTrade.CleanAndKeepMaxRecords(CandleTradeNoSql.GeneratePartitionKey(symbol, DateTime.UtcNow.AddDays(-Program.Settings.DaysToKeepMinutes - 2).Date), 0);

                            await writerTrade.CleanAndKeepMaxRecords(CandleTradeNoSql.GeneratePartitionKey(symbol, DateTime.UtcNow.AddDays(-Program.Settings.DaysToKeepMinutes - 3).Date), 0);

                            await writerTrade.CleanAndKeepMaxRecords(CandleTradeNoSql.GeneratePartitionKey(symbol, DateTime.UtcNow.AddDays(-Program.Settings.DaysToKeepMinutes - 4).Date), 0);

                            await writerTrade.CleanAndKeepMaxRecords(CandleTradeNoSql.GeneratePartitionKey(symbol, DateTime.UtcNow.AddDays(-Program.Settings.DaysToKeepMinutes - 5).Date), 0);

                            await writerTrade.CleanAndKeepMaxRecords(CandleTradeNoSql.GeneratePartitionKey(symbol, DateTime.UtcNow.AddDays(-Program.Settings.DaysToKeepMinutes - 6).Date), 0);

                            await writerTrade.CleanAndKeepMaxRecords(CandleTradeNoSql.GeneratePartitionKey(symbol, DateTime.UtcNow.AddDays(-Program.Settings.DaysToKeepMinutes - 7).Date), 0);

                            _logger.LogInformation("Cleanup minutes for broker: {brokerId} and symbol: {symbol}", brokerId, symbol);
                        }
                    }
                    catch (Exception ex)
                    {
                        _logger.LogError(ex, "Cannot cleanup minutes");
                    }

                    await Task.Delay(TimeSpan.FromHours(1), _token.Token);
                }
            }
            catch (Exception)
            { }
        }