|
9 | 9 | from tigeropen.common.consts import THREAD_LOCAL, SecurityType, Market, Currency |
10 | 10 | from tigeropen.common.consts.service_types import CONTRACTS, ACCOUNTS, POSITIONS, ASSETS, ORDERS, ORDER_NO, \ |
11 | 11 | CANCEL_ORDER, MODIFY_ORDER, PLACE_ORDER, ACTIVE_ORDERS, INACTIVE_ORDERS, FILLED_ORDERS, CONTRACT, PREVIEW_ORDER, \ |
12 | | - PRIME_ASSETS, ORDER_TRANSACTIONS, QUOTE_CONTRACT |
| 12 | + PRIME_ASSETS, ORDER_TRANSACTIONS, QUOTE_CONTRACT, ANALYTICS_ASSET |
13 | 13 | from tigeropen.common.exceptions import ApiException |
14 | 14 | from tigeropen.common.util.common_utils import get_enum_value |
15 | 15 | from tigeropen.common.request import OpenApiRequest |
16 | 16 | from tigeropen.tiger_open_client import TigerOpenClient |
17 | 17 | from tigeropen.trade.domain.order import Order |
18 | 18 | from tigeropen.trade.request.model import ContractParams, AccountsParams, AssetParams, PositionParams, OrdersParams, \ |
19 | | - OrderParams, PlaceModifyOrderParams, CancelOrderParams, TransactionsParams |
| 19 | + OrderParams, PlaceModifyOrderParams, CancelOrderParams, TransactionsParams, AnalyticsAssetParams |
20 | 20 | from tigeropen.trade.response.account_profile_response import ProfilesResponse |
| 21 | +from tigeropen.trade.response.analytics_asset_response import AnalyticsAssetResponse |
21 | 22 | from tigeropen.trade.response.assets_response import AssetsResponse |
22 | 23 | from tigeropen.trade.response.contracts_response import ContractsResponse |
23 | 24 | from tigeropen.trade.response.order_id_response import OrderIdResponse |
@@ -662,6 +663,37 @@ def get_transactions(self, account=None, order_id=None, symbol=None, sec_type=No |
662 | 663 | raise ApiException(response.code, response.message) |
663 | 664 | return None |
664 | 665 |
|
| 666 | + def get_analytics_asset(self, account=None, start_date=None, end_date=None, seg_type=None, currency=None, |
| 667 | + sub_account=None): |
| 668 | + """ |
| 669 | + get analytics of history asset |
| 670 | + :param account: |
| 671 | + :param start_date: |
| 672 | + :param end_date: |
| 673 | + :param seg_type: tigeropen.common.consts.SegmentType, like SegmentType.SEC |
| 674 | + :param currency: tigeropen.common.consts.Currency, like Currency.USD |
| 675 | + :param sub_account: sub account of institution account |
| 676 | + :return: |
| 677 | + """ |
| 678 | + params = AnalyticsAssetParams() |
| 679 | + params.account = account if account else self._account |
| 680 | + params.secret_key = self._secret_key |
| 681 | + params.seg_type = get_enum_value(seg_type) |
| 682 | + params.start_date = start_date |
| 683 | + params.end_date = end_date |
| 684 | + params.currency = get_enum_value(currency) |
| 685 | + params.sub_account = sub_account |
| 686 | + request = OpenApiRequest(ANALYTICS_ASSET, biz_model=params) |
| 687 | + response_content = self.__fetch_data(request) |
| 688 | + if response_content: |
| 689 | + response = AnalyticsAssetResponse() |
| 690 | + response.parse_response_content(response_content) |
| 691 | + if response.is_success(): |
| 692 | + return response.result |
| 693 | + else: |
| 694 | + raise ApiException(response.code, response.message) |
| 695 | + return None |
| 696 | + |
665 | 697 | def __fetch_data(self, request): |
666 | 698 | try: |
667 | 699 | response = super(TradeClient, self).execute(request) |
|
0 commit comments