signum-node icon indicating copy to clipboard operation
signum-node copied to clipboard

Extend `getTradeJournal` request by adding a `status` filter

Open ipr0310 opened this issue 2 years ago • 5 comments

Motivation While trying to show a summary of open orders in Signumswap i came up with an "accuracy" problem of fetching journal of trades for a given account. Due to some filtering limitations.

Proposal The request getTradeJournal should have a new query string parameter called status which its purpose is just to filter the trades/orders returned by the API endpoint.

The options for this query parameter will be limited to the following:

  • open
  • filled
  • cancelled

This query parameter should be optional

Example of how it would look like on API Docs: image

ipr0310 avatar Feb 14 '23 16:02 ipr0310

Additionally, it helps to make more efficient queries because you will just get the trades that you really want to see!

Example: I just want to fetch the open trades of a certain account Not all of its trades

ipr0310 avatar Feb 14 '23 16:02 ipr0310

Would that still work with pagination?

frankTheTank72 avatar Mar 03 '23 10:03 frankTheTank72

Pagination is already added, filtering is needed

ipr0310 avatar Mar 03 '23 13:03 ipr0310

Pagination is already added, what is needed is filtering

{
  "account": "8929712165307955075",
  "accountRS": "TS-NFW5-WWDU-Y3BE-9P7VR",
  "tradeJournal": [
    {
      "order": "12137482780163274653",
      "asset": "6589512152275040401",
      "account": "8929712165307955075",
      "accountRS": "TS-NFW5-WWDU-Y3BE-9P7VR",
      "quantityQNT": "100000",
      "priceNQT": "30",
      "height": 480139,
      "name": "myonetoken",
      "decimals": 1,
      "price": "300",
      "timestamp": 260371746,
      "executedQuantityQNT": "0",
      "executedVolumeNQT": "0",
      "type": "bid",
      "status": "cancelled",
      "trades": []
    },
    {
      "order": "2600843465838802073",
      "asset": "15784340403242018732",
      "account": "8929712165307955075",
      "accountRS": "TS-NFW5-WWDU-Y3BE-9P7VR",
      "quantityQNT": "15000000000",
      "priceNQT": "250",
      "height": 475416,
      "name": "TK8",
      "decimals": 8,
      "price": "25000000000",
      "timestamp": 259233220,
      "executedQuantityQNT": "1737429816",
      "executedVolumeNQT": "434357454000",
      "type": "ask",
      "status": "cancelled",
      "trades": [
        {
          "timestamp": 259804495,
          "quantityQNT": "1500000000",
          "priceNQT": "250",
          "asset": "15784340403242018732",
          "askOrder": "2600843465838802073",
          "bidOrder": "135389358966331573",
          "askOrderHeight": 477791,
          "seller": "8929712165307955075",
          "sellerRS": "TS-NFW5-WWDU-Y3BE-9P7VR",
          "buyer": "12892566484214586041",
          "buyerRS": "TS-H8PT-X5HD-V5U4-DSWU7",
          "block": "12446588116028768990",
          "height": 477791,
          "tradeType": "buy",
          "price": "25000000000"
        },
        {
          "timestamp": 259804495,
          "quantityQNT": "237429816",
          "priceNQT": "250",
          "asset": "15784340403242018732",
          "askOrder": "2600843465838802073",
          "bidOrder": "2096241056156122884",
          "askOrderHeight": 477791,
          "seller": "8929712165307955075",
          "sellerRS": "TS-NFW5-WWDU-Y3BE-9P7VR",
          "buyer": "8629824288351884182",
          "buyerRS": "TS-36WQ-GYQN-D856-9DUJH",
          "block": "12446588116028768990",
          "height": 477791,
          "tradeType": "buy",
          "price": "25000000000"
        }
      ]
    },
    {
      "order": "6981912161304512875",
      "asset": "13868324881938171674",
      "account": "8929712165307955075",
      "accountRS": "TS-NFW5-WWDU-Y3BE-9P7VR",
      "quantityQNT": "100000",
      "priceNQT": "5400",
      "height": 474787,
      "name": "TEST",
      "decimals": 4,
      "price": "54000000",
      "timestamp": 259082416,
      "executedQuantityQNT": "0",
      "executedVolumeNQT": "0",
      "type": "bid",
      "status": "cancelled",
      "trades": []
    },
    {
      "order": "6304692069553441032",
      "asset": "13868324881938171674",
      "account": "8929712165307955075",
      "accountRS": "TS-NFW5-WWDU-Y3BE-9P7VR",
      "quantityQNT": "250000",
      "priceNQT": "5500",
      "height": 474787,
      "name": "TEST",
      "decimals": 4,
      "price": "55000000",
      "timestamp": 259082479,
      "executedQuantityQNT": "0",
      "executedVolumeNQT": "0",
      "type": "bid",
      "status": "cancelled",
      "trades": []
    }
  ],
  "nextIndex": 4,
  "requestProcessingTime": 57
}

ipr0310 avatar Mar 03 '23 13:03 ipr0310

The status is a computed value and not inside the database.... so,

  1. filtering on db level is not possible
  2. pagination is partially an issue....in the sense that page sizes are not always 500. ANyways the nextIndex field always helps here

thinking of a solution here...

ohager avatar Apr 17 '24 15:04 ohager