コード例 #1
0
        public void TestConvert()
        {
            var orderRequst = new OrderRequest();

            orderRequst.ClientOrderId = Guid.NewGuid().ToString();
            orderRequst.CurrencyPair  = CurrencyPair.BtcEur;
            orderRequst.OrderType     = OrderType.Limit;
            orderRequst.Price         = 0.00561m;
            orderRequst.TradeType     = TradeType.Buy;
            orderRequst.Volume        = 0.00036m;

            var currencyMapper = new GdaxCurrencyMapper();
            var order          = GdaxOrderRequest.ConvertFrom(orderRequst, currencyMapper);

            Assert.Equal(orderRequst.ClientOrderId, order.client_oid);
            Assert.Equal("BTC-EUR", order.product_id);
            Assert.Equal("limit", order.type);
            Assert.Equal("0.00561", order.price);
            Assert.Equal("0.00036", order.size);
            Assert.Equal("buy", order.side);
        }
コード例 #2
0
        public MethodResult <OrderResult> MakeANewOrder(OrderRequest order)
        {
            RateLimit();
            var request = new RestRequest("/orders", Method.POST);

            request.AddJsonBody(GdaxOrderRequest.ConvertFrom(order, _currencyMapper));
            AddAuthenticationHeader(request);
            var client = new RestClient(baseUrl);
            //client.Proxy = new WebProxy("127.0.0.1", 8888); for fiddler trace
            var response = client.Execute <GdaxOrderResponse>(request);

            if (response.IsSuccessful)
            {
                var result = new OrderResult();
                return(new MethodResult <OrderResult>()
                {
                    IsSuccessful = true,
                    Data = response.Data.Convert()
                });
            }
            return(MethodResult <OrderResult> .Failed(response.ErrorMessage));
        }