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

Error in cancelOrder in TradeService class #584

Closed
Tempys opened this issue May 4, 2021 · 20 comments
Closed

Error in cancelOrder in TradeService class #584

Tempys opened this issue May 4, 2021 · 20 comments
Milestone

Comments

@Tempys
Copy link

Tempys commented May 4, 2021

when i tried to loanch method

    /**
     * Cancel order.
     *
     * @param orderId order id
     * @return true if cancelled
     */
    boolean cancelOrder(String orderId);

in TradeService

i got the next error

2021-05-04 20:45:31,536 ERROR [boundedElastic-5] tech.cassandre.trading.bot.service.xchange.TradeServiceXChangeImplementation: TradeService - Error canceling order 130285696 : You need to provide the currency pair to cancel an order.

@straumat
Copy link
Member

straumat commented May 4, 2021

@Tempys thx! It works without currency pair on kucoin ! Which exchange are you using ? still Binance ?

@Tempys
Copy link
Author

Tempys commented May 4, 2021

@straumat yes im using binance

@Tempys
Copy link
Author

Tempys commented May 4, 2021

@straumat should be additional method
public boolean cancelOrder(CancelOrderParams params) throws IOException {

@Tempys
Copy link
Author

Tempys commented May 4, 2021

also CancelOrderParams its interfaces and required a specific implementation ((((

@dstibbe
Copy link

dstibbe commented May 5, 2021

But that would mean you would have the call one or the other strategy based on the exchange being used.
Wouldn't it be better to always provide the currency pair?

@straumat
Copy link
Member

straumat commented May 5, 2021

@dstibbe I will call the method with the currency pair, and my integration tests will check if it still works with an exchange not supporting this parameter.

I already do that here. Some exchanges requires currency pair as a parameter to trieve trades

@straumat
Copy link
Member

straumat commented May 5, 2021

Geez. More complicated than thought... BinanceCancelOrderParams has to be created so It forces me to add xchange-binance to the main project which is really not a good idea :(

@dstibbe
Copy link

dstibbe commented May 5, 2021

But why retrieve the currency pair from the order repos if the strategy can simply provide it ?

And regarding xchange-binance: just implement the CancelOrderByCurrencyPair and CancelOrderByIdParams interfaces
or does it really need to be BinanceCancelOrderParams?

@straumat
Copy link
Member

straumat commented May 5, 2021

In cassandre, i don't have a dependency for any exchange library except xchange-core. And it seems I need to fulfill BinanceCancelOrderParams which forces me to add xchange-binance which is not clean

@dstibbe
Copy link

dstibbe commented May 5, 2021

No. binance xchange implementation just checks for CancelOrderByCurrencyPair and CancelOrderByIdParams...
implement these interfaces and no extra dependency is required

@Tempys
Copy link
Author

Tempys commented May 5, 2021

you need to move that logic on strategy level as i do

that code is working for me

CancelOrderParams cancelOrderParams = new BinanceCancelOrderParams(currencyPair,buyOrderId);
                            getTradeService().cancelOrder(cancelOrderParams);

in that case u ll avoid issues with adding additional libraries

@straumat
Copy link
Member

straumat commented May 5, 2021

@dstibbe but a BinanceCancelOrderParams has to be instantiated no?

@dstibbe
Copy link

dstibbe commented May 5, 2021

NO :P

@dstibbe
Copy link

dstibbe commented May 5, 2021

Edited : Just use the class mentioned a few posts down : DefaultCancelOrderByCurrencyPairAndIdParams

@Tempys Tempys closed this as completed May 5, 2021
@Tempys Tempys reopened this May 5, 2021
@Tempys
Copy link
Author

Tempys commented May 5, 2021

@dstibbe its not only binance specific other exchange can require other parameters

so about that functionality should be responsible strategy and not bot

@dstibbe
Copy link

dstibbe commented May 5, 2021

And I would just change the signature of cassandre's TradeService cancelOrder to : public final boolean cancelOrder(final String orderId, CurrencyPair currency)
and have the strategies call cancelOrder with the currency .
Instead of pulling it out of the order repos

@dstibbe
Copy link

dstibbe commented May 5, 2021

@Tempys yes, it is not only binance specific, so I would say have Cassandre's tradeService always call the xchange tradeservice with a currencypair

@dstibbe
Copy link

dstibbe commented May 5, 2021

If you don't, you are gonna have to make logic based on which exchange you are communicating with

@dstibbe
Copy link

dstibbe commented May 5, 2021

And I just noticed , the class I was suggesting to implement already exists ! :D
Use org.knowm.xchange.service.trade.DefaultCancelOrderByCurrencyPairAndIdParams instead of BinanceCancelOrderParams

@dstibbe
Copy link

dstibbe commented May 5, 2021

@Tempys regarding cancel orders on other exchanges: it seems Xchange has narrowed it down to 4 params:

  • orderId
  • currencyPair
  • orderType
  • userReference

based on the existing interface

@straumat straumat added this to the 5.0.1 milestone Jun 20, 2021
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

3 participants