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

Method fetch_position

python/ccxt/gate.py:5877–5959  ·  view source on GitHub ↗

fetch data on an open contract position https://www.gate.com/docs/developers/apiv4/en/#get-single-position-information https://www.gate.com/docs/developers/apiv4/en/#get-single-position-information-2 https://www.gate.com/docs/developers/apiv4/en/#get-specified-contr

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

Source from the content-addressed store, hash-verified

5875 })
5876
5877 def fetch_position(self, symbol: str, params={}):
5878 """
5879 fetch data on an open contract position
5880
5881 https://www.gate.com/docs/developers/apiv4/en/#get-single-position-information
5882 https://www.gate.com/docs/developers/apiv4/en/#get-single-position-information-2
5883 https://www.gate.com/docs/developers/apiv4/en/#get-specified-contract-position
5884
5885 :param str symbol: unified market symbol of the market the position is held in
5886 :param dict [params]: extra parameters specific to the exchange API endpoint
5887 :returns dict: a `position structure <https://docs.ccxt.com/?id=position-structure>`
5888 """
5889 self.load_markets()
5890 market = self.market(symbol)
5891 if not market['contract']:
5892 raise BadRequest(self.id + ' fetchPosition() supports contract markets only')
5893 request = {}
5894 request, params = self.prepare_request(market, market['type'], params)
5895 extendedRequest = self.extend(request, params)
5896 response = None
5897 if market['swap']:
5898 response = self.privateFuturesGetSettlePositionsContract(extendedRequest)
5899 elif market['future']:
5900 response = self.privateDeliveryGetSettlePositionsContract(extendedRequest)
5901 elif market['type'] == 'option':
5902 response = self.privateOptionsGetPositionsContract(extendedRequest)
5903 #
5904 # swap and future
5905 #
5906 # {
5907 # "value": "4.60516",
5908 # "leverage": "0",
5909 # "mode": "single",
5910 # "realised_point": "0",
5911 # "contract": "BTC_USDT",
5912 # "entry_price": "46030.3",
5913 # "mark_price": "46051.6",
5914 # "history_point": "0",
5915 # "realised_pnl": "-0.002301515",
5916 # "close_order": null,
5917 # "size": 1,
5918 # "cross_leverage_limit": "0",
5919 # "pending_orders": 0,
5920 # "adl_ranking": 5,
5921 # "maintenance_rate": "0.004",
5922 # "unrealised_pnl": "0.00213",
5923 # "user": 5691076,
5924 # "leverage_max": "125",
5925 # "history_pnl": "0",
5926 # "risk_limit": "1000000",
5927 # "margin": "8.997698485",
5928 # "last_close_pnl": "0",
5929 # "liq_price": "0",
5930 # "update_time": 1705034246,
5931 # "update_id": 1,
5932 # "initial_margin": "0",
5933 # "maintenance_margin": "0",
5934 # "open_time": 1705034246,

Callers

nothing calls this directly

Calls 9

prepare_requestMethod · 0.95
parse_positionMethod · 0.95
BadRequestClass · 0.90
load_marketsMethod · 0.45
marketMethod · 0.45
extendMethod · 0.45

Tested by

no test coverage detected