* @method * @name cryptocom#fetchPosition * @description fetch data on a single open contract trade position * @see https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-get-positions * @param {string} symbol unified market symbol of the market the position is h
(symbol: string, params = {})
| 3178 | * @returns {object} a [position structure]{@link https://docs.ccxt.com/?id=position-structure} |
| 3179 | */ |
| 3180 | async fetchPosition (symbol: string, params = {}) { |
| 3181 | await this.loadMarkets (); |
| 3182 | const market = this.market (symbol); |
| 3183 | const request: Dict = { |
| 3184 | 'instrument_name': market['id'], |
| 3185 | }; |
| 3186 | const response = await this.v1PrivatePostPrivateGetPositions (this.extend (request, params)); |
| 3187 | // |
| 3188 | // { |
| 3189 | // "id": 1688015952050, |
| 3190 | // "method": "private/get-positions", |
| 3191 | // "code": 0, |
| 3192 | // "result": { |
| 3193 | // "data": [ |
| 3194 | // { |
| 3195 | // "account_id": "ce075bef-b600-4277-bd6e-ff9007251e63", |
| 3196 | // "quantity": "0.0001", |
| 3197 | // "cost": "3.02392", |
| 3198 | // "open_pos_cost": "3.02392", |
| 3199 | // "open_position_pnl": "-0.0010281328", |
| 3200 | // "session_pnl": "-0.0010281328", |
| 3201 | // "update_timestamp_ms": 1688015919091, |
| 3202 | // "instrument_name": "BTCUSD-PERP", |
| 3203 | // "type": "PERPETUAL_SWAP" |
| 3204 | // } |
| 3205 | // ] |
| 3206 | // } |
| 3207 | // } |
| 3208 | // |
| 3209 | const result = this.safeDict (response, 'result', {}); |
| 3210 | const data = this.safeList (result, 'data', []); |
| 3211 | return this.parsePosition (this.safeDict (data, 0) as Dict, market); |
| 3212 | } |
| 3213 | |
| 3214 | /** |
| 3215 | * @method |
nothing calls this directly
no test coverage detected