PyQuantimClient 2.0.27__tar.gz → 2.0.28__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pyquantimclient-2.0.27 → pyquantimclient-2.0.28}/PKG-INFO +1 -1
- {pyquantimclient-2.0.27 → pyquantimclient-2.0.28}/PyQuantimClient.egg-info/PKG-INFO +1 -1
- {pyquantimclient-2.0.27 → pyquantimclient-2.0.28}/setup.py +1 -1
- pyquantimclient-2.0.28/src/data.py +83 -0
- pyquantimclient-2.0.27/src/data.py +0 -47
- {pyquantimclient-2.0.27 → pyquantimclient-2.0.28}/PyQuantimClient.egg-info/SOURCES.txt +0 -0
- {pyquantimclient-2.0.27 → pyquantimclient-2.0.28}/PyQuantimClient.egg-info/dependency_links.txt +0 -0
- {pyquantimclient-2.0.27 → pyquantimclient-2.0.28}/PyQuantimClient.egg-info/top_level.txt +0 -0
- {pyquantimclient-2.0.27 → pyquantimclient-2.0.28}/README.md +0 -0
- {pyquantimclient-2.0.27 → pyquantimclient-2.0.28}/setup.cfg +0 -0
- {pyquantimclient-2.0.27 → pyquantimclient-2.0.28}/src/__init__.py +0 -0
- {pyquantimclient-2.0.27 → pyquantimclient-2.0.28}/src/alm.py +0 -0
- {pyquantimclient-2.0.27 → pyquantimclient-2.0.28}/src/api.py +0 -0
- {pyquantimclient-2.0.27 → pyquantimclient-2.0.28}/src/benchmarks.py +0 -0
- {pyquantimclient-2.0.27 → pyquantimclient-2.0.28}/src/bi.py +0 -0
- {pyquantimclient-2.0.27 → pyquantimclient-2.0.28}/src/credit.py +0 -0
- {pyquantimclient-2.0.27 → pyquantimclient-2.0.28}/src/energy.py +0 -0
- {pyquantimclient-2.0.27 → pyquantimclient-2.0.28}/src/performance.py +0 -0
- {pyquantimclient-2.0.27 → pyquantimclient-2.0.28}/src/portfolios.py +0 -0
- {pyquantimclient-2.0.27 → pyquantimclient-2.0.28}/src/preprocess_co.py +0 -0
- {pyquantimclient-2.0.27 → pyquantimclient-2.0.28}/src/returns.py +0 -0
- {pyquantimclient-2.0.27 → pyquantimclient-2.0.28}/src/risk.py +0 -0
- {pyquantimclient-2.0.27 → pyquantimclient-2.0.28}/src/utils.py +0 -0
|
@@ -4,7 +4,7 @@ setup(
|
|
|
4
4
|
name='PyQuantimClient',
|
|
5
5
|
packages=['PyQuantimClient'],
|
|
6
6
|
package_dir={'PyQuantimClient': 'src'},
|
|
7
|
-
version='2.0.
|
|
7
|
+
version='2.0.28',
|
|
8
8
|
description='Python client to access quantIM services',
|
|
9
9
|
author='Daniel Velasquez',
|
|
10
10
|
author_email='daniel.velasquez@sura-im.com',
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
import pandas as pd
|
|
3
|
+
import numpy as np
|
|
4
|
+
import datetime as dt
|
|
5
|
+
from .api import quantim
|
|
6
|
+
|
|
7
|
+
class time_series(quantim):
|
|
8
|
+
def __init__(self, username, password, secretpool, env="pdn", api_url=None):
|
|
9
|
+
super().__init__(username, password, secretpool, env, api_url)
|
|
10
|
+
|
|
11
|
+
def get_series(self, tks, ref_curr='Origen', join='outer', since_date='2008-01-01', verify=False):
|
|
12
|
+
'''
|
|
13
|
+
Get series
|
|
14
|
+
'''
|
|
15
|
+
data = {'tks':list(tks), 'ref_curr':ref_curr, 'join':join, 'since_date':since_date}
|
|
16
|
+
resp = self.api_call('get_series', method="post", data=data, verify=verify)
|
|
17
|
+
ts, summ, tks_invalid = pd.DataFrame(resp['ts']).set_index("Date"), pd.DataFrame(resp['summ']), resp['tks_invalid']
|
|
18
|
+
return ts, summ, tks_invalid
|
|
19
|
+
|
|
20
|
+
def clustering(self, tks, ref_curr='USD', ini_date=None, cluster_method='graph', ncluster=None, factor_tickers=None, use_pca=True, verify=False):
|
|
21
|
+
"""
|
|
22
|
+
Perform clustering on financial assets/variables.
|
|
23
|
+
|
|
24
|
+
This function clusters financial assets based on historical returns. The clustering method can be selected from dendrogram-based, graph-based, or factorial analysis.
|
|
25
|
+
|
|
26
|
+
Parameters
|
|
27
|
+
----------
|
|
28
|
+
tks : list
|
|
29
|
+
List of tickers (financial assets) to be clustered.
|
|
30
|
+
ref_curr : str, optional
|
|
31
|
+
Reference currency (ISO Code) for calculating returns, default is 'USD'.
|
|
32
|
+
ini_date : str, optional
|
|
33
|
+
Initial date for the time series data in 'YYYY-MM-DD' format, default is None (uses all available data).
|
|
34
|
+
cluster_method : str, optional
|
|
35
|
+
Clustering approach to use. Options are:
|
|
36
|
+
- 'dendrogram': Hierarchical clustering using a dendrogram.
|
|
37
|
+
- 'graph': Network-based clustering using correlation-based graph structures (default).
|
|
38
|
+
- 'factorial': Clustering based on third variables.
|
|
39
|
+
n_cluster : int, optional
|
|
40
|
+
Number of clusters to form. Only applies if method is dendrogram.
|
|
41
|
+
factor_tickers: list, optional
|
|
42
|
+
List of tickers of third variables used to cluster original tks.
|
|
43
|
+
use_pca: bool
|
|
44
|
+
Performs a PCA transformation on the tickers returns, and use the principal components to build clusters. Ony applies when method is 'dendrogram'.
|
|
45
|
+
|
|
46
|
+
Returns
|
|
47
|
+
-------
|
|
48
|
+
clusters : pd.Series
|
|
49
|
+
Series containing tickers and their corresponding cluster identifiers.
|
|
50
|
+
rets_summ : pd.DataFrame
|
|
51
|
+
Summary table with risk and return metrics for each ticker.
|
|
52
|
+
invalid_tickers : list
|
|
53
|
+
List of tickers that were invalid (e.g., no available data).
|
|
54
|
+
valid_dates : list
|
|
55
|
+
List of valid dates for which all tickers have data.
|
|
56
|
+
factors : pd.DataFrame or None
|
|
57
|
+
Table with factor coefficients for each ticker when using the 'factorial' method.
|
|
58
|
+
Returns None if 'factorial' clustering is not selected.
|
|
59
|
+
"""
|
|
60
|
+
if cluster_method.lower()[:3]!='gra' and ncluster is None:
|
|
61
|
+
raise ValueError('Please provide number of clusters (ncluster)')
|
|
62
|
+
|
|
63
|
+
data = {'ref_curr':ref_curr, 'ini_date':ini_date, 'ncluster':ncluster, 'tickers':tks, 'factor_tickers':factor_tickers, 'cluster_method':cluster_method, 'use_pca':use_pca}
|
|
64
|
+
resp = self.api_call('clustering', method="post", data=data, verify=verify)
|
|
65
|
+
clusters, rets_summ, invalid_tickers, valid_dates, factors = pd.Series(resp['clusters']), pd.DataFrame(resp['rets_summ']), resp['invalid_tickers'], resp['valid_dates'], pd.DataFrame(resp['factors']) if resp['factors'] is not None else None
|
|
66
|
+
return clusters, rets_summ, invalid_tickers, valid_dates, factors
|
|
67
|
+
|
|
68
|
+
class s3(quantim):
|
|
69
|
+
def __init__(self, username, password, secretpool, env="pdn", api_url=None):
|
|
70
|
+
super().__init__(username, password, secretpool, env, api_url)
|
|
71
|
+
|
|
72
|
+
def read_file(self, bucket, key, sep=',', verify=False, res_url=False):
|
|
73
|
+
'''
|
|
74
|
+
Get series
|
|
75
|
+
'''
|
|
76
|
+
data = {'bucket':bucket, 'key':key, 'sep':sep, 'res_url':res_url}
|
|
77
|
+
resp = self.api_call('retrieve_data_s3', method="post", data=data, verify=verify)
|
|
78
|
+
|
|
79
|
+
if res_url:
|
|
80
|
+
output = resp
|
|
81
|
+
else:
|
|
82
|
+
output = pd.DataFrame(resp)
|
|
83
|
+
return output
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
import pandas as pd
|
|
3
|
-
import numpy as np
|
|
4
|
-
import datetime as dt
|
|
5
|
-
from .api import quantim
|
|
6
|
-
|
|
7
|
-
class time_series(quantim):
|
|
8
|
-
def __init__(self, username, password, secretpool, env="pdn", api_url=None):
|
|
9
|
-
super().__init__(username, password, secretpool, env, api_url)
|
|
10
|
-
|
|
11
|
-
def get_series(self, tks, ref_curr='Origen', join='outer', since_date='2008-01-01', verify=False):
|
|
12
|
-
'''
|
|
13
|
-
Get series
|
|
14
|
-
'''
|
|
15
|
-
data = {'tks':list(tks), 'ref_curr':ref_curr, 'join':join, 'since_date':since_date}
|
|
16
|
-
resp = self.api_call('get_series', method="post", data=data, verify=verify)
|
|
17
|
-
ts, summ, tks_invalid = pd.DataFrame(resp['ts']).set_index("Date"), pd.DataFrame(resp['summ']), resp['tks_invalid']
|
|
18
|
-
return ts, summ, tks_invalid
|
|
19
|
-
|
|
20
|
-
def clustering(self, tks, ref_curr='USD', ini_date=None, ncluster=None, cluster_method='graph', factor_tickers=None, verify=False):
|
|
21
|
-
'''
|
|
22
|
-
Clustering
|
|
23
|
-
'''
|
|
24
|
-
if cluster_method.lower()[:3]!='gra' and ncluster is None:
|
|
25
|
-
raise ValueError('Please provide number of clusters (ncluster)')
|
|
26
|
-
|
|
27
|
-
data = {'ref_curr':ref_curr, 'ini_date':ini_date, 'ncluster':ncluster, 'tickers':tks, 'factor_tickers':factor_tickers, 'cluster_method':cluster_method}
|
|
28
|
-
resp = self.api_call('clustering', method="post", data=data, verify=verify)
|
|
29
|
-
clusters, rets_summ, invalid_tickers, valid_dates, factors = pd.Series(resp['clusters']), pd.DataFrame(resp['rets_summ']), resp['invalid_tickers'], resp['valid_dates'], pd.DataFrame(resp['factors']) if resp['factors'] is not None else None
|
|
30
|
-
return clusters, rets_summ, invalid_tickers, valid_dates, factors
|
|
31
|
-
|
|
32
|
-
class s3(quantim):
|
|
33
|
-
def __init__(self, username, password, secretpool, env="pdn", api_url=None):
|
|
34
|
-
super().__init__(username, password, secretpool, env, api_url)
|
|
35
|
-
|
|
36
|
-
def read_file(self, bucket, key, sep=',', verify=False, res_url=False):
|
|
37
|
-
'''
|
|
38
|
-
Get series
|
|
39
|
-
'''
|
|
40
|
-
data = {'bucket':bucket, 'key':key, 'sep':sep, 'res_url':res_url}
|
|
41
|
-
resp = self.api_call('retrieve_data_s3', method="post", data=data, verify=verify)
|
|
42
|
-
|
|
43
|
-
if res_url:
|
|
44
|
-
output = resp
|
|
45
|
-
else:
|
|
46
|
-
output = pd.DataFrame(resp)
|
|
47
|
-
return output
|
|
File without changes
|
{pyquantimclient-2.0.27 → pyquantimclient-2.0.28}/PyQuantimClient.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|