private BittrexApiResult <T> WrapInResult <T>(T data, bool success = true, string message = null) where T : class { var result = new BittrexApiResult <T>(); result.GetType().GetProperty("Result").SetValue(result, data); result.GetType().GetProperty("Success").SetValue(result, success); result.GetType().GetProperty("Message", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public).SetValue(result, message); return(result); }
public ApiResult <BittrexPrice> Ticker(string market) { using (ApiClient = new BittrexClient()) { BittrexApiResult <BittrexPrice> ticker = ApiClient.GetTicker(market); return(Return(ticker)); } }
private ApiResult <T> Return <T>(BittrexApiResult <T> apiResult) where T : class { ApiResult <T> Result = new ApiResult <T>(); if (apiResult.Success) { Result.Data = apiResult.Result; } else { Result.Message = apiResult.Error.ErrorMessage; } return(Result); }
/// <summary> /// Attach Bittrex AllMarketDeltaStream websocket stream to tickers processor. /// This is a delta stream, sending only the changes since the last tick. /// </summary> /// <param name="callback">The callback.</param> /// <param name="streamId">The stream identifier which can be used to dispose this stream without killing all other socket subscriptions.</param> /// <returns> /// The BittrexSocketClient /// Note that this socketclient handles all subscriptions. /// To unsubscribe a single subscription, use UnsubscribeFromStream(int streamId) /// </returns> public BittrexSocketClient GetTickersWebSocket(Action <IReadOnlyCollection <KeyValuePair <string, ExchangeTicker> > > callback, out int streamId) { streamId = -1; if (callback == null) { return(null); } BittrexApiResult <int> result = this.SocketClient.SubscribeToAllMarketDeltaStream ( summaries => { // Convert Bittrex.Net tickers objects into ExchangeSharp ExchangeTickers var freshTickers = new Dictionary <string, ExchangeTicker>(StringComparer.OrdinalIgnoreCase); foreach (BittrexMarketSummary market in summaries) { decimal quantityAmount = market.Volume.ConvertInvariant <decimal>(); decimal last = market.Last.ConvertInvariant <decimal>(); var ticker = new ExchangeTicker { Ask = market.Ask, Bid = market.Bid, Last = last, Volume = new ExchangeVolume { QuantityAmount = quantityAmount, QuantitySymbol = market.MarketName, PriceAmount = market.BaseVolume.ConvertInvariant <decimal>(quantityAmount * last), PriceSymbol = market.MarketName, Timestamp = market.TimeStamp } }; freshTickers[market.MarketName] = ticker; } callback(freshTickers); } ); if (result.Success) { streamId = result.Result; } return(this.SocketClient); }
public async Task <bool> GetCurrencies() { using (var client = new BittrexClient()) { Currencies = await client.GetCurrenciesAsync(); if (Currencies.Success) { AddLog("Pavyko gauti valiutų sąrašą", "", Color.Green); } else { AddLog("Nepavyko gauti valiutų sąrašo", Currencies.Error.ErrorMessage, Color.Red); } return(Currencies.Success ? true : false); } }
// Token: 0x060001DB RID: 475 RVA: 0x00007E4C File Offset: 0x0000604C public override string Withdraw(decimal amount, string currency, string adress, string invoice = null) { string result; try { string text = string.Empty; bool flag = !string.IsNullOrWhiteSpace(invoice); if (flag) { BittrexApiResult <BittrexGuid> bittrexApiResult = this._client.Withdraw(currency, amount, adress, invoice); bool success = bittrexApiResult.Success; if (success) { text = "Успешно"; } else { text = bittrexApiResult.Error.ErrorMessage; } } else { BittrexApiResult <BittrexGuid> bittrexApiResult2 = this._client.Withdraw(currency, amount, adress, null); bool success2 = bittrexApiResult2.Success; if (success2) { text = "Успешно"; } else { text = bittrexApiResult2.Error.ErrorMessage; } } result = text; } catch (Exception ex) { result = ex.Message; } return(result); }
// Token: 0x060001DA RID: 474 RVA: 0x00007D40 File Offset: 0x00005F40 public override List <Currency> GetBalance() { List <Currency> result2; try { List <Currency> list = new List <Currency>(); BittrexApiResult <BittrexBalance[]> balances = this._client.GetBalances(); bool success = balances.Success; if (success) { foreach (BittrexBalance bittrexBalance in balances.Result) { bool flag = bittrexBalance.Balance != null; if (flag) { list.Add(new Currency { Name = bittrexBalance.Currency, Amount = ((bittrexBalance.Balance == null) ? "0" : bittrexBalance.Balance.ToString()) }); } } list = (from x in list orderby x.Amount descending select x).ToList <Currency>(); result2 = list; } else { result2 = list; } } catch (Exception ex) { result2 = new List <Currency>(); } return(result2); }