Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly support KrakenFutures positions API #22551

Closed
1 task done
PirateBread opened this issue May 19, 2024 · 1 comment
Closed
1 task done

Correctly support KrakenFutures positions API #22551

PirateBread opened this issue May 19, 2024 · 1 comment
Assignees

Comments

@PirateBread
Copy link

PirateBread commented May 19, 2024

Preliminary Checks

  • I have already searched for existing issues and confirmed that this issue is not a duplicate

Is your feature request related to a problem? Please describe

fetchPositions() does not properly return several fields which are present in the kraken futures websocket api response.

Example response from the websocket api:

        {
            "liquidation_threshold": 0.0,
            "effective_leverage": 0.24720734763323846,
            "unrealized_funding": -0.0003598551103092746,
            "initial_margin": 17.850790636043754,
            "initial_margin_with_orders": 17.850790636043754,
            "maintenance_margin": 8.925395318021877,
            "pnl_currency": "USD",
            "instrument": "PF_XBTUSD",
            "balance": 0.0134,
            "pnl": 3.712943321448949,
            "entry_price": 66607.42774643192,
            "mark_price": 66884.5130689281,
            "index_price": 66885.77,
            "return_on_equity": 0.20799881625141525,
            "fill_time": 1715882724277
        },

Response from fetchPositions()

[{'collateral': None,
  'contractSize': 1.0,
  'contracts': 0.0134,
  'datetime': '2024-05-19T12:36:47.540Z',
  'entryPrice': 66607.42774643192,
  'info': {'fillTime': '2024-05-19T12:36:47.540Z',
           'pnlCurrency': 'USD',
           'price': '66607.42774643192',
           'side': 'long',
           'size': '0.0134',
           'symbol': 'PF_XBTUSD',
           'unrealizedFunding': '-0.0026346805289640075'},
  'initialMargin': None,
  'initialMarginPercentage': None,
  'leverage': None,
  'liquidationPrice': None,
  'maintenanceMargin': None,
  'maintenanceMarginPercentage': None,
  'marginRatio': None,
  'marginType': 'cross',
  'markPrice': None,
  'notional': None,
  'percentage': None,
  'side': 'long',
  'symbol': 'BTC/USD:USD',
  'timestamp': 1716122207540,
  'unrealizedPnl': None},

As you can see, a number of the fields are hardcoded to

unrealizedPnl : pnl
markPrice : mark_price
initialMargin : initial_margin
maintenanceMargin : maintenance_margin

Describe the solution you'd like

The fields returned from the positions API should be properly matched to fields in fetchPositions.

I'm an amateur developer, but just eyeballing the code base, I wonder if the solution is relatively simple to update the undefined parameters and link them to the kraken futures api fields?

e.g.

unrealizedPnl': this.safeNumber (market, 'pnl'),
'markPrice': this.safeNumber (market, 'mark_price'),

If someone can take a look at this, I would be happy to submit a change request. I'm not sure how I could build and test this locally, but again would be happy to if someone can give me some rough idea so I can research more.

Describe alternatives you've considered

No response

@pcriadoperez
Copy link
Contributor

Hi @PirateBread ,

The reason for this is that the exchange, in this case krakenfutures, returns different information through the websocket than their rest API. You can see the raw information received by the excange in the info property of the response.
I checked and unfortunately in the rest API, the exchange does not return any mark price or pnl information.

I'll close this issue for now but feel free to reach out with any other questions or isses

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants