Beispiel #1
0
        public override HuobiOrderResult OnBuy(HuobiMarket coinType, decimal price, decimal amountBtc)
        {
            TradeAnswer tradeAnswer = _btceApi.Trade(BtcePair.btc_usd, TradeType.Buy, price, amountBtc);

            return(new HuobiOrderResult {
                id = (uint)tradeAnswer.OrderId, result = tradeAnswer.Received.ToString()
            });
        }
Beispiel #2
0
        public static TradeAnswer ReadFromJObject(JObject o)
        {
            if (o == null)
                return null;

            var r = new TradeAnswer()
            {
                Funds = Funds.ReadFromJObject(o["funds"] as JObject),
                Received = o.Value<decimal>("received"),
                Remains = o.Value<decimal>("remains"),
                OrderId = o.Value<int>("order_id")
            };

            return r;
        }
Beispiel #3
0
        public static TradeAnswer ReadFromJObject(JObject o)
        {
            if (o == null)
            {
                return(null);
            }

            var r = new TradeAnswer()
            {
                Funds    = Funds.ReadFromJObject(o["funds"] as JObject),
                Received = o.Value <decimal>("received"),
                Remains  = o.Value <decimal>("remains"),
                OrderId  = o.Value <int>("order_id")
            };

            return(r);
        }
Beispiel #4
0
        public TradeAnswer Trade(BtcePair pair, TradeType type, decimal rate, decimal amount)
        {
            var args = new Dictionary <string, string>()
            {
                { "method", "Trade" },
                { "pair", BtcePairHelper.ToString(pair) },
                { "type", TradeTypeHelper.ToString(type) },
                { "rate", DecimalToString(rate) },
                { "amount", DecimalToString(amount) }
            };
            var result = JObject.Parse(Query(args));

            if (result.Value <int>("success") == 0)
            {
                throw new Exception(result.Value <string>("error"));
            }
            return(TradeAnswer.ReadFromJObject(result["return"] as JObject));
        }