Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Responses to orders are sometimes None #60

Open
poohsen opened this issue Jan 17, 2022 · 7 comments
Open

Responses to orders are sometimes None #60

poohsen opened this issue Jan 17, 2022 · 7 comments

Comments

@poohsen
Copy link

poohsen commented Jan 17, 2022

I've seen this with binance and ftx. No error message, just a None response to the call to self.buy or self.sell. No open order at the exchange either. As if nothing happened. I'm not even sure if this is a problem with the bt-ccxt-store or with ccxt.

Is there anything that I can do to either make the requests more robust or to debug the issue?

@chuzheng88
Copy link

My codes ocur the same error, and my codes (samples in bt-ccxt-store) are described as follows:
image

image

image

my print function prints the None of my self.order, and then self.sell(self.order) function occurs error. However, the order submitted by codes happened in web/app develovped by Binance Exchange.

I want to konw what happend and how to deal with this problem.

@chuzheng88
Copy link

I've seen this with binance and ftx. No error message, just a None response to the call to self.buy or self.sell. No open order at the exchange either. As if nothing happened. I'm not even sure if this is a problem with the bt-ccxt-store or with ccxt.

Is there anything that I can do to either make the requests more robust or to debug the issue?

Are you deal with your problmes ?

@Saran33
Copy link

Saran33 commented Apr 30, 2022

To get the examples working, you can amend the CCXTBroker._submit() method. Firstly, it should raise, log or print Exceptions for failed orders. In this case, @chuzheng88, the response from Binance is binance {"code":-1104,"msg":"Not all sent parameters were read; read '9' parameter(s) but was sent '10'."}. This is because created is not a valid parameter for the API calls. I moved params['created'] = created below the call to create an order. Not sure if this is the best solution, as I haven't tried it with backtesting yet.

try:
    # all params are exchange specific: https://github.com/ccxt/ccxt/wiki/Manual#custom-order-params
    ret_ord = self.store.create_order(symbol=data.p.dataname, order_type=order_type, side=side,
                                      amount=amount, price=price, params=params)
    params['created'] = created  # Add timestamp of order creation for backtesting

except Exception as e:
    print(e)
    print("ORDER FAILED")
    # save some API calls after failure
    self.use_order_params = False
    return None

@chuzheng88
Copy link

To get the examples working, you can amend the CCXTBroker._submit() method. Firstly, it should raise, log or print Exceptions for failed orders. In this case, @chuzheng88, the response from Binance is binance {"code":-1104,"msg":"Not all sent parameters were read; read '9' parameter(s) but was sent '10'."}. This is because created is not a valid parameter for the API calls. I moved params['created'] = created below the call to create an order. Not sure if this is the best solution, as I haven't tried it with backtesting yet.

try:
    # all params are exchange specific: https://github.com/ccxt/ccxt/wiki/Manual#custom-order-params
    ret_ord = self.store.create_order(symbol=data.p.dataname, order_type=order_type, side=side,
                                      amount=amount, price=price, params=params)
    params['created'] = created  # Add timestamp of order creation for backtesting

except Exception as e:
    print(e)
    print("ORDER FAILED")
    # save some API calls after failure
    self.use_order_params = False
    return None

Thank you for your reply. I have deal with this problem. However, a few days ago, a program that was working correctly encountered a new problem:

InvalidNonce: binance {"code":-1021,"msg":"Timestamp for this request is outside of the recvWindow."}

I don't konw why ?

@Saran33
Copy link

Saran33 commented May 4, 2022

Looks like a time sync issue:

ccxt/ccxt#936

@Ying-da
Copy link

Ying-da commented Nov 4, 2022

Hey @chuzheng88, How you deal with the previous problem, I still stuck at here, my self.buy() return None. and I followed method provided by @Saran33. It is not working.

@dornerbalint
Copy link

@Ying-da make sure not have amount == 0 or price == 0.
ccxtbroker._submit() returns None with the above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants