(self, method, endpointMethod, returnAsJson, startRegex=None, endRegex=None)
| 945 | raise NotSupported(self.id + ' watchOHLCV() is not supported yet') |
| 946 | |
| 947 | async def fetch_web_endpoint(self, method, endpointMethod, returnAsJson, startRegex=None, endRegex=None): |
| 948 | errorMessage = '' |
| 949 | options = self.safe_value(self.options, method, {}) |
| 950 | muteOnFailure = self.safe_bool(options, 'webApiMuteFailure', True) |
| 951 | try: |
| 952 | # if it was not explicitly disabled, then don't fetch |
| 953 | if self.safe_bool(options, 'webApiEnable', True) is not True: |
| 954 | return None |
| 955 | maxRetries = self.safe_value(options, 'webApiRetries', 10) |
| 956 | response = None |
| 957 | retry = 0 |
| 958 | shouldBreak = False |
| 959 | while(retry < maxRetries): |
| 960 | try: |
| 961 | response = await getattr(self, endpointMethod)({}) |
| 962 | shouldBreak = True |
| 963 | break |
| 964 | except Exception as e: |
| 965 | retry = retry + 1 |
| 966 | if retry == maxRetries: |
| 967 | raise e |
| 968 | if shouldBreak: |
| 969 | break # self is needed because of GO |
| 970 | content = response |
| 971 | if startRegex is not None: |
| 972 | splitted_by_start = content.split(startRegex) |
| 973 | content = splitted_by_start[1] # we need second part after start |
| 974 | if endRegex is not None: |
| 975 | splitted_by_end = content.split(endRegex) |
| 976 | content = splitted_by_end[0] # we need first part after start |
| 977 | if returnAsJson and (isinstance(content, str)): |
| 978 | jsoned = self.parse_json(content.strip()) # content should be trimmed before json parsing |
| 979 | if jsoned: |
| 980 | return jsoned # if parsing was not successfull, exception should be thrown |
| 981 | else: |
| 982 | raise BadResponse('could not parse the response into json') |
| 983 | else: |
| 984 | return content |
| 985 | except Exception as e: |
| 986 | errorMessage = self.id + ' ' + method + '() failed to fetch correct data from website. Probably webpage markup has been changed, breaking the page custom parser.' |
| 987 | if muteOnFailure: |
| 988 | return None |
| 989 | else: |
| 990 | raise BadResponse(errorMessage) |
| 991 | |
| 992 | async def fetch_l2_order_book(self, symbol: str, limit: Int = None, params={}): |
| 993 | orderbook = await self.fetch_order_book(symbol, limit, params) |
no test coverage detected