Пример #1
0
        /// <summary>
        /// Place single trade with passed parameters
        /// </summary>
        /// <param name="pair">Trade Pair (currency)</param>
        /// <param name="type">Trade Type</param>
        /// <param name="rate">Trade Rate</param>
        /// <param name="amount">Trade Amount</param>
        /// <returns>On successful operation will return populated TradeAnswer, on error will throw BTCeException with original BTCe API error message</returns>
        public TradeAnswer PlaceOrder(BTCePair pair, BTCeTradeType type, decimal rate, decimal amount)
        {
            if (!authenticated)
            {
                throw new BTCeAPIException("Not Authenticated");
            }

            var resultStr = Query(new Dictionary <string, string>()
            {
                { "method", "Trade" },
                { "pair", BtcePairHelper.ToString(pair) },
                { "type", TradeTypeHelper.ToString(type) },
                { "rate", DecimalToString(rate) },
                { "amount", DecimalToString(amount) }
            });

            return(TradeAnswer.ReadFromJSON(resultStr));
        }
Пример #2
0
        public static OrderInfo ReadFromJSON(string order, int orderId)
        {
            JObject o = JObject.Parse(order) as JObject;

            if (o == null)
            {
                return(null);
            }

            OrderInfo orderInfo = new OrderInfo()
            {
                Pair             = BtcePairHelper.FromString(o.Value <string>("pair")),
                Type             = TradeTypeHelper.FromString(o.Value <string>("type")),
                Amount           = o.Value <decimal>("amount"),
                Rate             = o.Value <decimal>("rate"),
                TimestampCreated = o.Value <UInt32>("timestamp_created"),
                Status           = (BTCeOrderStatus)o.Value <int>("status"),
                Id = orderId
            };

            return(orderInfo);
        }