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

Trade Updates #6

Open
mainstringargs opened this issue Jun 13, 2019 · 1 comment
Open

Trade Updates #6

mainstringargs opened this issue Jun 13, 2019 · 1 comment

Comments

@mainstringargs
Copy link

Question on this part of the algorithm:

        if event == 'fill':
            if data.order['side'] == 'buy':
                position.update_total_shares(
                    int(data.order['filled_qty'])
                )
            else:
                position.update_total_shares(
                    -1 * int(data.order['filled_qty'])
                )
            position.remove_pending_order(
                data.order['id'], data.order['side']
            )

I'm wondering if it should really be:

        if event == 'fill':
            if data.order['side'] == 'buy':
                position.update_filled_amount(
                   data.order['id'], int(data.order['filled_qty']),
                   data.order['side']
                )
            else:
                position.update_filled_amount(
                   data.order['id'], int(data.order['filled_qty']),
                   data.order['side']
                )
            position.remove_pending_order(
                data.order['id'], data.order['side']
            )

Because, I believe, a PARTIALLY_FILLED order can then become FILL order once it is fully filled. Any thoughts or do I have that incorrect?

@molon
Copy link

molon commented Dec 1, 2023

I think you are right

if event == 'fill' or event == 'partial_fill':
    position.update_filled_amount(
        data.order['id'], int(data.order['filled_qty']),
        data.order['side']
    )
    if event == 'fill' 
        position.remove_pending_order(
            data.order['id'], data.order['side']
        )

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

3 participants
@molon @mainstringargs and others