Skip to content

Wrong price when using own last trade as CP #708

@bitphage

Description

@bitphage

Some users reported bot is screwing up and selling one of the asset when using own last trade price as center price. I investigated this issue and found it's happening when price drifting while bot replacing orders so it's becomes is_maker: False. This happens rarely so we didn't get much reports on this.

fill_price assets identical to pays and receives

[
  {
    "account_history": {
      "account": "1.2.973383",
      "id": "2.9.1052214535",
      "next": "2.9.1052203738",
      "operation_id": "1.11.1027541699",
      "sequence": 10256
    },
    "block_data": {
      "block_num": 43440842,
      "block_time": "2019-12-10T01:00:12",
      "trx_id": "74446b806cb01adf7b4a3337eb88abab84763346"
    },
    "operation_history": {
      "op": "[4,{\"fee\":{\"amount\":39,\"asset_id\":\"1.3.1895\"},\"order_id\":\"1.7.426545492\",\"account_id\":\"1.2.973383\",\"pays\":{\"amount\":26721662,\"asset_id\":\"1.3.0\"},\"receives\":{\"amount\":39618,\"asset_id\":\"1.3.1895\"},\"fill_price\":{\"base\":{\"amount\":26721662,\"asset_id\":\"1.3.0\"},\"quote\":{\"amount\":39618,\"asset_id\":\"1.3.1895\"}},\"is_maker\":true}]",
      "op_in_trx": 1,
      "op_object": {
        "account_id": "1.2.973383",
        "fee": {
          "amount": 39,
          "asset_id": "1.3.1895"
        },
        "fill_price": {
          "base": {
            "amount": 26721662,
            "asset_id": "1.3.0"
          },
          "quote": {
            "amount": 39618,
            "asset_id": "1.3.1895"
          }
        },
        "is_maker": true,
        "order_id": "1.7.426545492",
        "pays": {
          "amount": 26721662,
          "asset_id": "1.3.0"
        },
        "receives": {
          "amount": 39618,
          "asset_id": "1.3.1895"
        }
      },
      "operation_result": "[0,{}]",
      "trx_in_block": 8,
      "virtual_op": 2
    },
    "operation_id_num": 1027541699,
    "operation_type": 4
  }
]

BAD case: fill_price assets are different when bot is not a maker:

[
  {
    "account_history": {
      "account": "1.2.973383",
      "id": "2.9.1052214581",
      "next": "2.9.1052214580",
      "operation_id": "1.11.1027541745",
      "sequence": 10259
    },
    "block_data": {
      "block_num": 43440843,
      "block_time": "2019-12-10T01:00:15",
      "trx_id": "272fe189aa25079fd76db0e585b3f2963e671a9b"
    },
    "operation_history": {
      "op": "[4,{\"fee\":{\"amount\":39,\"asset_id\":\"1.3.1895\"},\"order_id\":\"1.7.426549358\",\"account_id\":\"1.2.973383\",\"pays\":{\"amount\":25919767,\"asset_id\":\"1.3.0\"},\"receives\":{\"amount\":39176,\"asset_id\":\"1.3.1895\"},\"fill_price\":{\"base\":{\"amount\":667966,\"asset_id\":\"1.3.1895\"},\"quote\":{\"amount\":441942080,\"asset_id\":\"1.3.0\"}},\"is_maker\":false}]",
      "op_in_trx": 0,
      "op_object": {
        "account_id": "1.2.973383",
        "fee": {
          "amount": 39,
          "asset_id": "1.3.1895"
        },
        "fill_price": {
          "base": {
            "amount": 667966,
            "asset_id": "1.3.1895"
          },
          "quote": {
            "amount": 441942080,
            "asset_id": "1.3.0"
          }
        },
        "is_maker": false,
        "order_id": "1.7.426549358",
        "pays": {
          "amount": 25919767,
          "asset_id": "1.3.0"
        },
        "receives": {
          "amount": 39176,
          "asset_id": "1.3.1895"
        }
      },
      "operation_result": "[0,{}]",
      "trx_in_block": 6,
      "virtual_op": 1
    },
    "operation_id_num": 1027541745,
    "operation_type": 4
  }
]

I'll provide a fix for this.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions