public void GetBalance_ShouldUnauthorizedThrowException_IfNoApiKeyIsGiven() { var bittrex = new Bittrex(); Func <Task> action = async() => { var _ = await bittrex.GetBalance(DefaultCurrency); }; action.ShouldThrow <UnauthorizedException>(); }
public void GetBalance_ShouldNotThrowException() { var bittrex = new Bittrex(DefaultApiKey, DefaultApiSecret); Func <Task> action = async() => { var _ = await bittrex.GetBalance(DefaultCurrency); }; action.ShouldNotThrow(); }
public async Task <BaseTypes.CurrencyBalance> GetBalance(string Currency, InvokePrint Print) { try { var cbal = await bittrex.GetBalance(Currency); BaseTypes.CurrencyBalance balance = new BaseTypes.CurrencyBalance { Currency = cbal.Currency, Balance = cbal.Balance, Available = cbal.Available }; return(balance); } catch (Exception ex) { System.Media.SystemSounds.Beep.Play(); Print(String.Format("Ошибка BittrexApi GetBalance: {0}\r\nCurrency: {1}.", ex.Message, Currency)); return(null); } }
public async Task <ApiStatus> CheckKeySecret() { var task = bittrex.GetBalance("BTC"); var res = await Task.WhenAny(task, Task.Delay(10000)); if (res == task) { // Task completed within time. if (task.Result.Message.CompareTo("APIKEY_INVALID") == 0 || task.Result.Message.CompareTo("INVALID_SIGNATURE") == 0) { return(ApiStatus.FALSE); } else { return(ApiStatus.TRUE); } } else { // Task timed out return(ApiStatus.CONNECTION_TIMEOUT); } }
/// <summary> /// Function returning the balance of one currency in the portfolio /// <paramref name="currency"/> have to be in <see cref="MainCurrency"/> /// </summary> /// <param name="currency">the name of the cryptocurrency.</param> public double GetBalance(string currency) { BittrexSharp.Domain.CurrencyBalance one_balance = my_bittrex.GetBalance(currency).Result.Result; return((double)one_balance.Available); }