Exemplo n.º 1
0
        /// <summary>
        /// Make a call to a public (non-authenticated) API
        /// </summary>
        /// <param name="method">The method to call on the Prelude API</param>
        /// <param name="quoteCurrency">A quote currency code to append to the method URL</param>
        /// <returns>The raw JSON returned from Prelude</returns>
        private async Task <T> CallPublic <T>(Method method, PreludeQuoteCurrency quoteCurrencyCode)
            where T : JToken
        {
            string url = BuildPublicUrl(method, quoteCurrencyCode);

            return((T)JToken.Parse(await CallPublic(url)));
        }
        public static List<MarketId> ParsePairs(JObject pairsJson, PreludeQuoteCurrency quoteCurrency)
        {
            // TODO: Verify the quote currency matches the "from" currency in the JSON

            return pairsJson.Value<JArray>("pairings").Select(
                trade => (MarketId)ParseSingle((JObject)trade, quoteCurrency)
            ).ToList();
        }
Exemplo n.º 3
0
        public static List <MarketId> ParsePairs(JObject pairsJson, PreludeQuoteCurrency quoteCurrency)
        {
            // TODO: Verify the quote currency matches the "from" currency in the JSON

            return(pairsJson.Value <JArray>("pairings").Select(
                       trade => (MarketId)ParseSingle((JObject)trade, quoteCurrency)
                       ).ToList());
        }
Exemplo n.º 4
0
        /// <summary>
        /// Return the (unescaped) path element to be inserted between the method,
        /// and quote currency, in the URL. This is required because Prelude has
        /// inconsistent URL naming depending on base currency.
        /// </summary>
        static string GetQuoteCurrencyMethodPostfix(PreludeQuoteCurrency quoteCurrency)
        {
            switch (quoteCurrency)
            {
            case PreludeQuoteCurrency.BTC:
                return("");

            default:
                return("-" + Enum.GetName(typeof(PreludeQuoteCurrency), quoteCurrency).ToLower());
            }
        }
Exemplo n.º 5
0
        public static string BuildPublicUrl(Method method, PreludeQuoteCurrency quoteCurrency)
        {
            switch (method)
            {
            case Method.pairings:
                return(BASE_URL + Enum.GetName(typeof(Method), method) + "/"
                       + Uri.EscapeUriString(Enum.GetName(typeof(PreludeQuoteCurrency), quoteCurrency).ToLower()));

                break;

            default:
                return(BASE_URL + Enum.GetName(typeof(Method), method)
                       + Uri.EscapeUriString(GetQuoteCurrencyMethodPostfix(quoteCurrency)) + "/");
            }
        }
 private static PreludeMarketId ParseSingle(JObject pairJson, PreludeQuoteCurrency quoteCurrency)
 {
     return new PreludeMarketId(pairJson.Value<string>("pair"), quoteCurrency);
 }
 public PreludeMarketId(string baseCode, PreludeQuoteCurrency quoteCode)
     : base(baseCode + "_" + quoteCode)
 {
     this.BaseCurrencyCode = baseCode;
     this.QuoteCurrencyCode = quoteCode;
 }
Exemplo n.º 8
0
 private static PreludeMarketId ParseSingle(JObject pairJson, PreludeQuoteCurrency quoteCurrency)
 {
     return(new PreludeMarketId(pairJson.Value <string>("pair"), quoteCurrency));
 }
Exemplo n.º 9
0
 public PreludeMarketId(string baseCode, PreludeQuoteCurrency quoteCode)
     : base(baseCode + "_" + quoteCode)
 {
     this.BaseCurrencyCode  = baseCode;
     this.QuoteCurrencyCode = quoteCode;
 }