Beispiel #1
0
        static async Task Main(string[] args)
        {
            await TestHistoricalDataLoading();

            var s = new BitmexSocketClient();

            s.OnTradeUpdate += S_OnTradeUpdate;
            await s.SubscribeAsync(new BitmexSubscribeRequest().AddSubscription(BitmexSubscribtions.Trade, "XBTUSD"));

            Console.ReadLine();

            var socketBook = new BitmexSymbolOrderBook("XBTUSD");

            socketBook.OnBestOffersChanged += S_OnBestOffersChanged;
            await socketBook.StartAsync();

            var builder = new ConfigurationBuilder()
                          .AddJsonFile("appconfig.json", optional: true, reloadOnChange: true);

            var configuration = builder.Build();


            var client = new BitmexClient(new BitmexClientOptions()
            {
                ApiCredentials = new CryptoExchange.Net.Authentication.ApiCredentials(configuration["prod:key"], configuration["prod:secret"]),
            });
            var wallet = await client.GetUserWalletHistoryAsync();

            foreach (var r in wallet.Data)
            {
                Console.WriteLine($"[{r.Timestamp}]: {r.TransactStatus} - {r.WalletBalanceInBtc} BTC ({r.WalletBalance}) satoshi");
            }
            Console.WriteLine();

            using (var socket = new BitmexSocketClient(new BitmexSocketClientOptions(configuration["testnet:key"], configuration["testnet:secret"], isTestnet: true)
            {
                LogLevel = LogLevel.Debug,
                SocketNoDataTimeout = TimeSpan.FromSeconds(25),
                ReconnectInterval = TimeSpan.FromSeconds(5),
                AutoReconnect = true,
            }))
            {
                socket.OnUserOrdersUpdate += Socket_OnUserOrdersUpdate;;
                socket.Subscribe(new BitmexSubscribeRequest()
                                 .AddSubscription(BitmexSubscribtions.Order, "XBTUSD"));
                Console.ReadLine();
                await socket.UnsubscribeAllAsync();

                Console.ReadLine();
            }

            Console.ReadLine();
        }
Beispiel #2
0
        static async Task  Main(string[] args)
        {
            await TestHistoricalDataLoading();

            var builder = new ConfigurationBuilder()
                          .AddJsonFile("appconfig.json", optional: true, reloadOnChange: true);


            var configuration = builder.Build();


            var client = new BitmexClient(new BitmexClientOptions()
            {
                ApiCredentials = new CryptoExchange.Net.Authentication.ApiCredentials(configuration["prod:key"], configuration["prod:secret"]),
            });
            var wallet = await client.GetUserWalletHistoryAsync();

            foreach (var r in wallet.Data)
            {
                Console.WriteLine($"[{r.Timestamp}]: {r.TransactStatus} - {r.WalletBalanceInBtc} BTC ({r.WalletBalance}) satoshi");
            }
            Console.WriteLine();

            using (var socket = new BitmexSocketClient(new BitmexSocketClientOptions(configuration["testnet:key"], configuration["testnet:secret"], isTestnet: true)
            {
                LogVerbosity = CryptoExchange.Net.Logging.LogVerbosity.Debug,
                SocketNoDataTimeout = TimeSpan.FromSeconds(25),
                ReconnectInterval = TimeSpan.FromSeconds(5),
                AutoReconnect = true,
                LogWriters = new List <System.IO.TextWriter>()
                {
                    new ThreadSafeFileWriter("testnetreconnect.log"), new DebugTextWriter()
                }
            }))
            {
                socket.OnUserOrdersUpdate += Socket_OnUserOrdersUpdate;;
                socket.Subscribe(new BitmexSubscribeRequest()
                                 .AddSubscription(BitmexSubscribtions.Order, "XBTUSD"));
                Console.ReadLine();
                await socket.UnsubscribeAll();

                Console.ReadLine();
            }

            Console.ReadLine();
        }