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

Updating order tag returns error on Bybit #28

Open
zurpet opened this issue Jan 27, 2025 · 0 comments
Open

Updating order tag returns error on Bybit #28

zurpet opened this issue Jan 27, 2025 · 0 comments

Comments

@zurpet
Copy link

zurpet commented Jan 27, 2025

Hi, we use order tagging functionality in LEAN a lot in our strategies (one use-case is restoring trade state from storage/cache after restarting a strategy) and we've noticed this error message appearing consistently when we try to update order tags on Bybit:
Image

Anytime LEAN tries to update the order tag, it sends order modification request to Bybit and we get the error message above, but Bybit does not support order tagging (ie. like IB does), so there is no reason to even try to send the update to Bybit.

We've prepared a sample script to reproduce the error on your end:

# region imports
from AlgorithmImports import *
# endregion

class OrderNotModified(QCAlgorithm):

    def initialize(self):
        # Brokerage and account settings
        self.set_brokerage_model(BrokerageName.BYBIT, AccountType.MARGIN)
        self.set_account_currency("USDT")

        self.btc = self.add_crypto_future("BTCUSDT", Resolution.MINUTE, Market.BYBIT)

        self.lmt_sent = False
        self.lmt_ticket = None

    def on_data(self, data: Slice):
        if "BTCUSDT" not in data.bars:
            return

        trade_bar = data.bars["BTCUSDT"]

        if self.lmt_ticket is not None:
            # update tag with some random string
            # this throws brokerage error "order not modified"
            self.lmt_ticket.update_tag(self.lmt_ticket.tag + " 1")

        if not self.lmt_sent:
            self.limit_order(self.btc.symbol, 0.1, trade_bar.close*0.9, tag="LMT")
            self.lmt_sent = True

    def on_order_event(self, order_event):
        if order_event.status == OrderStatus.SUBMITTED and order_event.ticket.tag == "LMT":
            self.lmt_ticket = order_event.ticket

This behaviour fills up the logs with unnecessary error messages.

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

1 participant