|
6 | 6 | """ |
7 | 7 | import logging |
8 | 8 |
|
9 | | -from tigeropen.common.consts import THREAD_LOCAL, SecurityType, Market, Currency, Language, OPEN_API_SERVICE_VERSION_V3 |
| 9 | +from tigeropen.common.consts import THREAD_LOCAL, SecurityType, Market, Currency, Language, OPEN_API_SERVICE_VERSION_V3, \ |
| 10 | + SegmentType |
10 | 11 | from tigeropen.common.consts.service_types import CONTRACTS, ACCOUNTS, POSITIONS, ASSETS, ORDERS, ORDER_NO, \ |
11 | 12 | CANCEL_ORDER, MODIFY_ORDER, PLACE_ORDER, ACTIVE_ORDERS, INACTIVE_ORDERS, FILLED_ORDERS, CONTRACT, PREVIEW_ORDER, \ |
12 | | - PRIME_ASSETS, ORDER_TRANSACTIONS, QUOTE_CONTRACT, ANALYTICS_ASSET, SEGMENT_FUND_AVAILABLE, SEGMENT_FUND_HISTORY, TRANSFER_FUND, \ |
13 | | - TRANSFER_SEGMENT_FUND, CANCEL_SEGMENT_FUND, PLACE_FOREX_ORDER, ESTIMATE_TRADABLE_QUANTITY |
| 13 | + PRIME_ASSETS, ORDER_TRANSACTIONS, QUOTE_CONTRACT, ANALYTICS_ASSET, SEGMENT_FUND_AVAILABLE, SEGMENT_FUND_HISTORY, \ |
| 14 | + TRANSFER_FUND, \ |
| 15 | + TRANSFER_SEGMENT_FUND, CANCEL_SEGMENT_FUND, PLACE_FOREX_ORDER, ESTIMATE_TRADABLE_QUANTITY, AGGREGATE_ASSETS |
14 | 16 | from tigeropen.common.exceptions import ApiException |
15 | 17 | from tigeropen.common.util.common_utils import get_enum_value, date_str_to_timestamp |
16 | 18 | from tigeropen.common.request import OpenApiRequest |
|
19 | 21 | from tigeropen.trade.domain.order import Order |
20 | 22 | from tigeropen.trade.request.model import ContractParams, AccountsParams, AssetParams, PositionParams, OrdersParams, \ |
21 | 23 | OrderParams, PlaceModifyOrderParams, CancelOrderParams, TransactionsParams, AnalyticsAssetParams, SegmentFundParams, \ |
22 | | - ForexTradeOrderParams, EstimateTradableQuantityModel, FundingHistoryParams |
| 24 | + ForexTradeOrderParams, EstimateTradableQuantityModel, FundingHistoryParams, AggregateAssetParams |
23 | 25 | from tigeropen.trade.response.account_profile_response import ProfilesResponse |
| 26 | +from tigeropen.trade.response.aggregate_assets_response import AggregateAssetsResponse |
24 | 27 | from tigeropen.trade.response.analytics_asset_response import AnalyticsAssetResponse |
25 | 28 | from tigeropen.trade.response.assets_response import AssetsResponse |
26 | 29 | from tigeropen.trade.response.contracts_response import ContractsResponse |
@@ -316,6 +319,23 @@ def get_prime_assets(self, account=None, base_currency=None, consolidated=True): |
316 | 319 | raise ApiException(response.code, response.message) |
317 | 320 | return None |
318 | 321 |
|
| 322 | + def get_aggregate_assets(self, account=None, seg_type=SegmentType.SEC, base_currency=None): |
| 323 | + params = AggregateAssetParams() |
| 324 | + params.account = account if account else self._account |
| 325 | + params.secret_key = self._secret_key |
| 326 | + params.lang = get_enum_value(self._lang) |
| 327 | + params.base_currency = get_enum_value(base_currency) |
| 328 | + params.seg_type = get_enum_value(seg_type) |
| 329 | + request = OpenApiRequest(AGGREGATE_ASSETS, biz_model=params) |
| 330 | + response_content = self.__fetch_data(request) |
| 331 | + if response_content: |
| 332 | + response = AggregateAssetsResponse() |
| 333 | + response.parse_response_content(response_content) |
| 334 | + if response.is_success(): |
| 335 | + return response.result |
| 336 | + else: |
| 337 | + raise ApiException(response.code, response.message) |
| 338 | + |
319 | 339 | def get_orders(self, account=None, sec_type=None, market=Market.ALL, symbol=None, start_time=None, end_time=None, |
320 | 340 | limit=100, is_brief=False, states=None, sort_by=None, seg_type=None): |
321 | 341 | """ |
|
0 commit comments