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

(feat) Batch order placing for Injective #305

Closed

Conversation

petioptrv
Copy link

@petioptrv petioptrv commented Jan 27, 2023

Before submitting this PR, please make sure:

  • Your code builds clean without any errors or warnings
  • You are using approved title ("feat/", "fix/", "docs/", "refactor/")

A description of the changes proposed in the pull request:

This PR introduces batch order creation and cancelation for the client.

The functionality is implemented with backward compatibility.

The Injective connector is refactored to provide this enhanced order management.

Tests performed by the developer:

Added tests for the new functionality.

Tips for QA testing:

Please test that at least one spot and one perpetual exchanges work with a normal PMM strategy, as well as with the new batch_order_update.py script. Also, test Injective specifically with the new script. The script strategy has four phases:

  1. Two orders are placed successfully.
  2. Then the orders are canceled successfully.
  3. After that, two more orders are attempted; one order is placed successfully and one order fails due to the amount being zero. Here, the bot should log the failed event appropriately.
  4. Finally, the existing order is canceled.

The script begins by setting some global variables

CONNECTOR = "okx"
TRADING_PAIR = combine_to_hb_trading_pair(base="BTC", quote="USDT")
AMOUNT = Decimal("0.0001")
ORDERS_INTERVAL = 10
PRICE_OFFSET_RATIO = Decimal("0.1")  # 10%

The ORDERS_INTERVAL variable is the number of ticks (seconds) between each of the script phases. The PRICE_OFFSET_RATIO variable sets the orders' prices at 10% from the current mid-market price.

Associated Gateway PR

CoinAlpha/gateway#4

@petioptrv petioptrv marked this pull request as draft January 27, 2023 05:55
@petioptrv petioptrv requested a review from a team January 27, 2023 05:56
@petioptrv
Copy link
Author

@CoinAlpha/qa-team, @CrimsonJacket, @aarmoa

I have opened this PR for review by the developers. Since we still don't have a confirmed-stable version for the base PR, then this PR cannot yet be QA-tested.

Comment on lines 87 to 90
export interface ClobDeleteOrderRequestExtract {
market: string;
orderId: string;
}

Choose a reason for hiding this comment

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

Is there a reason for this naming convention over using CancelOrderParam like what we have for CreateOrderParam?

Copy link

Choose a reason for hiding this comment

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

No much reason. That could also work. Just trying to keep reference to ClobDeleteOrderRequest so it can be obvious that it's peculiar to CLOB.

Comment on lines +279 to +286
for order in orders_to_create:
if order.is_buy:
client_order_id = self.buy(
trading_pair=order.trading_pair,
amount=order.quantity,
order_type=OrderType.LIMIT,
price=order.price,
)

Choose a reason for hiding this comment

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

Is there a reason why the default behaviour for batch_order_create is in contrast to what it is originally meant to do?

Copy link

Choose a reason for hiding this comment

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

Yes @CrimsonJacket . This is the default implementation we add in ConnectorBase to make all connectors polymorphic with the new functionality. But we are not providing now the logic to the the batch actions in all connectors, only for Injective. That is why the default behavior has to be doing the same thing we do when requested actions for a single order: handling them one by one.

Choose a reason for hiding this comment

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

Yes @CrimsonJacket . This is the default implementation we add in ConnectorBase to make all connectors polymorphic with the new functionality. But we are not providing now the logic to the the batch actions in all connectors, only for Injective. That is why the default behavior has to be doing the same thing we do when requested actions for a single order: handling them one by one.

Hello, I see you have been active in certain areas where we need some simple but urgent help. Can you please contact me on telegram @saveplanetearthdev , thank you.

Copy link

@CrimsonJacket CrimsonJacket left a comment

Choose a reason for hiding this comment

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

@petioptrv I have left some comments wrt the default behaviour of batch_order_create and some minor comments on the naming convention of ClobDeleteOrderRequestExtract. Personally I feel that batch_order_create should, as its name suggest, should perform the same logic that is defined within GatewayCLOBSPOT.batch_order_create and we should only really overwrite it when needed

@petioptrv petioptrv mentioned this pull request Jan 27, 2023
2 tasks
@petioptrv
Copy link
Author

@petioptrv I have left some comments wrt the default behaviour of batch_order_create and some minor comments on the naming convention of ClobDeleteOrderRequestExtract. Personally I feel that batch_order_create should, as its name suggest, should perform the same logic that is defined within GatewayCLOBSPOT.batch_order_create and we should only really overwrite it when needed

@CrimsonJacket, as Abel pointed out in his comment, we are only implementing the full functionality for Injective in this PR

@petioptrv
Copy link
Author

petioptrv commented Mar 9, 2023

Closing to re-open towards foundation: hummingbot#6139

@petioptrv petioptrv closed this Mar 9, 2023
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.

5 participants