当前位置: 首页>>代码示例>>C#>>正文


C# ApiClient.GetOrderBook方法代码示例

本文整理汇总了C#中ApiClient.GetOrderBook方法的典型用法代码示例。如果您正苦于以下问题:C# ApiClient.GetOrderBook方法的具体用法?C# ApiClient.GetOrderBook怎么用?C# ApiClient.GetOrderBook使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ApiClient的用法示例。


在下文中一共展示了ApiClient.GetOrderBook方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        // API Test
        static void Main()
        {
            // Alternatively you can set configure these in your web.config or app.config and use the parameterless constructor
            var client = new ApiClient("yourpublicley", "yourprivatekey", "https://www.btcturk.com");

            var ticker = client.GetTicker();
            Console.WriteLine(ticker.ToString()); // Print the ticker to console

            var orderbook = client.GetOrderBook();

            var bestBidPrice = orderbook.Bids[0][0];
            var bestBidAmount = orderbook.Bids[0][1];
            Console.WriteLine("Best bid price:" + bestBidPrice); // Print the best bid price and amount to console
            Console.WriteLine("Best bid amount:" + bestBidAmount);

            var bestAskPrice = orderbook.Asks[0][0];
            var bestAskAmount = orderbook.Asks[0][1];
            Console.WriteLine("Best ask price:" + bestAskPrice); // Print the best ask price and amount to console
            Console.WriteLine("Best ask amount:" + bestAskAmount);

            // BELOW THIS LINE REQUIRES AUTHENTICATION
            var accountBalance = client.GetAccountBalance();
            Console.WriteLine("My total Bitcoin: " + accountBalance.BitcoinBalance); // Print my bitcoin balance to console
            Console.WriteLine("My total money: " + accountBalance.MoneyBalance);

            var openorOrders = client.GetOpenOrders();
            if (openorOrders.Count != 0)
            {
                Console.WriteLine("I have some open orders");
                client.CancelOrder(openorOrders[0]); // Cancel one of my open orders
            }
            else
            {
                Console.WriteLine("I don't have any open orders");
            }

            var trades = client.GetLastTrades(50);
            foreach (var trade in trades)
            {
                Console.WriteLine(trade);
            }

            var depositMoney = client.GetDepositMoney();

            if(depositMoney != null)
                PrintDepositMoney(depositMoney);

            var depositModel = new DepositMoneyInput
            {
                Amount = 14,
                AmountPrecision = 0
            };

            depositMoney = client.DepositMoney(depositModel);

            if (depositMoney != null)
                PrintDepositMoney(depositMoney);

            var withdrawalMoney = client.GetWithdrawalMoney();

            if (withdrawalMoney != null)
                PrintWithdrawalMoney(withdrawalMoney);

            var withdrawalModel = new WithdrawalMoneyInput
            {
                Amount = 15,
                AmountPrecision = 0,
                BankId = "51c41f6349ede8108423f00a",
                BankName = "AKBANK T.A.S.",
                FriendlyNameSave = true,
                FriendlyName = "Test2",
                Iban = "iban_number_here"
            };

            withdrawalMoney = client.WithdrawalMoney(withdrawalModel);

            if (withdrawalMoney != null)
                PrintWithdrawalMoney(withdrawalMoney);

            var cancelOperation = client.CancelOperation("money_requestid_here");

            Console.WriteLine(cancelOperation);

            //// Submit an ask order at 1,000,000 per btc.
            //var order = new Order
            //{
            //    Price = 657m,
            //    Amount = 1000000m,
            //    Type = Order.SellOrder,
            //    IsMarketOrder = 0
            //};

            //if (client.SubmitOrder(ref order))
            //    Console.WriteLine("Order Id: " + order.Id); // Print the reference order ID to console.

            Console.ReadLine();
        }
开发者ID:Kayser1685,项目名称:broker-api-csharp,代码行数:98,代码来源:Program.cs


注:本文中的ApiClient.GetOrderBook方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。