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

Modify or replace order #2818

Open
walec51 opened this issue Sep 27, 2018 · 6 comments
Open

Modify or replace order #2818

walec51 opened this issue Sep 27, 2018 · 6 comments

Comments

@walec51
Copy link
Collaborator

walec51 commented Sep 27, 2018

Some exchanges have API methods that allow to modify an order or cancel an existing one and create a new one in one request. This could be added to generic interfaces as one method:

Order replaceOrder(String currenctOrderId, Order newOrderData)

which will either modify an existing order or replace it depending on the exchanges API capabilities.

This feature was initially proposed in PR: #2806
however current API support seams not wide spread enough to add to generic interfaces.

Feature support in exchange APIs is monitored on: https://github.com/knowm/XChange/wiki/Generic-feature-candidates

@cymp
Copy link
Contributor

cymp commented Oct 17, 2018

I think it is a dangerous addition to the generic interface. This sure is a great feature when implemented by the exchanges, but unfortunately too rare. Will cause many client codes to throw unexpected exceptions.

@sergluka
Copy link
Contributor

I think it is a dangerous addition to the generic interface. This sure is a great feature when implemented by the exchanges, but unfortunately too rare.

There are already functions in the generic interface that hasn't implemented in particular exchanges. For instance placeStopOrder, placeMarketOrder and even getOrder aren't exists in 100% exchanges. There are no requirements that exchange have to realize all of them. Moreover, since all functions in interfaces are defined as default, I can presume that it's allowed by this library architecture.

Will cause many client codes to throw unexpected exceptions.

If developer will use library blindly, without looking at what features are supported, he gets exceptions even without modifyOrder.

@roeiba
Copy link
Contributor

roeiba commented Dec 27, 2018

I agree with @SergeyLukashevich and I think it is OK to add such interface method, and add it to all supported exchanges and returning 'not implemented' exception on the exchanges that does not support replace feature.

I already have that interface at my code with implementation for Bitfinex and Poloniex only:
https://github.com/roeiba/XChange/commits/replace_order

@walec51
Copy link
Collaborator Author

walec51 commented Jan 7, 2019

@SergeyLukashevich the fact that some generic features are not supported on 100% exchanges is not an argument to assume that features supported by a few exchanges are generic

some exchanges support modifyOrder and some support replaceOrder

so we could consider adding String replaceOrModifyOrder(Order modifiedOrder) which returns the new orders id or the unchanged id of the modified order depending on what capability is supported by the underlining exchange

however according to my research at https://github.com/knowm/XChange/wiki/Generic-feature-candidates this still does not cover > 50% of exchanges

so to not have a method that throws a NotYetImplementedException for > 50% of exchanges we could add a default method to the interface like

String replaceOrModifyMarketOrder(MarketOrder modifiedOrder) {
    cancelOrder(modifiedOrder.getId());
    return placeMarketOrder(modifiedOrder);
}

@sergluka
Copy link
Contributor

sergluka commented Jan 9, 2019

Sounds good for me. But replaceOrModifyOrder looks too long. How about changeOrder? it can be related to both modify and replace operations.

@walec51
Copy link
Collaborator Author

walec51 commented Jan 14, 2019

Ok for changeOrder but the javadoc in the interface should mention that on most exchanges this method will cancel the given order and create a new one in its place and on some it will modify an order preserving its id.

sergluka pushed a commit to sergluka/XChange that referenced this issue Jan 17, 2019
Update feature request based on
[knowm#2818];
Update documentation;
Make cancel and replace by two requests as default behaviour
for exchanges that doesn't support modify or cancel/replace.
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

4 participants