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

[RestExchange] add option to edit_order_by_replacing #820

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

techfreaque
Copy link
Contributor

see binance usdm as an example usage

)
)

replaced_order = await self.create_order(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't we cancel the order first to free funds ? We should also wait for the order to be completely cancel as is trader.cancel_order() I think

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would have worked with some order types on some exchanges, but I reversed it anyway.
I didnt had a chance to test this code yet tho. I will let you know once I tested it.

@GuillaumeDSM GuillaumeDSM requested a review from Herklos February 10, 2023 10:54
@GuillaumeDSM GuillaumeDSM self-assigned this Feb 10, 2023
@techfreaque techfreaque force-pushed the add_edit_order_by_replacing branch from 8961844 to 6ad9c27 Compare February 16, 2023 15:09
@techfreaque techfreaque force-pushed the add_edit_order_by_replacing branch 2 times, most recently from 33e3677 to 109e215 Compare March 13, 2023 09:19
):
# Can be used if api doesnt have an endpoint to edit orders
# see binance USD m as an example
order_to_cancle = (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
order_to_cancle = (
order_to_cancel = (

@@ -163,6 +163,45 @@ async def _edit_order(self, order_id: str, order_type: enums.TraderOrderType, sy
quantity, price, stop_price, side,
current_price, params)

async def edit_order_by_replacing(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a test for it please?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how to test that, ss there somewhere a similar example test for a real exchange trading test?

Copy link
Member

@Herklos Herklos Mar 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A test like https://github.com/Drakkar-Software/OctoBot-Trading/blob/master/tests/exchanges/implementations/test_default_rest_exchange.py#L46 to ensure that the new order is properly createdand to also test that the portfolio values are properly updated (available and total).
You can use the simulated exchange

if replaced_order:
return replaced_order
else:
raise RuntimeError(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should prefer something like a

Suggested change
raise RuntimeError(
raise errors.FailedRequest(

@techfreaque techfreaque force-pushed the add_edit_order_by_replacing branch from 9f5b1e9 to 70dfa9a Compare March 22, 2023 11:22
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

Successfully merging this pull request may close these issues.

3 participants