Skip to content

get_order_history returning orders from the past #116

@jazarija

Description

@jazarija

Issue type

  • bug
  • missing functionality
  • performance
  • feature request

Brief description

This issue is related to #111 (comment) where I was asking how to properly detect if a post-only order landed in the orderbook or is canceled. In the presented solution one has to access the order history book and see what happened to the order.

Unfortunately, if an order lands in the order book there is no historical record. In particular, it seems as if the get_order_history is returning inconsistent results. Sometimes the last order does not match the actual last order, and even restricting the search with the start parameter gives incorrect results. Consider the following example

from bfxapi import Client
bfx = Client(API, KEY)
ret = await bfx.rest.submit_order(amount=0.0002, price=1, symbol='tBTCUSD', post_only=True)
mts = ret.notify_info[0].mts_create
L = await bfx.rest.get_order_history(symbol='tBTCUSD', start=mts, end=None, limit=1, sort=-1)
L[0].mts_create > mts
False
L[0].mts_update > mts
False

In this case the order book goes directly into the book and is not registered as a historical order. The returned order is a "random" one whose execution was way before our order was posted.

What is more, sometimes (this is not 100% reproducible) querying for all orders with a starting date far in the future, returns some historical records

[L = await bfx.rest.get_order_history(symbol='tBTCUSD', start=1916087019657, end=None, limit=1, sort=-1)
[<bfxapi.models.order.Order at 0x7efc8cb7ab80>]
print(L[0])
Order <'tBTCUSD' amount_orig=0.0002 amount_filled=0.0 mts_create=1616086389000 status='CANCELED' id=60750038057>]

This final result is inconsistent, as sometimes get_order_history correctly returns an empty list

L = await bbfx.rest.get_order_history(symbol='tBTCUSD', start=1916087019657, end=None, limit=1, sort=-1)
L
[]

I am not sure what is causing these results, but so far I am getting quite inconsistent results trying to obtain history about the last submitted order.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions