Skip to content

Commit

Permalink
Merge branch 'feature/implement-get-metrics-statistics-api' into 'mas…
Browse files Browse the repository at this point in the history
…ter'

Implement GetMetricsStatistics API

See merge request babakloni/investor8.core!467
  • Loading branch information
mehrdadrafiei committed Jul 31, 2023
1 parent 98a3e36 commit 9ef2e74
Show file tree
Hide file tree
Showing 11 changed files with 318 additions and 4 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Investoreight API Documentation: https://api.investoreight.com/api-docs/index.h
This Python package is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project:

- API version: 1.0.1
- Package version: 1.1.104
- Package version: 1.1.105
- Build package: io.swagger.codegen.v3.generators.python.PythonClientCodegen
For more information, please visit [https://www.investoreight.com](https://www.investoreight.com)

Expand Down Expand Up @@ -230,6 +230,7 @@ Class | Method | HTTP request | Description
*MetricsApi* | [**get_metric_view_by_name**](docs/MetricsApi.md#get_metric_view_by_name) | **GET** /Metrics/view/name/{name} |
*MetricsApi* | [**get_metrics_by_period**](docs/MetricsApi.md#get_metrics_by_period) | **GET** /Metrics/byperiod |
*MetricsApi* | [**get_metrics_metadata**](docs/MetricsApi.md#get_metrics_metadata) | **GET** /Metrics/metadata/{name} |
*MetricsApi* | [**get_metrics_statistics**](docs/MetricsApi.md#get_metrics_statistics) | **GET** /Metrics/statistics |
*MetricsApi* | [**get_monthly_returns**](docs/MetricsApi.md#get_monthly_returns) | **GET** /Metrics/returns/monthly/{ticker}/{sinceYear} |
*MetricsApi* | [**get_raw_historical_returns**](docs/MetricsApi.md#get_raw_historical_returns) | **GET** /Metrics/earning/raw/historical/{ticker} |
*MetricsApi* | [**get_sector_returns**](docs/MetricsApi.md#get_sector_returns) | **GET** /Metrics/sector/returns |
Expand Down Expand Up @@ -364,6 +365,7 @@ Class | Method | HTTP request | Description
- [Metrics](docs/Metrics.md)
- [MetricsByPeriodDto](docs/MetricsByPeriodDto.md)
- [MetricsMetadataResponseDto](docs/MetricsMetadataResponseDto.md)
- [MetricsStatisticsDto](docs/MetricsStatisticsDto.md)
- [MomentumMetricDto](docs/MomentumMetricDto.md)
- [MonthlyMetrics](docs/MonthlyMetrics.md)
- [MonthlyReturns](docs/MonthlyReturns.md)
Expand Down
59 changes: 59 additions & 0 deletions docs/MetricsApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Method | HTTP request | Description
[**get_metric_view_by_name**](MetricsApi.md#get_metric_view_by_name) | **GET** /Metrics/view/name/{name} |
[**get_metrics_by_period**](MetricsApi.md#get_metrics_by_period) | **GET** /Metrics/byperiod |
[**get_metrics_metadata**](MetricsApi.md#get_metrics_metadata) | **GET** /Metrics/metadata/{name} |
[**get_metrics_statistics**](MetricsApi.md#get_metrics_statistics) | **GET** /Metrics/statistics |
[**get_monthly_returns**](MetricsApi.md#get_monthly_returns) | **GET** /Metrics/returns/monthly/{ticker}/{sinceYear} |
[**get_raw_historical_returns**](MetricsApi.md#get_raw_historical_returns) | **GET** /Metrics/earning/raw/historical/{ticker} |
[**get_sector_returns**](MetricsApi.md#get_sector_returns) | **GET** /Metrics/sector/returns |
Expand Down Expand Up @@ -1487,6 +1488,64 @@ Name | Type | Description | Notes

[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

# **get_metrics_statistics**
> MetricsStatisticsDto get_metrics_statistics(metrics=metrics, in_millions=in_millions)


### Example
```python
from __future__ import print_function
import time
import investor8_sdk
from investor8_sdk.rest import ApiException
from pprint import pprint

# Configure API key authorization: apiKey
configuration = investor8_sdk.Configuration()
configuration.api_key['apiKey'] = 'YOUR_API_KEY'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['apiKey'] = 'Bearer'
# Configure API key authorization: bearerCoreAuth
configuration = investor8_sdk.Configuration()
configuration.api_key['Authorization'] = 'YOUR_API_KEY'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['Authorization'] = 'Bearer'

# create an instance of the API class
api_instance = investor8_sdk.MetricsApi(investor8_sdk.ApiClient(configuration))
metrics = 'metrics_example' # str | (optional)
in_millions = false # bool | (optional) (default to false)

try:
api_response = api_instance.get_metrics_statistics(metrics=metrics, in_millions=in_millions)
pprint(api_response)
except ApiException as e:
print("Exception when calling MetricsApi->get_metrics_statistics: %s\n" % e)
```

### Parameters

Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**metrics** | **str**| | [optional]
**in_millions** | **bool**| | [optional] [default to false]

### Return type

[**MetricsStatisticsDto**](MetricsStatisticsDto.md)

### Authorization

[apiKey](../README.md#apiKey), [bearerCoreAuth](../README.md#bearerCoreAuth)

### HTTP request headers

- **Content-Type**: Not defined
- **Accept**: application/json

[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

# **get_monthly_returns**
> list[MonthlyMetrics] get_monthly_returns(ticker, since_year)
Expand Down
9 changes: 9 additions & 0 deletions docs/MetricsStatisticsDto.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# MetricsStatisticsDto

## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**metrics** | **dict(str, dict(str, dict(str, float)))** | | [optional]

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

1 change: 1 addition & 0 deletions investor8_sdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
from investor8_sdk.models.metrics import Metrics
from investor8_sdk.models.metrics_by_period_dto import MetricsByPeriodDto
from investor8_sdk.models.metrics_metadata_response_dto import MetricsMetadataResponseDto
from investor8_sdk.models.metrics_statistics_dto import MetricsStatisticsDto
from investor8_sdk.models.momentum_metric_dto import MomentumMetricDto
from investor8_sdk.models.monthly_metrics import MonthlyMetrics
from investor8_sdk.models.monthly_returns import MonthlyReturns
Expand Down
93 changes: 93 additions & 0 deletions investor8_sdk/api/metrics_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2429,6 +2429,99 @@ def get_metrics_metadata_with_http_info(self, name, **kwargs): # noqa: E501
_request_timeout=params.get('_request_timeout'),
collection_formats=collection_formats)

def get_metrics_statistics(self, **kwargs): # noqa: E501
"""get_metrics_statistics # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.get_metrics_statistics(async_req=True)
>>> result = thread.get()
:param async_req bool
:param str metrics:
:param bool in_millions:
:return: MetricsStatisticsDto
If the method is called asynchronously,
returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if kwargs.get('async_req'):
return self.get_metrics_statistics_with_http_info(**kwargs) # noqa: E501
else:
(data) = self.get_metrics_statistics_with_http_info(**kwargs) # noqa: E501
return data

def get_metrics_statistics_with_http_info(self, **kwargs): # noqa: E501
"""get_metrics_statistics # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.get_metrics_statistics_with_http_info(async_req=True)
>>> result = thread.get()
:param async_req bool
:param str metrics:
:param bool in_millions:
:return: MetricsStatisticsDto
If the method is called asynchronously,
returns the request thread.
"""

all_params = ['metrics', 'in_millions'] # noqa: E501
all_params.append('async_req')
all_params.append('_return_http_data_only')
all_params.append('_preload_content')
all_params.append('_request_timeout')

params = locals()
for key, val in six.iteritems(params['kwargs']):
if key not in all_params:
raise TypeError(
"Got an unexpected keyword argument '%s'"
" to method get_metrics_statistics" % key
)
params[key] = val
del params['kwargs']

collection_formats = {}

path_params = {}

query_params = []
if 'metrics' in params:
query_params.append(('metrics', params['metrics'])) # noqa: E501
if 'in_millions' in params:
query_params.append(('inMillions', params['in_millions'])) # noqa: E501

header_params = {}

form_params = []
local_var_files = {}

body_params = None
# HTTP header `Accept`
header_params['Accept'] = self.api_client.select_header_accept(
['application/json']) # noqa: E501

# Authentication setting
auth_settings = ['apiKey', 'bearerCoreAuth'] # noqa: E501

return self.api_client.call_api(
'/Metrics/statistics', 'GET',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=local_var_files,
response_type='MetricsStatisticsDto', # noqa: E501
auth_settings=auth_settings,
async_req=params.get('async_req'),
_return_http_data_only=params.get('_return_http_data_only'),
_preload_content=params.get('_preload_content', True),
_request_timeout=params.get('_request_timeout'),
collection_formats=collection_formats)

def get_monthly_returns(self, ticker, since_year, **kwargs): # noqa: E501
"""get_monthly_returns # noqa: E501
Expand Down
2 changes: 1 addition & 1 deletion investor8_sdk/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def __init__(self, configuration=None, header_name=None, header_value=None,
self.default_headers[header_name] = header_value
self.cookie = cookie
# Set default User-Agent.
self.user_agent = 'Swagger-Codegen/1.1.104/python'
self.user_agent = 'Swagger-Codegen/1.1.105/python'

def __del__(self):
self.pool.close()
Expand Down
2 changes: 1 addition & 1 deletion investor8_sdk/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,5 +254,5 @@ def to_debug_report(self):
"OS: {env}\n"\
"Python Version: {pyversion}\n"\
"Version of the API: 1.0.1\n"\
"SDK Package Version: 1.1.104".\
"SDK Package Version: 1.1.105".\
format(env=sys.platform, pyversion=sys.version)
1 change: 1 addition & 0 deletions investor8_sdk/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
from investor8_sdk.models.metrics import Metrics
from investor8_sdk.models.metrics_by_period_dto import MetricsByPeriodDto
from investor8_sdk.models.metrics_metadata_response_dto import MetricsMetadataResponseDto
from investor8_sdk.models.metrics_statistics_dto import MetricsStatisticsDto
from investor8_sdk.models.momentum_metric_dto import MomentumMetricDto
from investor8_sdk.models.monthly_metrics import MonthlyMetrics
from investor8_sdk.models.monthly_returns import MonthlyReturns
Expand Down
110 changes: 110 additions & 0 deletions investor8_sdk/models/metrics_statistics_dto.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# coding: utf-8

"""
Investoreight Core API
Investoreight API Documentation: https://api.investoreight.com/api-docs/index.html # noqa: E501
OpenAPI spec version: 1.0.1
Contact: info@investoreight.com
Generated by: https://github.com/swagger-api/swagger-codegen.git
"""

import pprint
import re # noqa: F401

import six

class MetricsStatisticsDto(object):
"""NOTE: This class is auto generated by the swagger code generator program.
Do not edit the class manually.
"""
"""
Attributes:
swagger_types (dict): The key is attribute name
and the value is attribute type.
attribute_map (dict): The key is attribute name
and the value is json key in definition.
"""
swagger_types = {
'metrics': 'dict(str, dict(str, dict(str, float)))'
}

attribute_map = {
'metrics': 'Metrics'
}

def __init__(self, metrics=None): # noqa: E501
"""MetricsStatisticsDto - a model defined in Swagger""" # noqa: E501
self._metrics = None
self.discriminator = None
if metrics is not None:
self.metrics = metrics

@property
def metrics(self):
"""Gets the metrics of this MetricsStatisticsDto. # noqa: E501
:return: The metrics of this MetricsStatisticsDto. # noqa: E501
:rtype: dict(str, dict(str, dict(str, float)))
"""
return self._metrics

@metrics.setter
def metrics(self, metrics):
"""Sets the metrics of this MetricsStatisticsDto.
:param metrics: The metrics of this MetricsStatisticsDto. # noqa: E501
:type: dict(str, dict(str, dict(str, float)))
"""

self._metrics = metrics

def to_dict(self):
"""Returns the model properties as a dict"""
result = {}

for attr, _ in six.iteritems(self.swagger_types):
value = getattr(self, attr)
if isinstance(value, list):
result[attr] = list(map(
lambda x: x.to_dict() if hasattr(x, "to_dict") else x,
value
))
elif hasattr(value, "to_dict"):
result[attr] = value.to_dict()
elif isinstance(value, dict):
result[attr] = dict(map(
lambda item: (item[0], item[1].to_dict())
if hasattr(item[1], "to_dict") else item,
value.items()
))
else:
result[attr] = value
if issubclass(MetricsStatisticsDto, dict):
for key, value in self.items():
result[key] = value

return result

def to_str(self):
"""Returns the string representation of the model"""
return pprint.pformat(self.to_dict())

def __repr__(self):
"""For `print` and `pprint`"""
return self.to_str()

def __eq__(self, other):
"""Returns true if both objects are equal"""
if not isinstance(other, MetricsStatisticsDto):
return False

return self.__dict__ == other.__dict__

def __ne__(self, other):
"""Returns true if both objects are not equal"""
return not self == other
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from setuptools import setup, find_packages # noqa: H301

NAME = "investor8-sdk"
VERSION = "1.1.104"
VERSION = "1.1.105"
# To install the library, run the following
#
# python setup.py install
Expand Down
39 changes: 39 additions & 0 deletions test/test_metrics_statistics_dto.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# coding: utf-8

"""
Investoreight Core API
Investoreight API Documentation: https://api.investoreight.com/api-docs/index.html # noqa: E501
OpenAPI spec version: 1.0.1
Contact: info@investoreight.com
Generated by: https://github.com/swagger-api/swagger-codegen.git
"""

from __future__ import absolute_import

import unittest

import investor8_sdk
from investor8_sdk.models.metrics_statistics_dto import MetricsStatisticsDto # noqa: E501
from investor8_sdk.rest import ApiException


class TestMetricsStatisticsDto(unittest.TestCase):
"""MetricsStatisticsDto unit test stubs"""

def setUp(self):
pass

def tearDown(self):
pass

def testMetricsStatisticsDto(self):
"""Test MetricsStatisticsDto"""
# FIXME: construct object with mandatory attributes with example values
# model = investor8_sdk.models.metrics_statistics_dto.MetricsStatisticsDto() # noqa: E501
pass


if __name__ == '__main__':
unittest.main()

0 comments on commit 9ef2e74

Please sign in to comment.