Exemplo n.º 1
0
 def dividends(self, range='1m'):
     """
         Args:
             range - what range of data to retrieve. The variable
                     'DIVIDEND_RANGES' has possible values in addition to a date.
     """
     validate_range_set(range, RANGES)
     return self._get(f"chart/{range}")
Exemplo n.º 2
0
    def dividends(self, range='1m', token=None):
        """
            Args:
                range - what range of data to retrieve. The variable
                        'DIVIDEND_RANGES' has possible values in addition to a date.
        """

        # Setup parameters
        params = {'token': token}
        if token and type(token) != str:
            raise ValueError("token must be str")

        validate_range_set(range, RANGES)

        return self._get(f"dividends/{range}", params=params)
Exemplo n.º 3
0
    def chart(self,
              range='1m',
              chartByDay=None,
              chartSimplify=None,
              chartInterval=None,
              chartCloseOnly=None,
              token=None):
        """
            Args:
                range - what range of data to retrieve. The variable 'CHART_RANGES'
                        has possible values in addition to a date.
        """

        # Setup parameters
        params = {
            'chartByDay': chartByDay,
            'chartSimplify': chartSimplify,
            'chartInterval': chartInterval,
            'chartCloseOnly': chartCloseOnly,
            'token': token
        }
        params = {k: param_bool(v) for k, v in params.items() if v}
        if chartByDay and type(chartByDay) != bool:
            raise ValueError("chartByDay must be bool")
        if chartSimplify and type(chartSimplify) != bool:
            raise ValueError("chartSimplify must be bool")
        if chartInterval and type(chartInterval) != int:
            raise ValueError("chartInterval must be int")
        if chartCloseOnly and type(chartCloseOnly) != bool:
            raise ValueError("chartCloseOnly must be bool")
        if token and type(token) != str:
            raise ValueError("token must be str")

        # Validate range is appropriate
        validate_range_set(range, CHART_RANGES)

        # date match
        date_match = re.match('^[0-9]{8}$', range)

        if date_match:
            range = parse_date(range)
            url = f"chart/date/{range}"
        else:
            url = f"chart/{range}"

        return self._get(url, params=params)
Exemplo n.º 4
0
 def splits(self, range="1m"):
     validate_range_set(range, RANGES)
     return self._get(f"splits/{range}")