DigitalRuby / ExchangeSharp

ExchangeSharp is a powerful, fast and easy to use .NET/C# API for interfacing with many crypto currency exchanges. REST and web sockets are supported.
https://www.digitalruby.com
MIT License
741 stars 374 forks source link

Coinbasepro sandbox orders getting rejected #311

Closed yatendra closed 5 years ago

yatendra commented 5 years ago

I am trying to covert Kraken example in ExchangeSharpConsole to coinbasepro sandbox using following code -

ExchangeAPI api = new ExchangeCoinbaseAPI();
            api.BaseUrl = "https://api-public.sandbox.pro.coinbase.com";

            ExchangeTicker ticker = api.GetTickerAsync("BTC-USD").Sync();
            Console.WriteLine("On the coinbase exchange, 1 bitcoin is worth {0} USD.", ticker.Bid);

            api.LoadAPIKeysUnsecure("your coinbase prosandbox api key", "your coinbase prosandbox api secret", "your coinbase prosandbox api passphrase");
            /// place limit order for 0.01 bitcoin at ticker.Ask USD
            ExchangeOrderResult result = api.PlaceOrderAsync(new ExchangeOrderRequest
            {
                Amount = 0.01m,
                IsBuy = true,
                Price = ticker.Ask,
                MarketSymbol = "BTC-USD"
            }).Sync();

GetTicker returns ticker data but the result returned by PlaceOrderAsync has status unknown. When I tried to debug, in ExchangeCoinbaseAPI.cs in OnPlaceOrderAsync I keep getting result.status as rejected.

yatendra commented 5 years ago

My bad. It was a limit order so payload["post_only"] was set to true and the price I was setting was the ticker ask price. So instead of making an order it was taking one and thus getting rejected as a post_only order.