private async Task RunExample() { // Using the ApiCredentials Class // Client = new Api(new ApiCredentials(CexUsername, CexApiKey, CexApiSecret)); // Or not // CexClient = new CexApi(CexUsername, CexApiKey, CexApiSecret); // ApiCredentials/(Username, ApiKey, ApiSecret) not needed for public functions CexClient = new CexApi(); // Get Ticker Data Ticker tickerData = await CexClient.Ticker(SymbolPair.BTC_USD); // Get Order Book OrderBook orderBook = await CexClient.OrderBook(SymbolPair.BTC_USD); // Get Trade history IEnumerable <Trade> tradeHistory = await CexClient.TradeHistory(SymbolPair.BTC_USD); // ApiCredentials required for user specific calls or "Private Functions" CexClient = new CexApi(CexUsername, CexApiKey, CexApiSecret); // Get Account Balance Balance accountBalance = await CexClient.AccountBalance(); // Get Open Orders IEnumerable <OpenOrder> openOrders = await CexClient.OpenOrders(SymbolPair.LTC_BTC); // Place an order OpenOrder openOrder = await CexClient.PlaceOrder( SymbolPair.BTC_USD, new Order { Amount = 1.00m, Price = 0.04644000m, Type = OrderType.Buy }); // Cancel an order bool didSucceed = await CexClient.CancelOrder(openOrder.Id); // GHash.IO Example GhashClient = new GhashApi(new ApiCredentials(CexUsername, CexApiKey, CexApiSecret)); // Get Hash Rate Hashrate hashrate = await GhashClient.Hashrate(); // Get Workers Hash Rate IEnumerable <KeyValuePair <string, WorkerHashrate> > workerHashRate = await GhashClient.WorkersHashRate(); }
private string get_content(Uri uri, out string extension) { extension = ""; // Api Calls if (uri.ToString().Contains("/api")) { string command = uri.ToString().Split(new string[] { "api" }, StringSplitOptions.None)[1].Substring(1); CexApi CexClient = new CexApi(Form1.CexUsername, Form1.CexApiKey, Form1.CexApiSecret); switch (command) { case "ticker": return(Newtonsoft.Json.JsonConvert.SerializeObject(CexClient.Ticker(SymbolPair.XRP_USD).Result)); break; default: break; } var orderbook = CexClient.OrderBook(SymbolPair.XRP_USD).Result; return(Newtonsoft.Json.JsonConvert.SerializeObject( new { // ------------------------------- // Cex.Io Api Functions // ------------------------------- // ------------------------------- // ---- Tag: Public API calls ---- // ------------------------------- // Currency_limits Ticker = CexClient.Ticker(SymbolPair.XRP_USD).Result, // Tickers_for_all_pairs_by_markets // Last_price // Last_prices_for_given_markets // Converter Chart = CexClient.Chart(SymbolPair.XRP_USD).Result, // Historical_1m_OHLCV_Chart = CexClient.Historical_1m_OHLCV_Chart(SymbolPair.XRP_USD, DateTime.Now.AddDays(-1), "m"), Orderbook = new { Asks = orderbook.Asks.Take(15).Union(orderbook.Asks.Skip(orderbook.Asks.Count() - 5).Take(5)), Bids = orderbook.Bids.Take(15).Union(orderbook.Asks.Skip(orderbook.Bids.Count() - 5).Take(5)), Timestamp = orderbook.Timestamp, buy_total = orderbook.buy_total, sell_total = orderbook.sell_total } , // Trade_history = CexClient.TradeHistory(SymbolPair.XRP_USD).Result, // -------------------------------- // ---- Tag: Private API calls ---- // -------------------------------- Account_balance = CexClient.AccountBalance().Result, Open_orders = CexClient.OpenOrders(SymbolPair.XRP_USD).Result, // Open_orders_by_pair // Active_order_status // Archived_orders // Cancel_order= CexClient.CancelOrder(new TradeId(0)).Result, // Cancel_all_orders_for_given_pair // Place_order = CexClient.PlaceOrder(SymbolPair.XRP_USD,new Order() { Amount=1, Price=1, Type= OrderType.Buy },null).Result, // Get_order_details // Get_order_transactions // Get_crypto_address // Get_my_fee // Cancel_replace_order // Open_position // Get_position // Open_positions // Close_position // Archived_positions // Get_marginal_fee })); } else // Orher Resource calls { var path = uri.LocalPath.Substring(1); path = string.IsNullOrWhiteSpace(path) ? this.default_filename : path; extension = Path.GetExtension(path); return(File.ReadAllText(Path.Combine(this.folder, path))); } }