Esempio n. 1
0
        /// <summary>
        /// Make a call to a private API method.
        /// </summary>
        /// <param name="method">The method to call on the VoS API</param>
        /// <param name="quoteCurrencyCode">A quote currency code to append to the URL</param>
        /// <returns>Parsed JSON returned from VoS</returns>
        private async Task <T> CallPrivate <T>(Method method, VoSMarketId marketId)
            where T : JToken
        {
            FormUrlEncodedContent request = new FormUrlEncodedContent(new[]
            {
                new KeyValuePair <string, string>(PARAMETER_NONCE, this.GetNextNonce()),
                marketId.BaseCurrencyCodeKeyValuePair,
                marketId.QuoteCurrencyCodeKeyValuePair
            });

            return(await CallPrivate <T>(method, request));
        }
Esempio n. 2
0
        /// <summary>
        /// Make a call to a public (non-authenticated) API
        /// </summary>
        /// <param name="method">The method to call on the VoS API</param>
        /// <param name="quoteCurrencyCode">A quote currency code to append to the URL</param>
        /// <param name="round">Optionally, number of digits to round prices to.</param>
        /// <returns>The raw JSON returned from VoS</returns>
        private async Task <T> CallPublic <T>(Method method, VoSMarketId marketId, int?round)
            where T : JToken
        {
            StringBuilder url = new StringBuilder(BuildPublicUrl(method));

            url.Append("?").Append(marketId.BaseCurrencyCodeParameter).Append("&")
            .Append(marketId.QuoteCurrencyCodeParameter);
            if (null != round)
            {
                url.Append("&").Append(PARAMETER_ROUND).Append("=")
                .Append(round.ToString());
            }

            return(await CallPublic <T>(url.ToString()));
        }
Esempio n. 3
0
        public async Task <List <Market> > GetMarkets()
        {
            List <VoSCurrency> currencies = await GetCoins();

            IEnumerable <VoSCurrency> tradeableCurrencies = currencies.Where(currency => currency.Tradeable);
            List <Market>             markets             = new List <Market>();

            foreach (VoSCurrency baseCurrency in tradeableCurrencies.Where(currency => !currency.Virtual))
            {
                foreach (VoSCurrency quoteCurrency in tradeableCurrencies.Where(currency => currency.Virtual))
                {
                    VoSMarketId marketId = new VoSMarketId(baseCurrency.CurrencyCode, quoteCurrency.CurrencyCode);
                    markets.Add(new VoSMarket(marketId));
                }
            }

            return(markets);
        }
Esempio n. 4
0
        /// <summary>
        /// Make a call to a private API method.
        /// </summary>
        /// <param name="method">The method to call on the VoS API</param>
        /// <returns>Parsed JSON returned from VoS</returns>
        private async Task <T> CallPrivate <T>(Method method, VoSMarketId marketId,
                                               OrderType orderType, decimal quantity, decimal price)
            where T : JToken
        {
            FormUrlEncodedContent request = new FormUrlEncodedContent(new[]
            {
                new KeyValuePair <string, string>(PARAMETER_NONCE, this.GetNextNonce()),
                new KeyValuePair <string, string>(PARAMETER_ORDER_TYPE, orderType == OrderType.Buy
                    ? "bid"
                    : "ask"),
                marketId.BaseCurrencyCodeKeyValuePair,
                marketId.QuoteCurrencyCodeKeyValuePair,
                new KeyValuePair <string, string>(PARAMETER_UNITS, FormatAsCurrencyObject(quantity, DEFAULT_PRECISION)),
                new KeyValuePair <string, string>(PARAMETER_PRICE, FormatAsCurrencyObject(price, DEFAULT_PRECISION))
            });

            return(await CallPrivate <T>(method, request));
        }
Esempio n. 5
0
 public VoSMarket(VoSMarketId id)
     : base(id, id.BaseCurrencyCode, id.QuoteCurrencyCode,
            id.ToString(), new MarketStatistics())
 {
 }
 public VoSMarket(VoSMarketId id)
     : base(id, id.BaseCurrencyCode, id.QuoteCurrencyCode,
         id.ToString(), new MarketStatistics())
 {
 }