public double getPairVolume(Globals.Coin coinFrom, Globals.Coin coinTo) { string pair = reformCoinPair(coinFrom.marketSymbol, coinTo.marketSymbol); string resp = ExchangeAuxilaries.SendWebRequest( apiUrl + "/api/v1/ticker/24hr", apiSecret, "GET", new CustomDict <string, string> { { "X-MBX-APIKEY", apiKey } }, new CustomDict <string, string> { { "symbol", pair.ToUpper() } }, null ); if (resp == null) { throw new Exception("null response for getPairVolume"); } JObject assets = JObject.Parse(resp); return(double.Parse(assets["quoteVolume"].ToString())); }
public double getGlobalAssetPrice(string _asset, string _convertTo) { double result = 0.0d; bool hasFiat = false; string asset = _asset, convertTo = _convertTo; if (asset.Equals(convertTo)) { return(1.0d); } if (asset.ToLower().Equals(FiatCoin.marketSymbol)) { asset = _convertTo; convertTo = _asset; hasFiat = true; } //Globals.consoleDebugMsg("_asset=" + _asset+ " _convertTo="+ _convertTo+" hasFiat="+hasFiat+ "asset=" + asset + " convertTo="+convertTo); string pricesHistoryUrl = string.Format("{0}/data/price", baseGlobalDataUrl); if (asset.Equals("bcc")) { asset = "bch"; } string responseStr = ExchangeAuxilaries.SendWebRequest( pricesHistoryUrl, null, "GET", new CustomDict <string, string>(), new CustomDict <string, string>() { { "fsym", asset.ToUpper() } , { "tsyms", convertTo.ToUpper() }, { "e", Name } }, null ); if (responseStr == null) { throw new Exception("null response for getGlobalAssetPrice"); } //Globals.consoleDebugMsg("response="+responseStr); if (hasFiat) { result = 1 / double.Parse(JObject.Parse(responseStr)[FiatCoin.marketSymbol.ToUpper()].ToString()); } else { result = double.Parse(JObject.Parse(responseStr)[ProfitRealizationCoin.marketSymbol.ToUpper()].ToString()); } return(result); }