예제 #1
0
파일: API.cs 프로젝트: RAWX/csharp-lib
        public async Task<string> PlaceOrderAsync(MarketPair marketPair, bool bid, Amount price, Amount amount)
        {
            if (apiKey == null)
            {
                return null;
            }

            Task<Dictionary<string, MarketPair>> marketPairsTask = null;

            if (this.currencies == null)
            {
                marketPairsTask = QueryMarketPairsAsync();
            }

            HttpClient client = new HttpClient();

            Task<string> queryTask = client.GetStringAsync(host + "/a?orad" +
                "&base=" + marketPair.Base.TLA +
                "&other=" + marketPair.Other.TLA + 
                "&price=" + price.ToRawHex() +
                "&amount=" + amount.ToRawHex() +
                "&bid=" + (bid ? "1" : "0") + 
                "&enabled=1" + 
                "&apik=" + apiKey);
            string json = await queryTask;

            if (marketPairsTask != null)
            {
                await marketPairsTask;
            }

            json.PlaceOrderCall query = JsonConvert.DeserializeObject<json.PlaceOrderCall>(json);

            return query.id;
        }
예제 #2
0
파일: User.cs 프로젝트: RAWX/csharp-lib
            public Order(API api, json.UserCall.Order userOrder)
            {
                this.api = api;

                id = userOrder.id;
                marketPair = api.GetMarketPair(userOrder.pair);
                time = Utils.UnixTimeStampToDateTime(userOrder.time);
                amount = new Amount(userOrder.amount, api.GetCurrency(userOrder.side).DecimalsInternal);
                price = new Amount(userOrder.price, marketPair.Base.DecimalsInternal);
                bid = userOrder.side == marketPair.Base.TLA;
            }