static async Task Main() { var publicClient = new LykkeExchange(); // public api methods var pairs = await publicClient.GetAssetPairs(); foreach (var pair in pairs) { Console.WriteLine(pair.Name); } var orderBook = await publicClient.GetOrderBook(KnownAssetPairs.BTC_USD); var assetPair = await publicClient.GetAssetPair(KnownAssetPairs.BTC_USD); Console.WriteLine(assetPair.Name); // private api methods var apiKey = "XXX"; var privateClient = new LykkeExchange(apiKey); var ordersStatus = await privateClient.GetOrdersStatus(); foreach (var status in ordersStatus) { Console.WriteLine(status.Id); } await privateClient.PlaceLimitOrder(Order.Buy("BTCUSD", 0.0001m, 100)); await privateClient.PlaceMarketOrder(Order.Sell("BTCUSD", 0.0001m, 100)); var balances = await privateClient.GetBalances(); foreach (var asset in balances) { Console.WriteLine($"{asset.AssetId}: {asset.Balance}"); } var orderId = "XXX"; await privateClient.CancelOrder(orderId); }
static void Main(string[] args) { Options options = new Options(); if (!ArgumentParser.Parse(args, ref options)) { return; } LykkeExchange lykkeExchange = new LykkeExchange(); switch (options.methodName) { case "GetExchangeRate": GetExchangeRateOptions ex = new GetExchangeRateOptions(); ex.fromCurrency = getFromCurrency(); ex.toCurrency = getToCurrency(); var excRate = lykkeExchange.GetExchangeRate(ex.fromCurrency, ex.toCurrency); Console.WriteLine($"Sell Price {excRate.Sell}"); Console.WriteLine($"Buy Price {excRate.Buy}"); break; case "GetTradingHistory": GetTradingHistoryOptions th = new GetTradingHistoryOptions(); th.fromCurrency = getFromCurrency(); th.toCurrency = getToCurrency(); th.skip = getSkip(); th.count = getCount(); var histories = lykkeExchange.GetTradingHistory(th.fromCurrency, th.toCurrency, (int)th.skip, (int)th.count); foreach (var history in histories) { DisplayTradeHistory(history); } break; case "GetWalletTradeInformation": GetWalletTradeInformationOptions wt = new GetWalletTradeInformationOptions(); wt.fromCurrency = getFromCurrency(); wt.toCurrency = getToCurrency(); wt.skip = getSkip(); wt.take = getCount(); wt.apiKey = getAPIKey(); var apiKey = new System.Net.NetworkCredential(string.Empty, wt.apiKey).Password; var walletHistories = lykkeExchange.GetWalletTradeInformation(apiKey, wt.fromCurrency, wt.toCurrency, (int)wt.skip, (int)wt.take); foreach (var history in walletHistories) { DisplayWalletTradeHistory(history); } break; case "GetBalances": GetBalancesOptions b = new GetBalancesOptions(); b.apikey = getAPIKey(); apiKey = new System.Net.NetworkCredential(string.Empty, b.apikey).Password; var balances = lykkeExchange.GetBalances(apiKey); foreach (var balance in balances) { DisplayWalletBalance(balance); } break; case "MarketOrder": MarketOrderOptions m = new MarketOrderOptions(); m.apiKey = getAPIKey(); apiKey = new System.Net.NetworkCredential(string.Empty, m.apiKey).Password; m.value = getTradeVolume(); m.fromCurrency = getFromCurrency(); m.toCurrency = getToCurrency(); LykkeTradeType tradeType; Enum.TryParse <LykkeTradeType>(getTradeType(), out tradeType); m.tradeType = tradeType; var money = lykkeExchange.MarketOrder(apiKey, m.fromCurrency, m.toCurrency, m.tradeType, m.value); Console.WriteLine($"Amount {money.Amount}"); Console.WriteLine($"Currency {money.Currency}"); break; default: throw new Exception("API call is not supported"); } }