DYAMS 0.2__tar.gz → 0.3__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.
- {dyams-0.2/src/DYAMS.egg-info → dyams-0.3}/PKG-INFO +1 -1
- {dyams-0.2 → dyams-0.3}/pyproject.toml +1 -1
- dyams-0.3/src/DYAMS/api/__init__.py +0 -0
- dyams-0.3/src/DYAMS/api/get_portfolio_holdings.py +77 -0
- {dyams-0.2 → dyams-0.3}/src/DYAMS/client.py +5 -1
- {dyams-0.2 → dyams-0.3/src/DYAMS.egg-info}/PKG-INFO +1 -1
- {dyams-0.2 → dyams-0.3}/src/DYAMS.egg-info/SOURCES.txt +1 -0
- dyams-0.2/src/DYAMS/api/__init__.py +0 -1
- {dyams-0.2 → dyams-0.3}/LICENSE +0 -0
- {dyams-0.2 → dyams-0.3}/README.md +0 -0
- {dyams-0.2 → dyams-0.3}/setup.cfg +0 -0
- {dyams-0.2 → dyams-0.3}/src/DYAMS/__init__.py +0 -0
- {dyams-0.2 → dyams-0.3}/src/DYAMS/api/get_post_investment_product_list.py +0 -0
- {dyams-0.2 → dyams-0.3}/src/DYAMS.egg-info/dependency_links.txt +0 -0
- {dyams-0.2 → dyams-0.3}/src/DYAMS.egg-info/top_level.txt +0 -0
|
File without changes
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import requests
|
|
2
|
+
import pandas as pd
|
|
3
|
+
|
|
4
|
+
field_mapping = {
|
|
5
|
+
'date': 'date',
|
|
6
|
+
'assetName': 'asset_name',
|
|
7
|
+
'assetCode': 'asset_code',
|
|
8
|
+
'securityType': 'security_type',
|
|
9
|
+
'exchangeCd': 'trading_market',
|
|
10
|
+
'netPrice': 'current_clean_price',
|
|
11
|
+
'aiRate': 'accrued_interest',
|
|
12
|
+
'chg': 'price_change',
|
|
13
|
+
'amount': 'position_quantity',
|
|
14
|
+
'marketValueLocal': 'position_market_value',
|
|
15
|
+
'weight': 'position_weight_(net_assets)',
|
|
16
|
+
'dailyProfitValueLocal': 'daily_profit_loss',
|
|
17
|
+
'dailyProfitRate': 'daily_profit_loss_rate',
|
|
18
|
+
'floatingProfitValueLocal': 'floating_profit_loss',
|
|
19
|
+
'floatingProfitRate': 'floating_profit_loss_rate',
|
|
20
|
+
'cumulativeProfitValueLocal': 'cumulative_profit_loss',
|
|
21
|
+
'cumulativeProfitRate': 'cumulative_profit_loss_rate',
|
|
22
|
+
'totalBuyCostLocal': 'position_cost',
|
|
23
|
+
'realizedAiLocal': 'interest_income',
|
|
24
|
+
'realizedProfitValueLocal': 'realized_profit_loss',
|
|
25
|
+
'dueDate': 'maturity_date',
|
|
26
|
+
'channel': 'trading_channel',
|
|
27
|
+
'direction': 'position_direction',
|
|
28
|
+
'price': 'latest_price',
|
|
29
|
+
'weightTotal': 'position_weight_(total_assets)',
|
|
30
|
+
'weightCost': 'position_weight_(total_cost)',
|
|
31
|
+
'buyCost': 'cost_price',
|
|
32
|
+
'cost': 'amortized_cost',
|
|
33
|
+
'fxRate': 'valuation_exchange_rate',
|
|
34
|
+
'positionTime': 'market_quotation_time',
|
|
35
|
+
'holdDate': 'position_building_date',
|
|
36
|
+
'partyFullName': 'issuing_entity',
|
|
37
|
+
'yearToMaturity': 'remaining_maturity',
|
|
38
|
+
'ytmByBrain': 'YTM_(Cost)',
|
|
39
|
+
'nominalRatingInst': 'bond_rating_agency',
|
|
40
|
+
'nominalRating': 'bond_rating',
|
|
41
|
+
'margin': 'margin_requirement',
|
|
42
|
+
'city': 'city',
|
|
43
|
+
'province': 'province',
|
|
44
|
+
'instRatingYY': 'issuer_rating_(YY)',
|
|
45
|
+
'instRatingDate': 'issuer_rating_date',
|
|
46
|
+
'instRating': 'issuer_rating',
|
|
47
|
+
'nominalRatingDate': 'bond_rating_date',
|
|
48
|
+
'instRatingInst': 'issuer_rating_agency'
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def get_portfolio_holdings(client, account_code, start_date, end_date):
|
|
53
|
+
url = f"{client.base_url}/lib/portfolio/v1/position"
|
|
54
|
+
params = {
|
|
55
|
+
'accountCode': account_code,
|
|
56
|
+
'startDate': start_date,
|
|
57
|
+
'endDate': end_date
|
|
58
|
+
}
|
|
59
|
+
headers = client.get_headers()
|
|
60
|
+
try:
|
|
61
|
+
response = requests.get(url, params=params, headers=headers)
|
|
62
|
+
if response.status_code != 200:
|
|
63
|
+
response.raise_for_status()
|
|
64
|
+
r = response.json()
|
|
65
|
+
if r.get('code') == 'F00100':
|
|
66
|
+
raise ValueError('rate limit')
|
|
67
|
+
items = r.get('list')
|
|
68
|
+
rows = []
|
|
69
|
+
for item in items:
|
|
70
|
+
row = {}
|
|
71
|
+
for api_field, our_field in field_mapping.items():
|
|
72
|
+
row[our_field] = item.get(api_field, None)
|
|
73
|
+
rows.append(row)
|
|
74
|
+
df = pd.DataFrame(rows)
|
|
75
|
+
return df
|
|
76
|
+
except Exception as e:
|
|
77
|
+
raise e
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
from .api import get_post_investment_product_list
|
|
1
|
+
from .api.get_post_investment_product_list import get_post_investment_product_list
|
|
2
|
+
from .api.get_portfolio_holdings import get_portfolio_holdings
|
|
2
3
|
|
|
3
4
|
|
|
4
5
|
class Client:
|
|
@@ -33,3 +34,6 @@ class Client:
|
|
|
33
34
|
|
|
34
35
|
def get_post_investment_product_list(self, post_investment_production_id=None):
|
|
35
36
|
return get_post_investment_product_list(self, post_investment_production_id)
|
|
37
|
+
|
|
38
|
+
def get_portfolio_holdings(self, account_code, start_date, end_date):
|
|
39
|
+
return get_portfolio_holdings(self, account_code, start_date, end_date)
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
from .get_post_investment_product_list import get_post_investment_product_list # noqa: F401
|
{dyams-0.2 → dyams-0.3}/LICENSE
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|