Ejemplo n.º 1
0
    def historical_quote_by_symbols(cls,
                                    client,
                                    symbols,
                                    span="year",
                                    bounds="regular"):
        possible_intervals = {
            "day": "5minute",
            "week": "10minute",
            "year": "day",
            "5year": "week"
        }
        assert span in possible_intervals.keys()
        interval = possible_intervals[span]
        assert bounds in ["regular"]

        request_url = "https://api.robinhood.com/marketdata/historicals/"

        results = []
        for _symbols in chunked_list(symbols, 25):
            params = {
                "span": span,
                "interval": interval,
                "bounds": bounds,
                "symbols": ",".join(_symbols)
            }
            data = client.get(request_url, params=params)
            if data and data["results"]:
                results.extend(data["results"])
        return results
Ejemplo n.º 2
0
 def quotes_by_instrument_urls(cls, client, urls):
     results = []
     for _urls in chunked_list(urls, 50):
         url = "https://api.robinhood.com/marketdata/options/"
         params = {"instruments": ",".join(_urls)}
         data = client.get(url, params=params)
         if data and "results" in data:
             partial_results = data["results"]
             while ("next" in data and data["next"]):
                 data = get(data["next"], bearer=bearer)
                 partial_results.extend(data["results"])
             results.extend(partial_results)
     return results
Ejemplo n.º 3
0
 def historical_quotes_by_urls(cls, client, urls, span="year"):
     possible_intervals = {
         "day": "5minute",
         "week": "10minute",
         "year": "day",
         "5year": "week"}
     assert span in possible_intervals.keys()
     interval = possible_intervals[span]
     results = []
     request_url = \
         "https://api.robinhood.com/marketdata/options/historicals/"
     for _urls in chunked_list(urls, 5):
         params = {"span": span, "interval": interval,
                   "instruments": ",".join(_urls)}
         data = client.get(request_url, params=params)
         if data and data["results"]:
             results.extend(data["results"])
     return results
Ejemplo n.º 4
0
    def fetch_list(cls, client, ids):
        """
        fetch instruments by ids
        """
        results = []
        request_url = "https://api.robinhood.com/options/instruments/"

        for _ids in chunked_list(ids, 50):

            params = {"ids": ",".join(_ids)}
            data = client.get(request_url, params=params)
            partial_results = data["results"]

            while data["next"]:
                data = client.get(data["next"])
                partial_results.extend(data["results"])
            results.extend(partial_results)

        return results