public async Task<QuoteResponse> GetQuote(QuoteRequest request)
		{
			var client = this.ApiClient();
			client.QueryString.Add ("pair", request.ExchangeMarketRef);

			string rawData = await client.DownloadStringTaskAsync (this.QuoteApiUri);
			var jsonData = JToken.Parse (rawData);
			var quoteData = jsonData["result"][request.ExchangeMarketRef];

			rawData = await client.DownloadStringTaskAsync (this.QuoteApiUri_OHLC);
			jsonData = JToken.Parse (rawData);
			var ohlcData = jsonData["result"][request.ExchangeMarketRef];

			var quote = new QuoteResponse () {
				ExchangeMarketCD = request.ExchangeMarketCD,
				DailyOpen = Decimal.Parse(ohlcData[1].Value<string>()),
				DailyHigh = Decimal.Parse(ohlcData[2].Value<string>()),
				DailyLow = Decimal.Parse(ohlcData[3].Value<string>()),
				DailyClose = Decimal.Parse(ohlcData[4].Value<string>()),
				DailyVolume = Decimal.Parse(ohlcData[6].Value<string>()),
				LastBid = Decimal.Parse(quoteData["b"][0].Value<string>()),
				LastAsk = Decimal.Parse(quoteData["a"][0].Value<string>()),
				LastTrade = Decimal.Parse(quoteData["c"][0].Value<string>()),
				RawData = Encoding.ASCII.GetBytes (jsonData.ToString())
			};

			return quote;
		}
		public async Task<QuoteResponse> GetQuote(QuoteRequest request)
		{
			var client = this.ApiClient();
			string rawData = await client.DownloadStringTaskAsync (this.QuoteApiUri);
			var jsonData = JToken.Parse (rawData);

			var quote = new QuoteResponse () {
				ExchangeMarketCD = request.ExchangeMarketCD,
				LastBid = Decimal.Parse(jsonData["buy_price"].Value<string>()),
				LastAsk = Decimal.Parse(jsonData["sell_price"].Value<string>()),
				LastTrade = Decimal.Parse(jsonData["remit_partner_price"].Value<string>()),
				RawData = Encoding.ASCII.GetBytes (jsonData.ToString())
			};

			return quote;
		}
		public async Task<QuoteResponse> GetQuote(QuoteRequest request)
		{
			var client = this.ApiClient();
			client.QueryString.Add ("token", request.ApiToken);

			string rawData = await client.DownloadStringTaskAsync (this.QuoteApiUri);
			var jsonData = JToken.Parse (rawData);

			var quote = new QuoteResponse () {
				ExchangeMarketCD = request.ExchangeMarketCD,
				LastBid = Decimal.Parse(jsonData["PHP"].Value<string>()),
				LastAsk = Decimal.Parse(jsonData["PHP-ASK"].Value<string>()),
				RawData = Encoding.ASCII.GetBytes (jsonData.ToString())
			};

			return quote;
		}
		public async Task<QuoteResponse> GetQuote(QuoteRequest request)
		{
			var client = this.ApiClient();
			string rawData = await client.DownloadStringTaskAsync (this.QuoteApiUri);
			var jsonData = JToken.Parse (rawData);

			var quote = new QuoteResponse () {
				ExchangeMarketCD = request.ExchangeMarketCD,
				LastTrade = Decimal.Parse(jsonData["last"]["value"].Value<string>()),
				ReportedTime = DateTimeOffset.Parse(jsonData["last"]["timestamp"].Value<string>(),
													CultureInfo.InvariantCulture.DateTimeFormat,
													DateTimeStyles.AssumeUniversal),
				RawData = Encoding.ASCII.GetBytes (jsonData.ToString())
			};

			return quote;
		}
		public async Task<QuoteResponse> GetQuote(QuoteRequest request)
		{
			var client = this.ApiClient();
			client.QueryString.Add ("amount", "1");
			client.QueryString.Add ("curr", request.ExchangeMarketRef.Substring(0, 3));
			client.QueryString.Add ("refCurr", request.ExchangeMarketRef.Substring(3, 3));

			string rawData = await client.DownloadStringTaskAsync (this.QuoteApiUri);
			var jsonData = JToken.Parse (rawData);

			var quote = new QuoteResponse () {
				ExchangeMarketCD = request.ExchangeMarketCD,
				LastTrade = Decimal.Parse(jsonData["rate"].Value<string>()),
				RawData = Encoding.ASCII.GetBytes (jsonData.ToString())
			};

			return quote;
		}
		public async Task<QuoteResponse> GetQuote(QuoteRequest request)
		{
			var client = this.ApiClient();
			client.QueryString.Add ("currencypair", request.ExchangeMarketRef);

			string rawData = await client.DownloadStringTaskAsync (this.QuoteApiUri);
			var jsonData = JToken.Parse (rawData);

			this.CheckResponse (jsonData);

			var quoteData = jsonData["quote"];

			var quote = new QuoteResponse () {
				ExchangeMarketCD = request.ExchangeMarketCD,
				LastBid = Decimal.Parse(quoteData["bid"].Value<string>()),
				LastAsk = Decimal.Parse(quoteData["ask"].Value<string>()),
				RawData = Encoding.ASCII.GetBytes (jsonData.ToString())
			};

			return quote;
		}
		public async Task<QuoteResponse> GetQuote(QuoteRequest request)
		{
			var client = this.ApiClient();
			client.QueryString.Add ("book", request.ExchangeMarketRef);

			string rawData = await client.DownloadStringTaskAsync (this.QuoteApiUri);
			var jsonData = JToken.Parse (rawData);

			var quote = new QuoteResponse () {
				ExchangeMarketCD = request.ExchangeMarketCD,
				DailyHigh = Decimal.Parse(jsonData["high"].Value<string>()),
				DailyLow = Decimal.Parse(jsonData["low"].Value<string>()),
				DailyVolume = Decimal.Parse(jsonData["volume"].Value<string>()),
				LastBid = Decimal.Parse(jsonData["bid"].Value<string>()),
				LastAsk = Decimal.Parse(jsonData["ask"].Value<string>()),
				LastTrade = Decimal.Parse(jsonData["last"].Value<string>()),
				ReportedTime = Utilities.GetDateTimeFromUnixTimestamp (jsonData["timestamp"].Value<long> ()),
				RawData = Encoding.ASCII.GetBytes (jsonData.ToString())
			};

			return quote;
		}
		public async Task<QuoteResponse> GetQuote(QuoteRequest request)
		{
			var client = this.ApiClient();
			client.QueryString.Add ("currencypair", request.ExchangeMarketRef);

			string rawData = await client.DownloadStringTaskAsync (this.QuoteApiUri);
			var jsonData = JToken.Parse (rawData);

			var quoteData = jsonData["ticker"][request.ExchangeMarketRef];

			var quote = new QuoteResponse () {
				ExchangeMarketCD = request.ExchangeMarketCD,
				DailyVolume = Decimal.Parse(quoteData["volume"].Value<string>()),
				DailyHigh = Decimal.Parse(quoteData["high"].Value<string>()),
				DailyLow = Decimal.Parse(quoteData["low"].Value<string>()),
				LastBid = Decimal.Parse(quoteData["buy"].Value<string>()),
				LastAsk = Decimal.Parse(quoteData["sell"].Value<string>()),
				LastTrade = Decimal.Parse(quoteData["last"].Value<string>()),
				RawData = Encoding.ASCII.GetBytes (jsonData.ToString())
			};

			return quote;
		}
