Exemple #1
0
        public async Task <List <MarketTrade> > GetMarketTrades(MarketId marketId)
        {
            BterMarketId bterMarketId = (BterMarketId)marketId;

            return(BterMarketTrade.Parse(marketId,
                                         await CallPublic <JObject>(Method.trade, bterMarketId)));
        }
Exemple #2
0
        /// <summary>
        /// Make a call to a public (non-authenticated) API
        /// </summary>
        /// <param name="method">The method to call on the Bter API</param>
        /// <param name="quoteCurrencyCode">A quote currency code to append to the URL</param>
        /// <returns>The raw JSON returned from Bter</returns>
        private async Task <T> CallPublic <T>(Method method, BterMarketId marketId)
            where T : JToken
        {
            StringBuilder url = new StringBuilder(BuildPublicUrl(method));

            url.Append("/")
            .Append(Uri.EscapeUriString(marketId.Value));

            return((T)JToken.Parse(await CallPublic(url.ToString())));
        }
Exemple #3
0
        public static List <Market> ParseMarkets(JObject marketsJson)
        {
            List <Market> markets = new List <Market>();

            foreach (JProperty marketProperty in marketsJson.Properties())
            {
                BterMarketId marketId   = new BterMarketId(marketProperty.Name);
                JObject      marketJson = (JObject)marketProperty.Value;

                MarketStatistics marketStats = new MarketStatistics()
                {
                    HighTrade     = marketJson.Value <decimal>("high"),
                    LastTrade     = marketJson.Value <decimal>("last"),
                    LowTrade      = marketJson.Value <decimal>("low"),
                    Volume24HBase = marketJson.Value <decimal>("vol_" + marketId.BaseCurrencyCode.ToLower())
                };

                markets.Add(new BterMarket(marketId, marketStats));
            }

            return(markets);
        }
        public static List<Market> ParseMarkets(JObject marketsJson)
        {
            List<Market> markets = new List<Market>();

            foreach (JProperty marketProperty in marketsJson.Properties())
            {
                BterMarketId marketId = new BterMarketId(marketProperty.Name);
                JObject marketJson = (JObject)marketProperty.Value;

                MarketStatistics marketStats = new MarketStatistics()
                {
                    HighTrade = marketJson.Value<decimal>("high"),
                    LastTrade = marketJson.Value<decimal>("last"),
                    LowTrade = marketJson.Value<decimal>("low"),
                    Volume24HBase = marketJson.Value<decimal>("vol_" + marketId.BaseCurrencyCode.ToLower())
                };

                markets.Add(new BterMarket(marketId, marketStats));
            }

            return markets;
        }
 public BterOrderId(BterMarketId setMarketId, string setValue)
 {
     this.MarketId = setMarketId;
     this.Value = setValue;
 }
Exemple #6
0
        public override async Task <Model.Book> GetMarketDepth(MarketId marketId)
        {
            BterMarketId bterMarketId = (BterMarketId)marketId;

            return(BterParsers.ParseOrderBook(await CallPublic <JObject>(Method.depth, bterMarketId)));
        }
Exemple #7
0
        public async Task <List <BterMarketId> > GetPairs()
        {
            JArray pairsJson = await CallPublic <JArray>(Method.tickers);

            return(BterMarketId.ParsePairs(pairsJson));
        }
Exemple #8
0
 public BterMarket(BterMarketId id, MarketStatistics statistics)
     : base(id, id.BaseCurrencyCode, id.QuoteCurrencyCode,
            id.ToString(), statistics)
 {
 }
 public BterMarket(BterMarketId id, MarketStatistics statistics)
     : base(id, id.BaseCurrencyCode, id.QuoteCurrencyCode,
         id.ToString(), statistics)
 {
 }
Exemple #10
0
 public BterOrderId(BterMarketId setMarketId, string setValue)
 {
     this.MarketId = setMarketId;
     this.Value    = setValue;
 }