fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market https://www.gate.com/docs/developers/apiv4/en/#market-k-line-chart # spot https://www.gate.com/docs/developers/apiv4/en/#futures-market-k-li
(self, symbol: str, timeframe: str = '1m', since: Int = None, limit: Int = None, params={})
| 3224 | return returnResult |
| 3225 | |
| 3226 | def fetch_ohlcv(self, symbol: str, timeframe: str = '1m', since: Int = None, limit: Int = None, params={}) -> List[list]: |
| 3227 | """ |
| 3228 | fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market |
| 3229 | |
| 3230 | https://www.gate.com/docs/developers/apiv4/en/#market-k-line-chart # spot |
| 3231 | https://www.gate.com/docs/developers/apiv4/en/#futures-market-k-line-chart # swap |
| 3232 | https://www.gate.com/docs/developers/apiv4/en/#futures-market-k-line-chart-2 # future |
| 3233 | https://www.gate.com/docs/developers/apiv4/en/#options-contract-market-candlestick-chart # option |
| 3234 | |
| 3235 | :param str symbol: unified symbol of the market to fetch OHLCV data for |
| 3236 | :param str timeframe: the length of time each candle represents |
| 3237 | :param int [since]: timestamp in ms of the earliest candle to fetch |
| 3238 | :param int [limit]: the maximum amount of candles to fetch, limit is conflicted with since and params["until"], If either since and params["until"] is specified, request will be rejected |
| 3239 | :param dict [params]: extra parameters specific to the exchange API endpoint |
| 3240 | :param str [params.price]: "mark" or "index" for mark price and index price candles |
| 3241 | :param int [params.until]: timestamp in ms of the latest candle to fetch |
| 3242 | :param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params) |
| 3243 | :returns int[][]: A list of candles ordered, open, high, low, close, volume(units in quote currency) |
| 3244 | """ |
| 3245 | self.load_markets() |
| 3246 | market = self.market(symbol) |
| 3247 | paginate = False |
| 3248 | paginate, params = self.handle_option_and_params(params, 'fetchOHLCV', 'paginate') |
| 3249 | if paginate: |
| 3250 | return self.fetch_paginated_call_deterministic('fetchOHLCV', symbol, since, limit, timeframe, params, 1000) |
| 3251 | if market['option']: |
| 3252 | return self.fetch_option_ohlcv(symbol, timeframe, since, limit, params) |
| 3253 | price = self.safe_string(params, 'price') |
| 3254 | request = {} |
| 3255 | request, params = self.prepare_request(market, None, params) |
| 3256 | request['interval'] = self.safe_string(self.timeframes, timeframe, timeframe) |
| 3257 | maxLimit = 1999 if market['contract'] else 1000 |
| 3258 | limit = maxLimit if (limit is None) else min(limit, maxLimit) |
| 3259 | until = self.safe_integer(params, 'until') |
| 3260 | if until is not None: |
| 3261 | until = self.parse_to_int(until / 1000) |
| 3262 | params = self.omit(params, 'until') |
| 3263 | if since is not None: |
| 3264 | duration = self.parse_timeframe(timeframe) |
| 3265 | request['from'] = self.parse_to_int(since / 1000) |
| 3266 | distance = (limit - 1) * duration |
| 3267 | toTimestamp = self.sum(request['from'], distance) |
| 3268 | currentTimestamp = self.seconds() |
| 3269 | to = min(toTimestamp, currentTimestamp) |
| 3270 | if until is not None: |
| 3271 | request['to'] = min(to, until) |
| 3272 | else: |
| 3273 | request['to'] = to |
| 3274 | else: |
| 3275 | if until is not None: |
| 3276 | request['to'] = until |
| 3277 | request['limit'] = limit |
| 3278 | response = None |
| 3279 | if market['contract']: |
| 3280 | isMark = (price == 'mark') |
| 3281 | isIndex = (price == 'index') |
| 3282 | if isMark or isIndex: |
| 3283 | request['contract'] = price + '_' + market['id'] |
nothing calls this directly
no test coverage detected