DYAMS 0.2__py3-none-any.whl
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.
- DYAMS/__init__.py +3 -0
- DYAMS/api/__init__.py +1 -0
- DYAMS/api/get_post_investment_product_list.py +51 -0
- DYAMS/client.py +35 -0
- dyams-0.2.dist-info/METADATA +21 -0
- dyams-0.2.dist-info/RECORD +9 -0
- dyams-0.2.dist-info/WHEEL +5 -0
- dyams-0.2.dist-info/licenses/LICENSE +20 -0
- dyams-0.2.dist-info/top_level.txt +1 -0
DYAMS/__init__.py
ADDED
DYAMS/api/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .get_post_investment_product_list import get_post_investment_product_list # noqa: F401
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import requests
|
|
2
|
+
import pandas as pd
|
|
3
|
+
|
|
4
|
+
field_mapping = {
|
|
5
|
+
'accountName': 'post_investment_product_name', # 产品名称
|
|
6
|
+
'accountCode': 'post_investment_product_id', # 产品代码
|
|
7
|
+
'openDate': 'establishment_date', # 成立日期
|
|
8
|
+
'accountType': 'product_type', # 账户类型作为产品类型
|
|
9
|
+
'benchmark': 'benchmark', # 参考基准
|
|
10
|
+
'user': 'creator', # 用户作为创建人
|
|
11
|
+
'netValueStartDate': 'NAV_start_date', # 净值开始日期
|
|
12
|
+
'netValueDate': 'latest_NAV_date', # 最新净值日期
|
|
13
|
+
'navFrequency': 'NAV_update_frequency' # 净值更新频率
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def get_post_investment_product_list(client, post_investment_product_id=None):
|
|
18
|
+
|
|
19
|
+
url = f"{client.base_url}/lib/portfolio/v1/list"
|
|
20
|
+
headers = client.get_headers()
|
|
21
|
+
data = "[]"
|
|
22
|
+
if post_investment_product_id:
|
|
23
|
+
data = "[\"" + post_investment_product_id + "\"]"
|
|
24
|
+
|
|
25
|
+
try:
|
|
26
|
+
response = requests.post(url, headers=headers, data=data)
|
|
27
|
+
if response.status_code != 200:
|
|
28
|
+
response.raise_for_status()
|
|
29
|
+
r = response.json()
|
|
30
|
+
if r.get('code') == 'F00100':
|
|
31
|
+
raise ValueError('rate limit')
|
|
32
|
+
items = r.get('list')
|
|
33
|
+
|
|
34
|
+
rows = []
|
|
35
|
+
for item in items:
|
|
36
|
+
row = {}
|
|
37
|
+
for api_field, our_field in field_mapping.items():
|
|
38
|
+
row[our_field] = item.get(api_field, None)
|
|
39
|
+
rows.append(row)
|
|
40
|
+
|
|
41
|
+
df = pd.DataFrame(rows)
|
|
42
|
+
date_fields = ['establishment_date', 'NAV_start_date', 'latest_NAV_date']
|
|
43
|
+
for field in date_fields:
|
|
44
|
+
if field in df.columns:
|
|
45
|
+
try:
|
|
46
|
+
df[field] = pd.to_datetime(df[field], errors='coerce').dt.strftime('%Y-%m-%d')
|
|
47
|
+
except Exception:
|
|
48
|
+
pass
|
|
49
|
+
return df
|
|
50
|
+
except Exception as e:
|
|
51
|
+
raise e
|
DYAMS/client.py
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
from .api import get_post_investment_product_list
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class Client:
|
|
5
|
+
|
|
6
|
+
_instance = None
|
|
7
|
+
|
|
8
|
+
def __new__(cls, *args, **kwargs):
|
|
9
|
+
if cls._instance is None:
|
|
10
|
+
cls._instance = super(Client, cls).__new__(cls)
|
|
11
|
+
cls._instance._initialized = False
|
|
12
|
+
return cls._instance
|
|
13
|
+
|
|
14
|
+
def __init__(self, token='', env='prd'):
|
|
15
|
+
if self._initialized:
|
|
16
|
+
return
|
|
17
|
+
self.token = token
|
|
18
|
+
if env == 'prd':
|
|
19
|
+
self.base_url = "https://gw.datayes.com/aladdin_mof"
|
|
20
|
+
elif env == 'qa':
|
|
21
|
+
self.base_url = "https://gw.datayes-stg.com/mom_aladdin_qa"
|
|
22
|
+
elif env == 'stg':
|
|
23
|
+
self.base_url = "https://gw.datayes-stg.com/mom_aladdin_stg"
|
|
24
|
+
else:
|
|
25
|
+
raise ValueError("error env")
|
|
26
|
+
self._initialized = True
|
|
27
|
+
|
|
28
|
+
def get_headers(self):
|
|
29
|
+
return {
|
|
30
|
+
'Content-Type': 'application/json',
|
|
31
|
+
'Authorization': f'Bearer {self.token}'
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
def get_post_investment_product_list(self, post_investment_production_id=None):
|
|
35
|
+
return get_post_investment_product_list(self, post_investment_production_id)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: DYAMS
|
|
3
|
+
Version: 0.2
|
|
4
|
+
Summary: 通联数据AMS系统数据SDK
|
|
5
|
+
Author-email: songjiangduo <jiangduo.song@datayes.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: Operating System :: OS Independent
|
|
9
|
+
Requires-Python: >=3.9
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Dynamic: license-file
|
|
13
|
+
|
|
14
|
+
## 通联数据AMS系统数据SDK
|
|
15
|
+
|
|
16
|
+
### 介绍
|
|
17
|
+
[萝卜投资](https://r.datayes.com/)
|
|
18
|
+
|
|
19
|
+
### 调用示例
|
|
20
|
+
|
|
21
|
+
### api列表
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
DYAMS/__init__.py,sha256=GHP58uOsE_7GJsU0Pzh7f5dKbWjdyAjKs7q2WeAwl8I,49
|
|
2
|
+
DYAMS/client.py,sha256=VoOSBStP5YH5KcMJEPaUxz45dlnFkbat0JIKm9cdIAA,1122
|
|
3
|
+
DYAMS/api/__init__.py,sha256=avJPZbfQOBgmIOYKXVKLzR278vuSkDCwO1KicuZPuPY,93
|
|
4
|
+
DYAMS/api/get_post_investment_product_list.py,sha256=YBwQ5OwJmH1cMeQPbaUeKn5RSrm7HRrY60jI93GBAxw,1922
|
|
5
|
+
dyams-0.2.dist-info/licenses/LICENSE,sha256=WOCX9n2629PC9kRp-MvyMGR4DrNHG7_Q1Woo6QotwZ4,1130
|
|
6
|
+
dyams-0.2.dist-info/METADATA,sha256=OmIoetN0VTfmCJ7w9errjq9wSJArNhzg0mcUwenyyKk,487
|
|
7
|
+
dyams-0.2.dist-info/WHEEL,sha256=Nw36Djuh_5VDukK0H78QzOX-_FQEo6V37m3nkm96gtU,91
|
|
8
|
+
dyams-0.2.dist-info/top_level.txt,sha256=7vYrzyi90ywuwd-c24CKytuWbuILmzcU7kQYCuBu7No,6
|
|
9
|
+
dyams-0.2.dist-info/RECORD,,
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
通联数据机密
|
|
2
|
+
--------------------------------------------------------------------
|
|
3
|
+
通联数据股份公司版权所有 © 2013-$today.year
|
|
4
|
+
|
|
5
|
+
注意:本文所载所有信息均属于通联数据股份公司资产。本文所包含的知识和技术概念均属于
|
|
6
|
+
通联数据产权,并可能由中国、美国和其他国家专利或申请中的专利所覆盖,并受商业秘密或
|
|
7
|
+
版权法保护。
|
|
8
|
+
除非事先获得通联数据股份公司书面许可,严禁传播文中信息或复制本材料。
|
|
9
|
+
|
|
10
|
+
DataYes CONFIDENTIAL
|
|
11
|
+
--------------------------------------------------------------------
|
|
12
|
+
Copyright © 2013-$today.year DataYes, All Rights Reserved.
|
|
13
|
+
|
|
14
|
+
NOTICE: All information contained herein is the property of DataYes
|
|
15
|
+
Incorporated. The intellectual and technical concepts contained herein are
|
|
16
|
+
proprietary to DataYes Incorporated, and may be covered by China, U.S. and
|
|
17
|
+
Other Countries Patents, patents in process, and are protected by trade
|
|
18
|
+
secret or copyright law.
|
|
19
|
+
Dissemination of this information or reproduction of this material is
|
|
20
|
+
strictly forbidden unless prior written permission is obtained from DataYes.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
DYAMS
|