Exemple #9
0
		public async Task<QuoteResponse> GetQuote(QuoteRequest request)
		{
			var client = this.ApiClient();

			var endpointUri = new Uri (
				this.QuoteApiUri, 
				this.QuoteApiUri.AbsolutePath.Replace("$$", request.ExchangeMarketRef)
			);
			string signature = this.GenerateRequestSignature(
				request.ApiSecret,
				endpointUri.AbsolutePath,
				client.QueryString
			);
			
			client.Headers.Add ("Rest-Key", request.ApiToken);
			client.Headers.Add ("Rest-Sign", signature);

			string rawData = await client.DownloadStringTaskAsync (endpointUri);
			var jsonData = JToken.Parse (rawData);
			var quoteData = jsonData["data"];

			var quote = new QuoteResponse () {
				ExchangeMarketCD = request.ExchangeMarketCD,
				DailyAverage = Decimal.Parse(quoteData["avg"]["value"].Value<string>()),
				DailyVolume = Decimal.Parse(quoteData["vol"]["value"].Value<string>()),
				DailyHigh = Decimal.Parse(quoteData["high"]["value"].Value<string>()),
				DailyLow = Decimal.Parse(quoteData["low"]["value"].Value<string>()),
				LastBid = Decimal.Parse(quoteData["buy"]["value"].Value<string>()),
				LastAsk = Decimal.Parse(quoteData["sell"]["value"].Value<string>()),
				LastTrade = Decimal.Parse(quoteData["last"]["value"].Value<string>()),
				RawData = Encoding.ASCII.GetBytes (jsonData.ToString()),
				ReportedTime = Utilities.GetDateTimeFromUnixTimestamp (quoteData ["dataUpdateTime"].Value<long> () / 1000000)
			};

			return quote;
		}