Dave-Vallance / bt-ccxt-store

Fork of Ed Bartosh's CCXT Store Work
MIT License
423 stars 187 forks source link

Responses to orders are sometimes None #60

Open poohsen opened 2 years ago

poohsen commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

Looks like a time sync issue:

https://github.com/ccxt/ccxt/issues/936

Ying-da commented 1 year ago

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 commented 1 year ago

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