example-hftish icon indicating copy to clipboard operation
example-hftish copied to clipboard

Trade Updates

Open mainstringargs opened this issue 5 years ago • 1 comments

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?

mainstringargs avatar Jun 13 '19 15:06 mainstringargs

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']
        )

molon avatar Dec 01 '23 02:12 molon