示例#1
0
        private async Task TryPrivateAPI(SxcContext context)
        {
            var currency       = "BTC";
            var marketCurrency = "USD";

            // List balances
            var listBalancesResult = await context.ListBalancesAsync();

            var currencyBalance = listBalancesResult.First(r => r.Currency == currency);

            if (currencyBalance == null)
            {
                throw new Exception($"No {currency} balance");
            }

            Console.WriteLine(currencyBalance);

            // Place order
            var orderCode = await context.PlaceOrderAsync(
                currency, marketCurrency,
                OrderType.Sell,
                (decimal)0.00000001,
                1000000);

            Console.WriteLine(orderCode);

            // List orders
            var listOrdersResult = await context.ListOrdersAsync();

            var order = listOrdersResult.First(r => r.Code == orderCode);

            if (order == null)
            {
                throw new Exception("Order not found");
            }

            Console.WriteLine(order);

            // Cancel order
            await context.CancelOrderAsync(orderCode);

            // Generate new address
            var address = await context.GenerateNewAddressAsync(currency);

            Console.WriteLine(address?.Address);

            // Withdraw
            // await context.WithdrawAsync(currency, address, DestinationType.CryptoAddress, currencyBalance.Available);

            // get LN Invoice
            var invoice = await context.GetLNInvoiceAsync(currency, (decimal)0.01);

            Console.WriteLine(invoice);
        }
        private async Task RunAsync()
        {
            var context = new SxcContext("Your_API_Key", "Your_API_Secret");

            // List balances
            var listBalancesResult = await context.ListBalancesAsync();

            var limxBalance = listBalancesResult.First(r => r.Currency == "LIMX");

            if (limxBalance == null)
            {
                throw new Exception("No LIMX balance");
            }

            Console.WriteLine(limxBalance);

            // Place order
            var orderCode = await context.PlaceOrderAsync(
                "LIMX", "BTC",
                SouthXchange.Model.OrderType.Sell,
                limxBalance.Available,
                (decimal)99999);

            Console.WriteLine(orderCode);

            // List orders
            var listOrdersResult = await context.ListOrdersAsync();

            var order = listOrdersResult.First(r => r.Code == orderCode);

            if (order == null)
            {
                throw new Exception("Order not found");
            }

            Console.WriteLine(order);

            // Cancel order
            await context.CancelOrderAsync(orderCode);

            // Generate new address
            var address = await context.GenerateNewAddressAsync("LIMX");

            Console.WriteLine(address);

            // Withdraw
            await context.WithdrawAsync("LIMX", address, limxBalance.Available);
        }
        private async Task RunAsync()
        {
            var context = new SxcContext("Your_API_Key", "Your_API_Secret");

            // List balances
            var listBalancesResult = await context.ListBalancesAsync();
            var limxBalance = listBalancesResult.First(r => r.Currency == "LIMX");
            
            if (limxBalance == null)
            {
                throw new Exception("No LIMX balance");
            }

            Console.WriteLine(limxBalance);

            // Place order
            var orderCode = await context.PlaceOrderAsync(
                "LIMX", "BTC",
                SouthXchange.Model.OrderType.Sell,
                limxBalance.Available,
                (decimal)99999);

            Console.WriteLine(orderCode);

            // List orders
            var listOrdersResult = await context.ListOrdersAsync();
            var order = listOrdersResult.First(r => r.Code == orderCode);

            if (order == null)
            {
                throw new Exception("Order not found");
            }

            Console.WriteLine(order);

            // Cancel order
            await context.CancelOrderAsync(orderCode);

            // Generate new address
            var address = await context.GenerateNewAddressAsync("LIMX");

            Console.WriteLine(address);

            // Withdraw
            await context.WithdrawAsync("LIMX", address, limxBalance.Available);
        }