question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

RestClient PlaceOrder

See original GitHub issue

Describe the bug restClient.Spot.Order.PlaceOrder(“BTCUSDT”, OrderSide.Buy, OrderType.Market, 0.1) returns null. Sometimes it places order and returns null but most of the time null is returned and order is not placed. It does not happen every time, but when some time has passed, it happens. KeepAliveUserStream is working fine.

To Reproduce

WebCallResult<BinancePlacedOrder> result = null;
try
{
    result = restClient.Spot.Order.PlaceOrder("BTCUSDT", OrderSide.Buy, OrderType.Market, 0.1);
    if (result.Success)
    {
         return result.Data.OrderId;
    }
}
catch (Exception ex)
{
    Console.WriteLine(ex.Message); --- Object reference not set to an instance of an object.
}

Expected behavior WebCallResult != null is returned, so Success or Error can be checked

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:26 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
JKorfcommented, Jun 27, 2021

You’re not checking any result if it was successfull. If you call for example GetAccountInfo you’ll have to check if the call was successful by doing something like this:

var accountInfoResult = client.General.GetAccountInfo();
if(!accountInfoResult.Success)
{
  // Handle error, the accountInfoResult.Error property will have more details on what went wrong
  return;
}

var data = accountInfoResult.Data;

Checking it like this will guarentee that data is never null. If the call fails for some reason then client.General.GetAccountInfo().Data.Balances will throw an exception because the Data property is null.

1reaction
ZigmundLcommented, May 18, 2021

Very interesting info, thx. It seems to me a little wierd to create a new instance of restclient for every request. I thought that one object would be enough. Like you create a single instance, and use it so send different requests. That is what I was doing. I’m testing your examples with using and multiple restclients at the moment.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why does placeOrder() take so much time to create Request?
Hi All! I have a requirement to create several Requested Items in a Request based on a list of elements specified by the...
Read more >
Salesforce Placeorder Rest Api
Place Order REST API Developer Guide. Requirements and Limitations Authorization Through Connected Apps and OAuth ...
Read more >
Place order using REST API
Place order using REST API. To submit an order, we need some additional data to enter in our request as seen in the...
Read more >
Place order using Magento Rest API - Issue
1 Answer 1 · 1. Get Customer Token · 2. Get Cart ID (Quote ID) - using customer id. · 3. Add Configurable...
Read more >
clients
func (*RestClient) GetTransfers ¶ ... GetTransfers gets a historical record of deposits/withdrawals between the given time range. :param t_start: (str) time in ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found