dougdellolio / coinbasepro-csharp

The unofficial .NET/C# client library for the Coinbase Pro/GDAX API
MIT License
192 stars 90 forks source link

I gen a CoinbasePro.Exceptions.CoinbaseProHttpException: Post only mode #208

Closed codeinflash closed 5 years ago

codeinflash commented 5 years ago

Hi, Sometimes, I get an error when placing a limit sell order. The stack trace is below:

Exception - CoinbasePro.Exceptions.CoinbaseProHttpException: Post only mode at CoinbasePro.Services.AbstractService.SendHttpRequestMessageAsync(HttpMethod httpMethod, String uri, String content) at CoinbasePro.Services.AbstractService.SendServiceCall[T](HttpMethod httpMethod, String uri, String content) at CoinbasePro.Services.Orders.OrdersService.PlaceOrderAsync(Order order) at CoinbasePro.Services.Orders.OrdersService.PlaceLimitOrderAsync(OrderSide side, ProductType productId, Decimal size, Decimal price, TimeInForce timeInForce, Boolean postOnly, Nullable`1 clientOid)

dougdellolio commented 5 years ago

hi @codeinflash

For post only mode, the post only flag is invalid when time_in_force is IOC or FOK. Are you using either of those values in your call while setting the flag to true? Looking through the docs, another piece of info which may or may not be related is The post-only flag indicates that the order should only make liquidity. If any part of the order results in taking liquidity, the order will be rejected and no part of it will execute.

If this still doesn't help, please paste the exact call you are making (omit quantities and prices) and I can try and help debug from there.

thanks!

codeinflash commented 5 years ago

Hi @dougdellolio

I use the built-in limit sell order function as following: var orderResponse = await _CoinbaseProClient.OrdersService.PlaceLimitOrderAsync(CoinbasePro.Services.Orders.Types.OrderSide.Sell, CoinbasePro.Shared.Types.ProductType.BtcUsd, correctOrderSize, currentPrice);

dougdellolio commented 5 years ago

@codeinflash the error indicates a problem with post only. The default is set to true. Is that what you want? If not, you can pass in ‘false’ for post only mode. If you are unsure, I would read more in their docs (https://docs.pro.coinbase.com/#place-a-new-order under post only) to make sure you understand what the flag will do.

codeinflash commented 5 years ago

Hi @dougdellolio ,

Thanks for the reference! My function uses the default parameters, which are time_in_force = GTC and PostOnly = true. Yes, I wanted to have Post-Only (maker) sell order. I still can't figure out in what kind circumstance it raises the post only error for selling a limit order even though it is GTC..

Thanks.

dougdellolio commented 5 years ago

hmmm.. from my understanding you wouldn't be able to set a price that is the same or lower than the highest buy order.

Wish I could help more.... if you do find out the answer please post back for future reference