Coder Social home page Coder Social logo

Comments (8)

curious-debug avatar curious-debug commented on July 28, 2024

I'm receiving the exact same error on client.CreateOrder. This occurs no matter if it is a market buy or market sell. Also using BinanceDotNet v4.0.1. My ApiKey and Secret are valid.

var createOrderResponse = await client.CreateOrder(new BinanceExchange.API.Models.Request.CreateOrderRequest(){
  Symbol = <<anycoinsymbol - I've tried multiple>>,
  Side = <<BinanceExchange.API.Enums.OrderSide.Buy>> or <<BinanceExchange.API.Enums.OrderSide.Sell>>,
  Type = <<BinanceExchange.API.Enums.OrderType.Market>>, 
  Quantity = <correctly calculated qty that meets rules in Exchange Info payload>>,
  NewClientOrderId = <<my custom string>>
});

I've tried to catch all BinanceExchange.API.Models.Response.Errors, but all I get is this:

fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[0]
      An unhandled exception has occurred while executing the request
System.ArgumentNullException: Value cannot be null.
Parameter name: The Guarded argument was null.
   at BinanceExchange.API.Client.BinanceClient.<CreateOrder>d__20.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at TraderWeb.Controllers.NewApiOrderController.<Post>d__1.MoveNext() in {redacted file path}\NewApiOrderController.cs:line 154 {this is the line where client.CreateOrder exists}
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeActionMethodAsync>d__12.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeNextActionFilterAsync>d__10.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeInnerFilterAsync>d__14.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeNextResourceFilter>d__22.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeFilterPipelineAsync>d__17.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeAsync>d__15.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Builder.RouterMiddleware.<Invoke>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.<Invoke>d__7.MoveNext()

from binancedotnet.

paolobriones avatar paolobriones commented on July 28, 2024

Heres what i reckon is happening, based on the binance api docs (https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md), depending on the type of Order you are executing some parameters are required and some are not.

But the code here in BinanceDotNet requires that all parameters be passed into the CreateTestOrder() method.

I.e.
When you execute a Market Buy Order, as per the binance api, the only requirement is the QTY, but in the BinanceDotNet code, Time-In-Force is still a required parameter.

And since you passed in the Time-In-Force value, BinanceDotNet passes that parameter to the binance api which will cause a "Malformed Request" error

from binancedotnet.

curious-debug avatar curious-debug commented on July 28, 2024

@paolobriones @glitch100
So any idea as to the solution? I cannot make any Market orders without getting an error.

On my CreateOrderRequest object in the client.CreateOrder method:

  • If I set TimeInForce = BinanceExchange.API.Enums.TimeInForce.GTC, I receive this:
Malformed requests are sent to the server. Please review the request object/string
  • If I do not include TimeInForce, or if I set TimeInForce = null, I receive this:
fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[0]
      An unhandled exception has occurred while executing the request
System.ArgumentNullException: Value cannot be null.
Parameter name: The Guarded argument was null.
   at BinanceExchange.API.Client.BinanceClient.<CreateOrder>d__20.MoveNext()
--- End of stack trace from previous location where exception was thrown ---

from binancedotnet.

paolobriones avatar paolobriones commented on July 28, 2024

@ryanjhardinorders thats exactly what i said, its sending additional request parameters that causes the binance api to throw a malformed error

@glitch100 im working on a fix for it now, will send as soon as i can

from binancedotnet.

paolobriones avatar paolobriones commented on July 28, 2024

@glitch100 this bug is related to #10

from binancedotnet.

curious-debug avatar curious-debug commented on July 28, 2024

@paolobriones
OK Cool. I am new to git/github and also relatively new to C#, so if you could be kind enough to guide me a bit on how to implement your changes once posted, I would very much appreciate it. (I'll be a code contributor soon enough!) Thanks!

from binancedotnet.

glitch100 avatar glitch100 commented on July 28, 2024

I believe this fix is included in the #32 release . Please retest there.

If you are wondering it's because I have a deliberate Guard in methods to prevent mandatory parameters being missed. It therefore saves a trip to the API. It appears Binance recently changed which parameters were mandatory. Please try the latest release and see if it fixes your issue

from binancedotnet.

paolobriones avatar paolobriones commented on July 28, 2024

@glitch100 @ryanjhardinorders
Confirmed, this bug is fixed with release #32

from binancedotnet.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.