MCPcopy Create free account
hub / github.com/ccxt/ccxt / fetchPosition

Method fetchPosition

ts/src/bitget.ts:7845–7938  ·  view source on GitHub ↗

* @method * @name bitget#fetchPosition * @description fetch data on a single open contract trade position * @see https://www.bitget.com/api-doc/contract/position/get-single-position * @see https://www.bitget.com/api-doc/uta/trade/Get-Position * @param {string} symbol unified

(symbol: string, params = {})

Source from the content-addressed store, hash-verified

7843 * @returns {object} a [position structure]{@link https://docs.ccxt.com/?id=position-structure}
7844 */
7845 async fetchPosition (symbol: string, params = {}) {
7846 await this.loadMarkets ();
7847 const market = this.market (symbol);
7848 let productType: Str = undefined;
7849 [ productType, params ] = this.handleProductTypeAndParams (market, params);
7850 const request: Dict = {
7851 'symbol': market['id'],
7852 };
7853 let response = undefined;
7854 let uta = undefined;
7855 let result: NullableList = undefined;
7856 [ uta, params ] = this.handleOptionAndParams (params, 'fetchPosition', 'uta', false);
7857 if (uta) {
7858 request['category'] = productType;
7859 response = await this.privateUtaGetV3PositionCurrentPosition (this.extend (request, params));
7860 //
7861 // {
7862 // "code": "00000",
7863 // "msg": "success",
7864 // "requestTime": 1750929905423,
7865 // "data": {
7866 // "list": [
7867 // {
7868 // "category": "USDT-FUTURES",
7869 // "symbol": "BTCUSDT",
7870 // "marginCoin": "USDT",
7871 // "holdMode": "hedge_mode",
7872 // "posSide": "long",
7873 // "marginMode": "crossed",
7874 // "positionBalance": "5.435199",
7875 // "available": "0.001",
7876 // "frozen": "0",
7877 // "total": "0.001",
7878 // "leverage": "20",
7879 // "curRealisedPnl": "0",
7880 // "avgPrice": "107410.3",
7881 // "positionStatus": "normal",
7882 // "unrealisedPnl": "0.0047",
7883 // "liquidationPrice": "0",
7884 // "mmr": "0.004",
7885 // "profitRate": "0.0008647337475591",
7886 // "markPrice": "107415.3",
7887 // "breakEvenPrice": "107539.2",
7888 // "totalFunding": "0",
7889 // "openFeeTotal": "-0.06444618",
7890 // "closeFeeTotal": "0",
7891 // "createdTime": "1750495670699",
7892 // "updatedTime": "1750929883465"
7893 // }
7894 // ]
7895 // }
7896 // }
7897 //
7898 const data = this.safeDict (response, 'data', {});
7899 result = this.safeList (data, 'list', []);
7900 } else {
7901 request['marginCoin'] = market['settleId'];
7902 request['productType'] = productType;

Callers

nothing calls this directly

Calls 10

parsePositionMethod · 0.95
loadMarketsMethod · 0.45
marketMethod · 0.45
handleOptionAndParamsMethod · 0.45
extendMethod · 0.45
safeDictMethod · 0.45
safeListMethod · 0.45

Tested by

no test coverage detected