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

Method fetch_position

python/ccxt/bybit.py:6202–6271  ·  view source on GitHub ↗

fetch data on a single open contract trade position https://bybit-exchange.github.io/docs/v5/position :param str symbol: unified market symbol of the market the position is held in, default is None :param dict [params]: extra parameters specific to the exchange API

(self, symbol: str, params={})

Source from the content-addressed store, hash-verified

6200 return self.parse_transaction(result, currency)
6201
6202 def fetch_position(self, symbol: str, params={}) -> Position:
6203 """
6204 fetch data on a single open contract trade position
6205
6206 https://bybit-exchange.github.io/docs/v5/position
6207
6208 :param str symbol: unified market symbol of the market the position is held in, default is None
6209 :param dict [params]: extra parameters specific to the exchange API endpoint
6210 :returns dict: a `position structure <https://docs.ccxt.com/?id=position-structure>`
6211 """
6212 if symbol is None:
6213 raise ArgumentsRequired(self.id + ' fetchPosition() requires a symbol argument')
6214 self.load_markets()
6215 market = self.market(symbol)
6216 request = {
6217 'symbol': market['id'],
6218 }
6219 response = None
6220 type = None
6221 type, params = self.get_bybit_type('fetchPosition', market, params)
6222 request['category'] = type
6223 response = self.privateGetV5PositionList(self.extend(request, params))
6224 #
6225 # {
6226 # "retCode": 0,
6227 # "retMsg": "OK",
6228 # "result": {
6229 # "nextPageCursor": "updateAt%3D1672279322668",
6230 # "category": "linear",
6231 # "list": [
6232 # {
6233 # "symbol": "XRPUSDT",
6234 # "leverage": "10",
6235 # "avgPrice": "0.3615",
6236 # "liqPrice": "0.0001",
6237 # "riskLimitValue": "200000",
6238 # "takeProfit": "",
6239 # "positionValue": "36.15",
6240 # "tpslMode": "Full",
6241 # "riskId": 41,
6242 # "trailingStop": "0",
6243 # "unrealisedPnl": "-1.83",
6244 # "markPrice": "0.3432",
6245 # "cumRealisedPnl": "0.48805876",
6246 # "positionMM": "0.381021",
6247 # "createdTime": "1672121182216",
6248 # "positionIdx": 0,
6249 # "positionIM": "3.634521",
6250 # "updatedTime": "1672279322668",
6251 # "side": "Buy",
6252 # "bustPrice": "",
6253 # "size": "100",
6254 # "positionStatus": "Normal",
6255 # "stopLoss": "",
6256 # "tradeMode": 0
6257 # }
6258 # ]
6259 # },

Callers 1

fetch_leverageMethod · 0.95

Calls 11

get_bybit_typeMethod · 0.95
parse_positionMethod · 0.95
ArgumentsRequiredClass · 0.90
safe_dictMethod · 0.80
safe_list_2Method · 0.80
safe_integerMethod · 0.80
load_marketsMethod · 0.45
marketMethod · 0.45
extendMethod · 0.45
iso8601Method · 0.45

Tested by

no test coverage detected