fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market https://www.bitget.com/api-doc/spot/market/Get-Candle-Data https://www.bitget.com/api-doc/spot/market/Get-History-Candle-Data https://www.bitget.com/api-d
(self, symbol: str, timeframe: str = '1m', since: Int = None, limit: Int = None, params={})
| 4124 | ] |
| 4125 | |
| 4126 | def fetch_ohlcv(self, symbol: str, timeframe: str = '1m', since: Int = None, limit: Int = None, params={}) -> List[list]: |
| 4127 | """ |
| 4128 | fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market |
| 4129 | |
| 4130 | https://www.bitget.com/api-doc/spot/market/Get-Candle-Data |
| 4131 | https://www.bitget.com/api-doc/spot/market/Get-History-Candle-Data |
| 4132 | https://www.bitget.com/api-doc/contract/market/Get-Candle-Data |
| 4133 | https://www.bitget.com/api-doc/contract/market/Get-History-Candle-Data |
| 4134 | https://www.bitget.com/api-doc/contract/market/Get-History-Index-Candle-Data |
| 4135 | https://www.bitget.com/api-doc/contract/market/Get-History-Mark-Candle-Data |
| 4136 | https://www.bitget.com/api-doc/uta/public/Get-Candle-Data |
| 4137 | |
| 4138 | :param str symbol: unified symbol of the market to fetch OHLCV data for |
| 4139 | :param str timeframe: the length of time each candle represents |
| 4140 | :param int [since]: timestamp in ms of the earliest candle to fetch |
| 4141 | :param int [limit]: the maximum amount of candles to fetch |
| 4142 | :param dict [params]: extra parameters specific to the exchange API endpoint |
| 4143 | :param boolean [params.uta]: set to True for the unified trading account(uta), defaults to False |
| 4144 | :param int [params.until]: timestamp in ms of the latest candle to fetch |
| 4145 | :param boolean [params.useHistoryEndpoint]: whether to force to use historical endpoint(it has max limit of 200) |
| 4146 | :param boolean [params.useHistoryEndpointForPagination]: whether to force to use historical endpoint for pagination(default True) |
| 4147 | :param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params) |
| 4148 | :param str [params.price]: *swap only* "mark"(to fetch mark price candles) or "index"(to fetch index price candles) |
| 4149 | :returns int[][]: A list of candles ordered, open, high, low, close, volume |
| 4150 | """ |
| 4151 | self.load_markets() |
| 4152 | defaultLimit = 100 # default 100, max 1000 |
| 4153 | maxLimitForRecentEndpoint = 1000 |
| 4154 | maxLimitForHistoryEndpoint = 200 # note, max 1000 bars are supported for "recent-candles" endpoint, but "historical-candles" support only max 200 |
| 4155 | useHistoryEndpoint = self.safe_bool(params, 'useHistoryEndpoint', False) |
| 4156 | useHistoryEndpointForPagination = self.safe_bool(params, 'useHistoryEndpointForPagination', True) |
| 4157 | paginate = False |
| 4158 | paginate, params = self.handle_option_and_params(params, 'fetchOHLCV', 'paginate') |
| 4159 | if paginate: |
| 4160 | limitForPagination = maxLimitForHistoryEndpoint if useHistoryEndpointForPagination else maxLimitForRecentEndpoint |
| 4161 | return self.fetch_paginated_call_deterministic('fetchOHLCV', symbol, since, limit, timeframe, params, limitForPagination) |
| 4162 | market = self.market(symbol) |
| 4163 | request = { |
| 4164 | 'symbol': market['id'], |
| 4165 | } |
| 4166 | marketType = None |
| 4167 | timeframes = None |
| 4168 | uta = None |
| 4169 | uta, params = self.handle_option_and_params(params, 'fetchOHLCV', 'uta', False) |
| 4170 | if uta: |
| 4171 | timeframes = self.options['timeframes']['uta'] |
| 4172 | request['interval'] = self.safe_string(timeframes, timeframe, timeframe) |
| 4173 | else: |
| 4174 | marketType = 'spot' if market['spot'] else 'swap' |
| 4175 | timeframes = self.options['timeframes'][marketType] |
| 4176 | request['granularity'] = self.safe_string(timeframes, timeframe, timeframe) |
| 4177 | msInDay = 86400000 |
| 4178 | now = self.milliseconds() |
| 4179 | duration = self.parse_timeframe(timeframe) * 1000 |
| 4180 | until = self.safe_integer(params, 'until') |
| 4181 | limitDefined = limit is not None |
| 4182 | sinceDefined = since is not None |
| 4183 | untilDefined = until is not None |
nothing calls this directly
no test coverage detected