Ejemplo n.º 1
0
        public void TestNash()
        {
            NashClientConfig config = NashClientConfig.Authenticated(
                Environment.GetEnvironmentVariable("NASH_API_KEY"),
                Environment.GetEnvironmentVariable("NASH_API_SECRET"),
                0,
                NashEnvironment.Sandbox,
                1000
                );

            var client = new ExchangeClient(config);

            TestContext.Progress.WriteLine("Orderbook " + client.Orderbook("btc_usdc"));
            TestContext.Progress.WriteLine("ReceivePairs " + client.ReceivePairs());
            TestContext.Progress.WriteLine("GetAccountBalances " + client.GetAccountBalances());
            TestContext.Progress.WriteLine("GetHistoricRates: " + client.GetHistoricTrades(new GetHistoricTradesRequest("btc_usdc")));
            TestContext.Progress.WriteLine("GetOrderHistory btc_usdc: " + client.GetOrderHistory(new GetOrderHistoryRequest("btc_usdc")));
            client.CancelAllOrders("btc_usdc");
            var order = client.LimitSell(LimitOrderRequest.goodTillCancelled("6500.0", "0.01000", "btc_usdc"));

            TestContext.Progress.WriteLine("Limit sell: " + order);
            TestContext.Progress.WriteLine("Get order", client.GetOrder(order.id, order.marketPair));
            TestContext.Progress.WriteLine("Limit buy: " + client.LimitBuy(LimitOrderRequest.goodTillCancelled("6500.0", "0.01000", "btc_usdc")));
            TestContext.Progress.WriteLine("Limit buy fok: " + client.LimitSell(LimitOrderRequest.fillOrKill("6500.0", "0.01000", "btc_usdc")));
            TestContext.Progress.WriteLine("Limit buy ioc: " + client.LimitSell(LimitOrderRequest.immediateOrCancel("6500.0", "0.01000", "btc_usdc")));
            TestContext.Progress.WriteLine("Market sell: " + client.MarketSell(new MarketOrderRequest("0.01000", "btc_usdc")));
            TestContext.Progress.WriteLine("Market sell inverse: " + client.MarketSell(new MarketOrderRequest("20", "usdc_btc")));
            client.CancelAllOrders("btc_usdc");

            var order2 = client.LimitSell(LimitOrderRequest.goodTillCancelled("8000.0", "1.0000", "btc_usdc"));

            TestContext.Progress.WriteLine("Limit sell: " + order2);
            client.CancelOrder(order2.id, order2.marketPair);
        }
Ejemplo n.º 2
0
        static public void Main(string[] args)
        {
            Console.WriteLine("Init");
            NashClientConfig config = NashClientConfig.Unauthenticated(0, NashEnvironment.Production, 1000);
            var client = new ExchangeClient(config);

            client.SubscribeToDisconnect(() => {
                Console.WriteLine("Disconnected");
            });
            foreach (var market in client.ReceivePairs())
            {
                client.SubscribeToOrderbook(market.symbol, PrintBook);
            }

            GC.Collect();
            GC.WaitForPendingFinalizers();

            // Noia markets only available in NashEnvironment.Production
            // Console.WriteLine("Listening to the noia markets");
            // client.SubscribeToOrderbook("noia_usdc", PrintBook);
            // client.SubscribeToOrderbook("noia_btc", PrintBook);
        }