예제 #1
0
 def aggregate(self, start, end, sources, sample_unit, debug=False):
     headers = {'accept': 'application/json'}
     url = "".join([
         self.endpoint, "/prices/aggregate?start=", start, "&end=", end,
         "&sources=", "&sources=".join(sources), "&unit=", sample_unit
     ])
     return http.get(url=url, headers=headers, debug=debug)
예제 #2
0
 def get_model(self, modelId, debug=False):
     headers = {
         'X-IBM-Client-Id': self.credentials["clientId"],
         'X-IBM-Client-Secret': self.credentials["clientSecret"],
         'accept': 'application/json'
     }
     url = "".join([
         self.credentials["endpoint"], "/miol-prod/api/v1/models/", modelId
     ])
     return http.get(url=url, headers=headers, debug=debug)
예제 #3
0
    def get_dataset_by_id(self, dataset_id, debug=False):
        headers = {
            'X-IBM-Client-Id': self.credentials["clientId"],
            'X-IBM-Client-Secret': self.credentials["clientSecret"],
            'accept': 'application/json'
        }

        # TODO eliminate id, no need.
        query = {
            'where': {
                'id': dataset_id,
            }
        }
        url = "".join([
            self.credentials["endpoint"], "/miol-prod/api/v1/datasets?filter=",
            json.dumps(query)
        ])
        resp = http.get(url=url, headers=headers, debug=debug)
        dataset = resp[0]
        return [Dataset.jsontocsv(dataset), dataset["dataset_desc"]]
예제 #4
0
    def get_predictions(self,
                        market,
                        modelId,
                        start=None,
                        end=None,
                        debug=False):
        headers = {
            'X-IBM-Client-Id': self.credentials["clientId"],
            'X-IBM-Client-Secret': self.credentials["clientSecret"],
            'accept': 'application/json'
        }

        query = Predictions.getQuery(market, modelId, start, end)

        url = "".join([
            self.credentials["endpoint"],
            "/miol-prod/api/v1/predictions?filter=",
            json.dumps(query)
        ])
        resp = http.get(url=url, headers=headers, debug=debug)
        return Predictions.jsontocsv(resp)
예제 #5
0
 def get(self, source_id, debug=False):
     headers = {'accept': 'application/json'}
     url = "".join([self.endpoint, "/prices/datasource/", source_id])
     return http.get(url=url, headers=headers, debug=debug)