dnse-sdk-openapi 2.4.1__tar.gz → 2.4.2__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.
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/PKG-INFO +1 -1
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/README.md +1 -1
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/dnse/api/client.py +108 -2
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/dnse/websocket/client.py +1 -10
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/dnse/websocket/models.py +17 -32
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/dnse_sdk_openapi.egg-info/PKG-INFO +1 -1
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/dnse_sdk_openapi.egg-info/SOURCES.txt +11 -0
- dnse_sdk_openapi-2.4.2/marketdata-api/get_corporate_actions.py +27 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/pyproject.toml +1 -1
- dnse_sdk_openapi-2.4.2/tests/test_client.py +165 -0
- dnse_sdk_openapi-2.4.2/tests/test_corporate_actions.py +67 -0
- dnse_sdk_openapi-2.4.2/tests/test_loan_package_detail.py +36 -0
- dnse_sdk_openapi-2.4.2/tests/test_payment_configs.py +83 -0
- dnse_sdk_openapi-2.4.2/trading-api/get_loan_by_id.py +27 -0
- dnse_sdk_openapi-2.4.2/trading-api/get_loan_package_detail.py +28 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/trading-api/get_loan_packages.py +1 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/trading-api/get_loans.py +1 -0
- dnse_sdk_openapi-2.4.2/trading-api/get_payment_configs.py +25 -0
- dnse_sdk_openapi-2.4.2/trading-api/get_pnl_reports.py +31 -0
- dnse_sdk_openapi-2.4.2/trading-api/get_position_payment_configs.py +25 -0
- dnse_sdk_openapi-2.4.2/trading-api/put_payment_configs.py +26 -0
- dnse_sdk_openapi-2.4.2/trading-api/put_position_payment_configs.py +26 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/websocket-marketdata/ohlc_closed.py +10 -8
- dnse_sdk_openapi-2.4.1/tests/test_client.py +0 -57
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/broker-api/get_list_care_by.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/dnse/__init__.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/dnse/api/_version.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/dnse/api/common.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/dnse/websocket/_version.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/dnse/websocket/auth.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/dnse/websocket/connection.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/dnse/websocket/encoding.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/dnse/websocket/exceptions.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/dnse/websocket/py.typed +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/dnse_sdk_openapi.egg-info/dependency_links.txt +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/dnse_sdk_openapi.egg-info/top_level.txt +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/examples/env_util.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/examples/indicators.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/examples/log_util.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/examples/market_utils.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/examples/otp_email.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/examples/position_manager.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/examples/position_store.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/examples/reference/orders-email-otp.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/examples/reference/orders-smart-otp.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/examples/reference/smart-otp-handoff-flow.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/examples/strategy_base.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/examples/strategy_ichimoku.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/examples/strategy_price_action.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/examples/strategy_scalping.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/examples/token_store.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/examples/use-cases/auto-trader.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/examples/use-cases/market-data.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/examples/use-cases/order-history.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/examples/use-cases/place-a-trade.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/examples/use-cases/portfolio-check.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/marketdata-api/get_expected_price.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/marketdata-api/get_foreign_trading.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/marketdata-api/get_instruments.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/marketdata-api/get_lastest_session.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/marketdata-api/get_latest_quote.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/marketdata-api/get_latest_trade.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/marketdata-api/get_market_index.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/marketdata-api/get_ohlc.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/marketdata-api/get_quotes.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/marketdata-api/get_security_definition.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/marketdata-api/get_trades.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/marketdata-api/get_trades_volume_profile.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/marketdata-api/get_working_dates.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/setup.cfg +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/tests/test_smart_otp_handoff.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/trading-api/cancel_order.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/trading-api/close_position.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/trading-api/create_smart_otp_handoff.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/trading-api/create_trading_token.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/trading-api/get_account_pnl_configs.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/trading-api/get_accounts.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/trading-api/get_balances.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/trading-api/get_close_price.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/trading-api/get_corporate_action_history.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/trading-api/get_execution_detail.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/trading-api/get_order_detail.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/trading-api/get_order_history.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/trading-api/get_orders.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/trading-api/get_position_by_id.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/trading-api/get_position_pnl_configs.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/trading-api/get_positions.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/trading-api/get_ppse.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/trading-api/patch_account_pnl_configs.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/trading-api/post_order.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/trading-api/post_position_pnl_configs.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/trading-api/put_order.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/trading-api/reverse_position.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/trading-api/send_email_otp.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/websocket-marketdata/estimated_market_index.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/websocket-marketdata/expected_price.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/websocket-marketdata/foreign_investor.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/websocket-marketdata/market_index.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/websocket-marketdata/market_index_influence.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/websocket-marketdata/ohlc.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/websocket-marketdata/quote.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/websocket-marketdata/sec_def.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/websocket-marketdata/session.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/websocket-marketdata/trade.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/websocket-marketdata/trade_extra.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/websocket-trading/broker_order.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/websocket-trading/broker_position.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/websocket-trading/order.py +0 -0
- {dnse_sdk_openapi-2.4.1 → dnse_sdk_openapi-2.4.2}/websocket-trading/position.py +0 -0
|
@@ -619,4 +619,4 @@ Before using trading functionality in a production application, make sure that:
|
|
|
619
619
|
* API credentials are stored securely.
|
|
620
620
|
* Trading authentication requirements have been completed.
|
|
621
621
|
* API errors are handled appropriately.
|
|
622
|
-
* WebSocket disconnections and reconnections are handled appropriately.
|
|
622
|
+
* WebSocket disconnections and reconnections are handled appropriately.
|
|
@@ -41,10 +41,18 @@ class DNSEClient:
|
|
|
41
41
|
def get_balances(self, account_no, dry_run=False):
|
|
42
42
|
return self._request("GET", f"/accounts/{account_no}/balances", dry_run=dry_run)
|
|
43
43
|
|
|
44
|
-
def get_loan_packages(self, account_no, market_type, symbol=None, dry_run=False):
|
|
44
|
+
def get_loan_packages(self, account_no, market_type, symbol=None, dry_run=False, include_all=None):
|
|
45
|
+
"""List loan packages; include_all=True opts in to all STOCK/DERIVATIVE packages.
|
|
46
|
+
|
|
47
|
+
Omitting include_all preserves the existing API request and response behavior.
|
|
48
|
+
"""
|
|
45
49
|
query = {"marketType": market_type}
|
|
46
50
|
if symbol:
|
|
47
51
|
query["symbol"] = symbol
|
|
52
|
+
if include_all is not None:
|
|
53
|
+
if not isinstance(include_all, bool):
|
|
54
|
+
raise TypeError("include_all must be a bool or None")
|
|
55
|
+
query["includeAll"] = "true" if include_all else "false"
|
|
48
56
|
return self._request(
|
|
49
57
|
"GET",
|
|
50
58
|
f"/accounts/{account_no}/loan-packages",
|
|
@@ -52,10 +60,21 @@ class DNSEClient:
|
|
|
52
60
|
dry_run=dry_run,
|
|
53
61
|
)
|
|
54
62
|
|
|
63
|
+
def get_loan_package_detail(self, account_no, loan_package_id, market_type, symbol, dry_run=False):
|
|
64
|
+
"""Get exactly one STOCK or DERIVATIVE loan package by its ID."""
|
|
65
|
+
return self._request(
|
|
66
|
+
"GET",
|
|
67
|
+
f"/accounts/{account_no}/loan-packages/{loan_package_id}",
|
|
68
|
+
query={"marketType": market_type, "symbol": symbol},
|
|
69
|
+
version="2026-01-01",
|
|
70
|
+
dry_run=dry_run,
|
|
71
|
+
)
|
|
72
|
+
|
|
55
73
|
def get_loans(
|
|
56
74
|
self,
|
|
57
75
|
account_no,
|
|
58
76
|
market_type,
|
|
77
|
+
loan_status="DISBURSED",
|
|
59
78
|
disbursement_from=None,
|
|
60
79
|
disbursement_to=None,
|
|
61
80
|
due_date_from=None,
|
|
@@ -65,7 +84,7 @@ class DNSEClient:
|
|
|
65
84
|
page_size=None,
|
|
66
85
|
dry_run=False,
|
|
67
86
|
):
|
|
68
|
-
query = {"marketType": market_type}
|
|
87
|
+
query = {"marketType": market_type, "loanStatus": loan_status}
|
|
69
88
|
if disbursement_from is not None:
|
|
70
89
|
query["disbursementFrom"] = disbursement_from
|
|
71
90
|
if disbursement_to is not None:
|
|
@@ -87,6 +106,37 @@ class DNSEClient:
|
|
|
87
106
|
dry_run=dry_run,
|
|
88
107
|
)
|
|
89
108
|
|
|
109
|
+
def get_loan_by_id(
|
|
110
|
+
self,
|
|
111
|
+
account_no,
|
|
112
|
+
loan_id,
|
|
113
|
+
market_type,
|
|
114
|
+
version="2026-01-01",
|
|
115
|
+
dry_run=False,
|
|
116
|
+
):
|
|
117
|
+
return self._request(
|
|
118
|
+
"GET",
|
|
119
|
+
f"/accounts/{account_no}/loans/{loan_id}",
|
|
120
|
+
query={"marketType": market_type},
|
|
121
|
+
version=version,
|
|
122
|
+
dry_run=dry_run,
|
|
123
|
+
)
|
|
124
|
+
|
|
125
|
+
def get_pnl_reports(self, account_no, market_type, from_date, to_date, symbol=None,
|
|
126
|
+
page_index=None, page_size=None, loan_package_id=None, dry_run=False):
|
|
127
|
+
"""Get STOCK or DERIVATIVE profit/loss reports for one account."""
|
|
128
|
+
query = {"marketType": market_type, "fromDate": from_date, "toDate": to_date}
|
|
129
|
+
if symbol is not None:
|
|
130
|
+
query["symbol"] = symbol
|
|
131
|
+
if page_index is not None:
|
|
132
|
+
query["pageIndex"] = page_index
|
|
133
|
+
if page_size is not None:
|
|
134
|
+
query["pageSize"] = page_size
|
|
135
|
+
if loan_package_id is not None:
|
|
136
|
+
query["loanPackageId"] = loan_package_id
|
|
137
|
+
return self._request("GET", f"/accounts/{account_no}/pnl-reports", query=query,
|
|
138
|
+
version="2026-01-01", dry_run=dry_run)
|
|
139
|
+
|
|
90
140
|
def get_positions(self, account_no, market_type, dry_run=False):
|
|
91
141
|
return self._request(
|
|
92
142
|
"GET",
|
|
@@ -129,6 +179,44 @@ class DNSEClient:
|
|
|
129
179
|
version=version,
|
|
130
180
|
dry_run=dry_run)
|
|
131
181
|
|
|
182
|
+
def get_payment_configs(self, account_no, market_type, payment_type, version="2026-01-01", dry_run=False):
|
|
183
|
+
return self._request(
|
|
184
|
+
"GET",
|
|
185
|
+
f"/accounts/{account_no}/payment-configs",
|
|
186
|
+
query={"marketType": market_type, "paymentType": payment_type},
|
|
187
|
+
version=version,
|
|
188
|
+
dry_run=dry_run,
|
|
189
|
+
)
|
|
190
|
+
|
|
191
|
+
def put_payment_configs(self, account_no, market_type, payment_type, payload, version="2026-01-01", dry_run=False):
|
|
192
|
+
return self._request(
|
|
193
|
+
"PUT",
|
|
194
|
+
f"/accounts/{account_no}/payment-configs",
|
|
195
|
+
query={"marketType": market_type, "paymentType": payment_type},
|
|
196
|
+
body=payload,
|
|
197
|
+
version=version,
|
|
198
|
+
dry_run=dry_run,
|
|
199
|
+
)
|
|
200
|
+
|
|
201
|
+
def get_position_payment_configs(self, position_id, market_type, payment_type, version="2026-01-01", dry_run=False):
|
|
202
|
+
return self._request(
|
|
203
|
+
"GET",
|
|
204
|
+
f"/positions/{position_id}/payment-configs",
|
|
205
|
+
query={"marketType": market_type, "paymentType": payment_type},
|
|
206
|
+
version=version,
|
|
207
|
+
dry_run=dry_run,
|
|
208
|
+
)
|
|
209
|
+
|
|
210
|
+
def put_position_payment_configs(self, position_id, market_type, payment_type, payload, version="2026-01-01", dry_run=False):
|
|
211
|
+
return self._request(
|
|
212
|
+
"PUT",
|
|
213
|
+
f"/positions/{position_id}/payment-configs",
|
|
214
|
+
query={"marketType": market_type, "paymentType": payment_type},
|
|
215
|
+
body=payload,
|
|
216
|
+
version=version,
|
|
217
|
+
dry_run=dry_run,
|
|
218
|
+
)
|
|
219
|
+
|
|
132
220
|
def post_position_pnl_configs(self, market_type, position_id, payload, trading_token, version=None, dry_run=False):
|
|
133
221
|
headers = {"trading-token": trading_token}
|
|
134
222
|
return self._request(
|
|
@@ -410,6 +498,24 @@ class DNSEClient:
|
|
|
410
498
|
dry_run=dry_run,
|
|
411
499
|
)
|
|
412
500
|
|
|
501
|
+
def get_corporate_actions(
|
|
502
|
+
self, page=None, page_size=None, time_range=None, version=None, dry_run=False
|
|
503
|
+
):
|
|
504
|
+
query = {}
|
|
505
|
+
if page is not None:
|
|
506
|
+
query["page"] = page
|
|
507
|
+
if page_size is not None:
|
|
508
|
+
query["page_size"] = page_size
|
|
509
|
+
if time_range is not None:
|
|
510
|
+
query["time_range"] = time_range
|
|
511
|
+
return self._request(
|
|
512
|
+
"GET",
|
|
513
|
+
"/market/corporate-actions",
|
|
514
|
+
query=query if query else None,
|
|
515
|
+
version=version,
|
|
516
|
+
dry_run=dry_run,
|
|
517
|
+
)
|
|
518
|
+
|
|
413
519
|
def get_latest_trade(self, symbol, board_id=None, dry_run=False):
|
|
414
520
|
query = {}
|
|
415
521
|
if board_id is not None:
|
|
@@ -24,7 +24,7 @@ from .exceptions import (
|
|
|
24
24
|
SubscriptionError,
|
|
25
25
|
ConnectionClosed,
|
|
26
26
|
)
|
|
27
|
-
from .models import Trade, Quote, Ohlc, Order,
|
|
27
|
+
from .models import Trade, Quote, Ohlc, Order, ExpectedPrice, SecurityDefinition, TradeExtra, \
|
|
28
28
|
MarketIndex, ForeignInvestor, Position, EstimatedMarketIndex, Session, IndexInfluence
|
|
29
29
|
|
|
30
30
|
logger = logging.getLogger(__name__)
|
|
@@ -53,7 +53,6 @@ _MSG_TYPE_MAP = {
|
|
|
53
53
|
"mi": ("market_index", MarketIndex, None),
|
|
54
54
|
"emi": ("estimated_market_index", EstimatedMarketIndex, "marketIndex"),
|
|
55
55
|
"ii": ("market_index_influence", IndexInfluence, None),
|
|
56
|
-
"a": ("account", AccountUpdate, None),
|
|
57
56
|
"f": ("foreign", ForeignInvestor, None),
|
|
58
57
|
"s": ("session", Session, None),
|
|
59
58
|
}
|
|
@@ -468,14 +467,6 @@ class TradingClient:
|
|
|
468
467
|
if on_position:
|
|
469
468
|
self.on("position", on_position)
|
|
470
469
|
|
|
471
|
-
async def subscribe_account(
|
|
472
|
-
self, on_account: Optional[Callable[[AccountUpdate], None]] = None
|
|
473
|
-
) -> None:
|
|
474
|
-
await self._subscribe_channel("account", [])
|
|
475
|
-
|
|
476
|
-
if on_account:
|
|
477
|
-
self.on("account", on_account)
|
|
478
|
-
|
|
479
470
|
async def _subscribe_channel(
|
|
480
471
|
self, channel: str, symbols: List[str], **kwargs
|
|
481
472
|
) -> None:
|
|
@@ -2,14 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
This module provides typed data models for all message types:
|
|
4
4
|
- Market data: Trade, Quote, OHLC, ExpectedPrice, TradeExtra, SecurityDefinition
|
|
5
|
-
- Private channels: Order, Position
|
|
5
|
+
- Private channels: Order, Position
|
|
6
6
|
|
|
7
7
|
All models support parsing from both abbreviated (MessagePack) and full (JSON) field names.
|
|
8
8
|
"""
|
|
9
9
|
|
|
10
10
|
from dataclasses import dataclass, field
|
|
11
11
|
from datetime import datetime
|
|
12
|
-
from decimal import Decimal
|
|
13
12
|
from typing import Optional, List, Dict, Any, Tuple
|
|
14
13
|
|
|
15
14
|
|
|
@@ -438,6 +437,14 @@ class Order:
|
|
|
438
437
|
transDate: str
|
|
439
438
|
createdDate: str
|
|
440
439
|
modifiedDate: str
|
|
440
|
+
orderCategory: Optional[str] = None
|
|
441
|
+
stopPrice: Optional[float] = None
|
|
442
|
+
stopOrderPrice: Optional[float] = None
|
|
443
|
+
conditionOperator: Optional[str] = None
|
|
444
|
+
durationType: Optional[str] = None
|
|
445
|
+
durationDateTime: Optional[str] = None
|
|
446
|
+
errorMessage: Optional[str] = None
|
|
447
|
+
externalOrderId: Optional[int] = None
|
|
441
448
|
receivedAt: Optional[float] = field(default=None, repr=False)
|
|
442
449
|
|
|
443
450
|
@classmethod
|
|
@@ -466,6 +473,14 @@ class Order:
|
|
|
466
473
|
transDate=data.get("transDate"),
|
|
467
474
|
createdDate=data.get("createdDate"),
|
|
468
475
|
modifiedDate=data.get("modifiedDate"),
|
|
476
|
+
orderCategory=data.get("orderCategory"),
|
|
477
|
+
stopPrice=data.get("stopPrice"),
|
|
478
|
+
stopOrderPrice=data.get("stopOrderPrice"),
|
|
479
|
+
conditionOperator=data.get("conditionOperator"),
|
|
480
|
+
durationType=data.get("durationType"),
|
|
481
|
+
durationDateTime=data.get("durationDateTime"),
|
|
482
|
+
errorMessage=data.get("errorMessage"),
|
|
483
|
+
externalOrderId=data.get("externalOrderId"),
|
|
469
484
|
receivedAt=data.get("_receivedAt"),
|
|
470
485
|
)
|
|
471
486
|
|
|
@@ -633,33 +648,3 @@ class Session:
|
|
|
633
648
|
time=parse_timestamp(data.get("sendingTime")),
|
|
634
649
|
receivedAt=data.get("_receivedAt"),
|
|
635
650
|
)
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
@dataclass
|
|
639
|
-
class AccountUpdate:
|
|
640
|
-
cash: Decimal
|
|
641
|
-
buyingPower: Decimal
|
|
642
|
-
portfolioValue: Decimal
|
|
643
|
-
equity: Decimal
|
|
644
|
-
timestamp: datetime
|
|
645
|
-
|
|
646
|
-
@classmethod
|
|
647
|
-
def from_dict(cls, data: Dict[str, Any]) -> "AccountUpdate":
|
|
648
|
-
"""Parse account update from message data.
|
|
649
|
-
|
|
650
|
-
Args:
|
|
651
|
-
data: Raw message dict with either abbreviated or full field names
|
|
652
|
-
|
|
653
|
-
Returns:
|
|
654
|
-
AccountUpdate instance
|
|
655
|
-
|
|
656
|
-
Example:
|
|
657
|
-
>>> AccountUpdate.from_dict({"c": "10000.00", "bp": "20000.00", ...})
|
|
658
|
-
"""
|
|
659
|
-
return cls(
|
|
660
|
-
cash=Decimal(str(data.get("cash"))),
|
|
661
|
-
buyingPower=Decimal(str(data.get("buyingPower"))),
|
|
662
|
-
portfolioValue=Decimal(str(data.get("portfolioValue"))),
|
|
663
|
-
equity=Decimal(str(data.get("equity"))),
|
|
664
|
-
timestamp=datetime.fromtimestamp((data.get("timestamp")) / 1000)
|
|
665
|
-
)
|
|
@@ -37,6 +37,7 @@ examples/use-cases/market-data.py
|
|
|
37
37
|
examples/use-cases/order-history.py
|
|
38
38
|
examples/use-cases/place-a-trade.py
|
|
39
39
|
examples/use-cases/portfolio-check.py
|
|
40
|
+
marketdata-api/get_corporate_actions.py
|
|
40
41
|
marketdata-api/get_expected_price.py
|
|
41
42
|
marketdata-api/get_foreign_trading.py
|
|
42
43
|
marketdata-api/get_instruments.py
|
|
@@ -51,6 +52,9 @@ marketdata-api/get_trades.py
|
|
|
51
52
|
marketdata-api/get_trades_volume_profile.py
|
|
52
53
|
marketdata-api/get_working_dates.py
|
|
53
54
|
tests/test_client.py
|
|
55
|
+
tests/test_corporate_actions.py
|
|
56
|
+
tests/test_loan_package_detail.py
|
|
57
|
+
tests/test_payment_configs.py
|
|
54
58
|
tests/test_smart_otp_handoff.py
|
|
55
59
|
trading-api/cancel_order.py
|
|
56
60
|
trading-api/close_position.py
|
|
@@ -62,12 +66,17 @@ trading-api/get_balances.py
|
|
|
62
66
|
trading-api/get_close_price.py
|
|
63
67
|
trading-api/get_corporate_action_history.py
|
|
64
68
|
trading-api/get_execution_detail.py
|
|
69
|
+
trading-api/get_loan_by_id.py
|
|
70
|
+
trading-api/get_loan_package_detail.py
|
|
65
71
|
trading-api/get_loan_packages.py
|
|
66
72
|
trading-api/get_loans.py
|
|
67
73
|
trading-api/get_order_detail.py
|
|
68
74
|
trading-api/get_order_history.py
|
|
69
75
|
trading-api/get_orders.py
|
|
76
|
+
trading-api/get_payment_configs.py
|
|
77
|
+
trading-api/get_pnl_reports.py
|
|
70
78
|
trading-api/get_position_by_id.py
|
|
79
|
+
trading-api/get_position_payment_configs.py
|
|
71
80
|
trading-api/get_position_pnl_configs.py
|
|
72
81
|
trading-api/get_positions.py
|
|
73
82
|
trading-api/get_ppse.py
|
|
@@ -75,6 +84,8 @@ trading-api/patch_account_pnl_configs.py
|
|
|
75
84
|
trading-api/post_order.py
|
|
76
85
|
trading-api/post_position_pnl_configs.py
|
|
77
86
|
trading-api/put_order.py
|
|
87
|
+
trading-api/put_payment_configs.py
|
|
88
|
+
trading-api/put_position_payment_configs.py
|
|
78
89
|
trading-api/reverse_position.py
|
|
79
90
|
trading-api/send_email_otp.py
|
|
80
91
|
websocket-marketdata/estimated_market_index.py
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
import os
|
|
3
|
+
import sys
|
|
4
|
+
|
|
5
|
+
sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
|
|
6
|
+
|
|
7
|
+
from dnse import DNSEClient
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def main():
|
|
11
|
+
client = DNSEClient(
|
|
12
|
+
api_key="replace-with-api-key",
|
|
13
|
+
api_secret="replace-with-api-secret",
|
|
14
|
+
base_url="https://openapi.dnse.com.vn",
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
status, body = client.get_corporate_actions(
|
|
18
|
+
page=1,
|
|
19
|
+
page_size=1000,
|
|
20
|
+
time_range=30,
|
|
21
|
+
dry_run=False,
|
|
22
|
+
)
|
|
23
|
+
print(status, body)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
if __name__ == "__main__":
|
|
27
|
+
main()
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
import os
|
|
3
|
+
import sys
|
|
4
|
+
import unittest
|
|
5
|
+
|
|
6
|
+
sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
|
|
7
|
+
|
|
8
|
+
from dnse import DNSEClient
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class DNSEClientTest(unittest.TestCase):
|
|
12
|
+
def test_get_loan_packages_include_all_is_opt_in_and_backward_compatible(self):
|
|
13
|
+
client = DNSEClient(
|
|
14
|
+
api_key="key", api_secret="secret", base_url="https://example.test"
|
|
15
|
+
)
|
|
16
|
+
calls = []
|
|
17
|
+
|
|
18
|
+
def fake_request(method, path, query=None, **kwargs):
|
|
19
|
+
calls.append((method, path, dict(query), kwargs))
|
|
20
|
+
return 200, "{}"
|
|
21
|
+
|
|
22
|
+
client._request = fake_request
|
|
23
|
+
client.get_loan_packages("0001179019", "STOCK", "ACB")
|
|
24
|
+
client.get_loan_packages("0001179019", "STOCK", "ACB", include_all=True)
|
|
25
|
+
client.get_loan_packages("0001179019", "DERIVATIVE", "41I1G9000", include_all=False)
|
|
26
|
+
|
|
27
|
+
self.assertEqual("GET", calls[0][0])
|
|
28
|
+
self.assertEqual("/accounts/0001179019/loan-packages", calls[0][1])
|
|
29
|
+
self.assertEqual({"marketType": "STOCK", "symbol": "ACB"}, calls[0][2])
|
|
30
|
+
self.assertEqual({"dry_run": False}, calls[0][3])
|
|
31
|
+
self.assertEqual("true", calls[1][2]["includeAll"])
|
|
32
|
+
self.assertEqual("false", calls[2][2]["includeAll"])
|
|
33
|
+
with self.assertRaises(TypeError):
|
|
34
|
+
client.get_loan_packages("0001179019", "STOCK", include_all="true")
|
|
35
|
+
|
|
36
|
+
def test_get_loans_builds_expected_request(self):
|
|
37
|
+
client = DNSEClient(
|
|
38
|
+
api_key="key",
|
|
39
|
+
api_secret="secret",
|
|
40
|
+
base_url="https://example.test",
|
|
41
|
+
)
|
|
42
|
+
captured = {}
|
|
43
|
+
|
|
44
|
+
def fake_request(method, path, query=None, **kwargs):
|
|
45
|
+
captured.update(method=method, path=path, query=query, kwargs=kwargs)
|
|
46
|
+
return 200, "{}"
|
|
47
|
+
|
|
48
|
+
client._request = fake_request
|
|
49
|
+
|
|
50
|
+
client.get_loans(
|
|
51
|
+
account_no="0001179019",
|
|
52
|
+
market_type="STOCK",
|
|
53
|
+
loan_status="DISBURSED",
|
|
54
|
+
disbursement_from="2026-06-01",
|
|
55
|
+
disbursement_to="2026-07-31",
|
|
56
|
+
due_date_from="2026-09-01",
|
|
57
|
+
due_date_to="2026-12-31",
|
|
58
|
+
position_id=9638,
|
|
59
|
+
page_index=2,
|
|
60
|
+
page_size=25,
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
self.assertEqual("GET", captured["method"])
|
|
64
|
+
self.assertEqual("/accounts/0001179019/loans", captured["path"])
|
|
65
|
+
self.assertEqual(
|
|
66
|
+
{
|
|
67
|
+
"marketType": "STOCK",
|
|
68
|
+
"loanStatus": "DISBURSED",
|
|
69
|
+
"disbursementFrom": "2026-06-01",
|
|
70
|
+
"disbursementTo": "2026-07-31",
|
|
71
|
+
"dueDateFrom": "2026-09-01",
|
|
72
|
+
"dueDateTo": "2026-12-31",
|
|
73
|
+
"positionId": 9638,
|
|
74
|
+
"pageIndex": 2,
|
|
75
|
+
"pageSize": 25,
|
|
76
|
+
},
|
|
77
|
+
captured["query"],
|
|
78
|
+
)
|
|
79
|
+
self.assertEqual({"dry_run": False}, captured["kwargs"])
|
|
80
|
+
|
|
81
|
+
def test_get_pnl_reports_builds_expected_request(self):
|
|
82
|
+
client = DNSEClient(api_key="key", api_secret="secret", base_url="https://example.test")
|
|
83
|
+
captured = {}
|
|
84
|
+
client._request = lambda method, path, query=None, **kwargs: captured.update(method=method, path=path, query=query, kwargs=kwargs) or (200, "{}")
|
|
85
|
+
client.get_pnl_reports("0001179019", "STOCK", "2026-01-01", "2026-01-31", symbol="ACB", page_index=1, page_size=25, loan_package_id=9)
|
|
86
|
+
self.assertEqual("GET", captured["method"])
|
|
87
|
+
self.assertEqual("/accounts/0001179019/pnl-reports", captured["path"])
|
|
88
|
+
self.assertEqual({"marketType":"STOCK", "fromDate":"2026-01-01", "toDate":"2026-01-31", "symbol":"ACB", "pageIndex":1, "pageSize":25, "loanPackageId":9}, captured["query"])
|
|
89
|
+
self.assertEqual({"version":"2026-01-01", "dry_run":False}, captured["kwargs"])
|
|
90
|
+
|
|
91
|
+
def test_get_corporate_actions_builds_expected_request(self):
|
|
92
|
+
client = DNSEClient(
|
|
93
|
+
api_key="key",
|
|
94
|
+
api_secret="secret",
|
|
95
|
+
base_url="https://example.test",
|
|
96
|
+
)
|
|
97
|
+
captured = {}
|
|
98
|
+
|
|
99
|
+
def fake_request(method, path, query=None, **kwargs):
|
|
100
|
+
captured.update(method=method, path=path, query=query, kwargs=kwargs)
|
|
101
|
+
return 200, "{}"
|
|
102
|
+
|
|
103
|
+
client._request = fake_request
|
|
104
|
+
|
|
105
|
+
client.get_corporate_actions(page=1, page_size=1000, time_range=30)
|
|
106
|
+
|
|
107
|
+
self.assertEqual("GET", captured["method"])
|
|
108
|
+
self.assertEqual("/market/corporate-actions", captured["path"])
|
|
109
|
+
self.assertEqual({"page": 1, "page_size": 1000, "time_range": 30}, captured["query"])
|
|
110
|
+
self.assertEqual(
|
|
111
|
+
{"version": None, "dry_run": False},
|
|
112
|
+
captured["kwargs"],
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
def test_get_corporate_actions_omits_unspecified_query(self):
|
|
116
|
+
client = DNSEClient(
|
|
117
|
+
api_key="key",
|
|
118
|
+
api_secret="secret",
|
|
119
|
+
base_url="https://example.test",
|
|
120
|
+
)
|
|
121
|
+
captured = {}
|
|
122
|
+
|
|
123
|
+
def fake_request(method, path, query=None, **kwargs):
|
|
124
|
+
captured.update(method=method, path=path, query=query, kwargs=kwargs)
|
|
125
|
+
return 200, "{}"
|
|
126
|
+
|
|
127
|
+
client._request = fake_request
|
|
128
|
+
|
|
129
|
+
client.get_corporate_actions()
|
|
130
|
+
|
|
131
|
+
self.assertEqual("GET", captured["method"])
|
|
132
|
+
self.assertEqual("/market/corporate-actions", captured["path"])
|
|
133
|
+
self.assertIsNone(captured["query"])
|
|
134
|
+
|
|
135
|
+
def test_get_loan_by_id_builds_expected_request(self):
|
|
136
|
+
client = DNSEClient(
|
|
137
|
+
api_key="key",
|
|
138
|
+
api_secret="secret",
|
|
139
|
+
base_url="https://example.test",
|
|
140
|
+
)
|
|
141
|
+
captured = {}
|
|
142
|
+
|
|
143
|
+
def fake_request(method, path, query=None, **kwargs):
|
|
144
|
+
captured.update(method=method, path=path, query=query, kwargs=kwargs)
|
|
145
|
+
return 200, "{}"
|
|
146
|
+
|
|
147
|
+
client._request = fake_request
|
|
148
|
+
|
|
149
|
+
client.get_loan_by_id(
|
|
150
|
+
account_no="0001179019",
|
|
151
|
+
loan_id=7588,
|
|
152
|
+
market_type="STOCK",
|
|
153
|
+
)
|
|
154
|
+
|
|
155
|
+
self.assertEqual("GET", captured["method"])
|
|
156
|
+
self.assertEqual("/accounts/0001179019/loans/7588", captured["path"])
|
|
157
|
+
self.assertEqual({"marketType": "STOCK"}, captured["query"])
|
|
158
|
+
self.assertEqual(
|
|
159
|
+
{"version": "2026-01-01", "dry_run": False},
|
|
160
|
+
captured["kwargs"],
|
|
161
|
+
)
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
if __name__ == "__main__":
|
|
165
|
+
unittest.main()
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import contextlib
|
|
2
|
+
import importlib.util
|
|
3
|
+
import io
|
|
4
|
+
import json
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
import sys
|
|
7
|
+
import unittest
|
|
8
|
+
from unittest.mock import patch
|
|
9
|
+
|
|
10
|
+
SDK_ROOT = Path(__file__).resolve().parents[1]
|
|
11
|
+
sys.path.insert(0, str(SDK_ROOT))
|
|
12
|
+
|
|
13
|
+
from dnse import DNSEClient
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class CorporateActionsClientTest(unittest.TestCase):
|
|
17
|
+
def test_response_and_error_are_returned_unchanged(self):
|
|
18
|
+
for status, body in [
|
|
19
|
+
(200, json.dumps({
|
|
20
|
+
"corporateActions": [{
|
|
21
|
+
"symbol": "ACG", "name": "Dividend", "exDate": "2026-10-15",
|
|
22
|
+
"recordDate": "2026-10-16", "processDate": "", "description": "Payment",
|
|
23
|
+
}],
|
|
24
|
+
"pagination": {"pageIndex": 1, "pageSize": 1000, "totalRecords": 65},
|
|
25
|
+
})),
|
|
26
|
+
(400, ' {"code": "INVALID_INPUT", "message": "bad query"}\n'),
|
|
27
|
+
]:
|
|
28
|
+
with self.subTest(status=status):
|
|
29
|
+
client = DNSEClient(api_key="key", api_secret="secret", base_url="https://example.test")
|
|
30
|
+
with patch.object(client, "_request", return_value=(status, body)) as request:
|
|
31
|
+
self.assertEqual((status, body), client.get_corporate_actions(
|
|
32
|
+
page=1, page_size=1000, time_range=30, version="2026-07-23",
|
|
33
|
+
))
|
|
34
|
+
request.assert_called_once_with(
|
|
35
|
+
"GET", "/market/corporate-actions",
|
|
36
|
+
query={"page": 1, "page_size": 1000, "time_range": 30},
|
|
37
|
+
version="2026-07-23", dry_run=False,
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
def test_example_prints_status_and_response_for_success_and_errors(self):
|
|
41
|
+
spec = importlib.util.spec_from_file_location(
|
|
42
|
+
"corporate_actions_example", SDK_ROOT / "marketdata-api/get_corporate_actions.py",
|
|
43
|
+
)
|
|
44
|
+
example = importlib.util.module_from_spec(spec)
|
|
45
|
+
spec.loader.exec_module(example)
|
|
46
|
+
for status, response in [
|
|
47
|
+
(200, {"corporateActions": [{
|
|
48
|
+
"symbol": "ACG", "name": "Dividend", "exDate": "2026-10-15",
|
|
49
|
+
"recordDate": "2026-10-16", "processDate": "", "description": "Payment",
|
|
50
|
+
}], "pagination": {"pageIndex": 1, "pageSize": 1000, "totalRecords": 65}}),
|
|
51
|
+
(400, {"message": "bad query"}),
|
|
52
|
+
(200, {"message": "upstream error"}),
|
|
53
|
+
]:
|
|
54
|
+
with self.subTest(status=status, response=response):
|
|
55
|
+
output = io.StringIO()
|
|
56
|
+
body = json.dumps(response)
|
|
57
|
+
with patch.object(example, "DNSEClient") as client, contextlib.redirect_stdout(output):
|
|
58
|
+
client.return_value.get_corporate_actions.return_value = status, body
|
|
59
|
+
example.main()
|
|
60
|
+
client.return_value.get_corporate_actions.assert_called_once_with(
|
|
61
|
+
page=1, page_size=1000, time_range=30, dry_run=False,
|
|
62
|
+
)
|
|
63
|
+
self.assertEqual(f"{status} {body}\n", output.getvalue())
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
if __name__ == "__main__":
|
|
67
|
+
unittest.main()
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
import os
|
|
3
|
+
import sys
|
|
4
|
+
import unittest
|
|
5
|
+
|
|
6
|
+
sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
|
|
7
|
+
|
|
8
|
+
from dnse import DNSEClient
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class LoanPackageDetailClientTest(unittest.TestCase):
|
|
12
|
+
def test_detail_uses_single_id_path_and_expected_query_and_version(self):
|
|
13
|
+
client = DNSEClient(api_key="key", api_secret="secret", base_url="https://example.test")
|
|
14
|
+
calls = []
|
|
15
|
+
|
|
16
|
+
def fake_request(method, path, **kwargs):
|
|
17
|
+
calls.append((method, path, kwargs))
|
|
18
|
+
return 200, '{"loanPackage":{"id":1769}}'
|
|
19
|
+
|
|
20
|
+
client._request = fake_request
|
|
21
|
+
result = client.get_loan_package_detail("0001179019", 1769, "STOCK", "ACB")
|
|
22
|
+
self.assertEqual((200, '{"loanPackage":{"id":1769}}'), result)
|
|
23
|
+
self.assertEqual([(
|
|
24
|
+
"GET", "/accounts/0001179019/loan-packages/1769",
|
|
25
|
+
{"query": {"marketType": "STOCK", "symbol": "ACB"},
|
|
26
|
+
"version": "2026-01-01", "dry_run": False},
|
|
27
|
+
)], calls)
|
|
28
|
+
|
|
29
|
+
client.get_loan_package_detail("0001179019", 2279, "DERIVATIVE", "VN30F1M", dry_run=True)
|
|
30
|
+
self.assertEqual("/accounts/0001179019/loan-packages/2279", calls[-1][1])
|
|
31
|
+
self.assertEqual({"marketType": "DERIVATIVE", "symbol": "VN30F1M"}, calls[-1][2]["query"])
|
|
32
|
+
self.assertTrue(calls[-1][2]["dry_run"])
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
if __name__ == "__main__":
|
|
36
|
+
unittest.main()
|