Skip to content

Wrong price returned by market order book #59

@abitmore

Description

@abitmore

In market.py, orderbook function:

        asks = list(map(lambda x: Order(
            Amount(x["quote"], self["quote"], bitshares_instance=self.bitshares),
            Amount(x["base"], self["base"], bitshares_instance=self.bitshares),
            bitshares_instance=self.bitshares
        ), orders["asks"]))
        bids = list(map(lambda x: Order(
            Amount(x["quote"], self["quote"], bitshares_instance=self.bitshares),
            Amount(x["base"], self["base"], bitshares_instance=self.bitshares),
            bitshares_instance=self.bitshares
        ), orders["bids"]))

Orders are constructed with base amount and quote amount only. This leads to wrong price when the order was partially filled.

For example, with this data:

Mon Mar 19 22:19:22 UTC 2018
{"id":1037,"jsonrpc":"2.0","result":{"base":"USD","quote":"BTS","bids":[{"price":"0.127431355173731879","quote":"2.88782","base":"0.3680"}],"asks":[{"price":"0.12743137102808178","quote":"431.10656","base":"54.9365"}]}}

The bid price returned by market.orderbook is 0.3680/2.88782 = 0.12743177, which is far from the real price returned by the API server which is 0.127431355.

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