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

Add Support for Partially and Canceled order callback functions #106

Open
Crypto7816 opened this issue May 9, 2024 · 0 comments
Open

Add Support for Partially and Canceled order callback functions #106

Crypto7816 opened this issue May 9, 2024 · 0 comments

Comments

@Crypto7816
Copy link

Crypto7816 commented May 9, 2024

Is your feature request related to a problem? Please describe.
A trading robot requires functionality to manage order statuses effectively. Specifically, there is a need for callback functions that can respond to changes in order status, such as identifying orders that are partially filled, fully filled, or canceled.

Describe the solution you'd like
To address this, I propose the implementation of specific callback functions within the trading robot's framework. For instance, when an order is partially filled, the def on_partially_filled_order() function would be triggered. Similarly, if an order is canceled, the def on_canceled_order() should be called. We can refer to the Lumibot framework for implementation.

Simple Framework demo

async def watch_order_loop(exchange: ccxt.pro.Exchange, symbol: str):
    your_delay = 1
    await exchange.throttle(your_delay)
    while True:
        try:
            orders = await exchange.watch_orders(symbol)
            for order in orders:
                if order['status'] == 'open' and order['filled'] == 0:
                    print('---------------------------Open Order NEW---------------------------')
                    # strategy.on_new_order(order)
                elif order['status'] == 'open' and order['filled'] == 0:
                    print('---------------------------Open Order PARTIALLY FILLED---------------------------')
                    # strategy.on_partially_filled_order(order)
                elif order['status'] == 'closed':
                    print('---------------------------Close Order---------------------------')
                    # strategy.on_close_order(order)
                elif order['status'] == 'canceled':
                    print('---------------------------Cancel Order---------------------------')
                   # strategy.on_cancel_order(order)
            # print(exchange.iso8601(exchange.milliseconds()), 'watch_orders_loop', len(orders), ' last orders cached')
            print('---------------------------------------------------------------')
        except Exception as e:
            # break
            print(e)
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