kaq-quant-common 0.1.85__py3-none-any.whl → 0.1.87__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.
@@ -9,13 +9,16 @@ from kaq_quant_common.api.rest.instruction.helper.order_helper import \
9
9
  from kaq_quant_common.api.rest.instruction.models import \
10
10
  InstructionResponseBase
11
11
  from kaq_quant_common.api.rest.instruction.models.account import (
12
- ContractBalanceRequest, ContractBalanceResponse)
12
+ AccountIncomeRequest, AccountIncomeResponse, ContractBalanceRequest,
13
+ ContractBalanceResponse)
13
14
  from kaq_quant_common.api.rest.instruction.models.order import (
14
15
  AllOpenOrdersRequest, AllOpenOrdersResponse, CancelOrderRequest,
15
16
  CancelOrderResponse, ChangeLeverageRequest, ChangeLeverageResponse,
16
17
  LimitOrderBookRequest, LimitOrderBookResponse, ModifyOrderRequest,
17
18
  ModifyOrderResponse, OrderRequest, OrderResponse, QuerySymbolConfigRequest,
18
19
  QuerySymbolConfigResponse)
20
+ from kaq_quant_common.api.rest.instruction.models.position import (
21
+ QueryOpenInterestRequest, QueryOpenInterestResponse)
19
22
  from kaq_quant_common.api.rest.instruction.models.transfer import (
20
23
  TransferRequest, TransferResponse)
21
24
  from kaq_quant_common.resources.kaq_mysql_resources import \
@@ -93,6 +96,16 @@ class InstructionServerBase(ApiServerBase, ApiInterface, ABC):
93
96
  @api_method(LimitOrderBookRequest, LimitOrderBookResponse)
94
97
  def get_limit_order(self, request: LimitOrderBookRequest) -> LimitOrderBookResponse:
95
98
  return self._on_get_limit_order(request)
99
+
100
+ # 查询账户损益资金流水
101
+ @api_method(AccountIncomeRequest, AccountIncomeResponse)
102
+ def get_account_income(self, request: AccountIncomeRequest) -> AccountIncomeResponse:
103
+ return self._on_get_account_income(request)
104
+
105
+ # 查询未平仓合约数量
106
+ @api_method(QueryOpenInterestRequest, QueryOpenInterestResponse)
107
+ def query_open_interest(self, request: QueryOpenInterestRequest) -> QueryOpenInterestResponse:
108
+ return self._on_query_open_interest(request)
96
109
 
97
110
  # ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ abstract methods
98
111
 
@@ -130,4 +143,12 @@ class InstructionServerBase(ApiServerBase, ApiInterface, ABC):
130
143
 
131
144
  @abstractmethod
132
145
  def _on_get_limit_order(self, request: LimitOrderBookRequest) -> LimitOrderBookResponse:
146
+ pass
147
+
148
+ @abstractmethod
149
+ def _on_get_account_income(self, request: AccountIncomeRequest) -> AccountIncomeResponse:
150
+ pass
151
+
152
+ @abstractmethod
153
+ def _on_query_open_interest(self, request: QueryOpenInterestRequest) -> QueryOpenInterestResponse:
133
154
  pass
@@ -1,3 +1,4 @@
1
+ from enum import Enum
1
2
  from typing import Optional
2
3
 
3
4
  from pydantic import BaseModel
@@ -22,3 +23,27 @@ class ContractBalanceRequest(InstructionRequestBase):
22
23
  class ContractBalanceResponse(InstructionResponseBase):
23
24
  #
24
25
  assets: list[AssetsInfo]
26
+
27
+
28
+ # ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ 查询账户损益资金流水
29
+ class AccountIncomeInfo(BaseModel):
30
+ symbol: str
31
+ incomeType: int
32
+ income: float
33
+ time: int
34
+ subType: Optional[str] = None
35
+
36
+
37
+ class AccountIncomeRequest(InstructionRequestBase):
38
+ # 交易对
39
+ symbol: Optional[str] = None
40
+ # 收益类型
41
+ incomeType: Optional[int] = None
42
+ # 起始时间
43
+ startTime: Optional[int] = None
44
+ # 结束时间
45
+ endTime: Optional[int] = None
46
+
47
+
48
+ class AccountIncomeResponse(InstructionResponseBase):
49
+ income_list: list[AccountIncomeInfo]
@@ -54,3 +54,17 @@ class QueryPositionRequest(InstructionRequestBase):
54
54
  class QueryPositionResponse(InstructionResponseBase):
55
55
  #
56
56
  positions: list[PositionInfo]
57
+
58
+
59
+ # ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ 查询未平仓合约数
60
+ class QueryOpenInterestRequest(InstructionRequestBase):
61
+ # 交易对
62
+ symbol: str
63
+
64
+ class QueryOpenInterestResponse(InstructionResponseBase):
65
+ # 交易对
66
+ symbol: str
67
+ # 未平仓合约数量(币)
68
+ open_interest: float
69
+ # 时间
70
+ time: int
@@ -2,7 +2,7 @@ import os
2
2
  import threading
3
3
  import time
4
4
  import traceback
5
- from datetime import datetime
5
+ import datetime
6
6
 
7
7
  import numpy as np
8
8
  import pandas as pd
@@ -102,8 +102,13 @@ class KaqQuantMysqlRepository:
102
102
  # 从连接池获取连接
103
103
  session = self.session_maker()
104
104
  try:
105
- time_str = time.strftime("%Y_%m_%d_%H_%M", time.localtime(time.time()))
106
- sql = f"RENAME TABLE {table_name} TO {table_name}_{time_str};"
105
+ # 1. 计算上周一的日期字符串
106
+ today = datetime.date.today()
107
+ # 2. 先计算本周一,再减去 7 天
108
+ last_monday = today - datetime.timedelta(days=today.weekday(), weeks=1)
109
+ # 3. 格式化
110
+ last_monday_str = last_monday.strftime('%Y%m%d')
111
+ sql = f"RENAME TABLE {table_name} TO {table_name}_{last_monday_str};"
107
112
  session.execute(text(sql))
108
113
  return True
109
114
  except Exception as e:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: kaq_quant_common
3
- Version: 0.1.85
3
+ Version: 0.1.87
4
4
  Summary:
5
5
  Author: kevinfuture
6
6
  Author-email: liuenbofuture@foxmail.com
@@ -8,11 +8,11 @@ kaq_quant_common/api/rest/api_client_base.py,sha256=LYpqjjVGbVRVyP8qdmlgMelUtEY-
8
8
  kaq_quant_common/api/rest/api_server_base.py,sha256=URrvzerHIE6XQLERYFcFH1ftLbCYTz3sENAxFD0HWY0,4653
9
9
  kaq_quant_common/api/rest/instruction/helper/order_helper.py,sha256=q2opRLHrysvgqoFpAC70WNQpFJsbviHqjRldXj6tiMY,12267
10
10
  kaq_quant_common/api/rest/instruction/instruction_client.py,sha256=CI5RidyBN51qxq3NKNMIJGs3boCIt-EYN5bnn12ywIo,3489
11
- kaq_quant_common/api/rest/instruction/instruction_server_base.py,sha256=uKE0O_x3hC3595YCFbIZ2CDnmsk6V7b0dQ4J-5lvbI0,5279
11
+ kaq_quant_common/api/rest/instruction/instruction_server_base.py,sha256=pq1wghAlgtm10aWz70-x1OAqtoRH3lBu-HsIuVRHkqY,6223
12
12
  kaq_quant_common/api/rest/instruction/models/__init__.py,sha256=fx5pnfcf9L5KvAqhsQBZkl9fUf9oABuroLGZqDNycpc,312
13
- kaq_quant_common/api/rest/instruction/models/account.py,sha256=3rdsEnEqaHWjQ3yHMZ4pOupfHqHMRZ_W5kxIxuRQoac,632
13
+ kaq_quant_common/api/rest/instruction/models/account.py,sha256=Lj12EvWNxEt7k9dAKSsFhTJDmLX553duMRa5NroJW30,1375
14
14
  kaq_quant_common/api/rest/instruction/models/order.py,sha256=F941DPXlbsklpc8jHLaJ2nQZiUmjPt0zyL_bagijSzI,6847
15
- kaq_quant_common/api/rest/instruction/models/position.py,sha256=PGyZg_z4ZIB09BWl1uRtmePz8T3mzgrHSgpdN0ZKRzA,1268
15
+ kaq_quant_common/api/rest/instruction/models/position.py,sha256=OqtfWWcpGhbijJbwJqERkeFxPiIkzdBnhPx5CfXj8W0,1744
16
16
  kaq_quant_common/api/rest/instruction/models/transfer.py,sha256=htjk4hb9THUZP4REW5gtyPdo850jHPtHPWFLPA2ERzo,775
17
17
  kaq_quant_common/api/ws/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
18
  kaq_quant_common/api/ws/exchange/models.py,sha256=RPD5cDRQyISguTjO5Si1V5hJza8Uyr4u2EZEHNFtLb8,664
@@ -43,7 +43,7 @@ kaq_quant_common/resources/kaq_ddb_stream_init_resources.py,sha256=0FY0cmqedrLSY
43
43
  kaq_quant_common/resources/kaq_ddb_stream_read_resources.py,sha256=yqeruZELmxAKjVsdnZ7ieAeV3Wt7KpFYJdt8Vn_Y_qA,3163
44
44
  kaq_quant_common/resources/kaq_ddb_stream_write_resources.py,sha256=pebBaDypkY6Mn--Od5Wh1_ZfHewbQH3ce_JsfiWsyl4,4139
45
45
  kaq_quant_common/resources/kaq_mysql_init_resources.py,sha256=UcqWey6LgoMqvLq1SxK33nS6-rkViGYhzUPxcrucOks,827
46
- kaq_quant_common/resources/kaq_mysql_resources.py,sha256=j-rvzWs_AMCijj2H_4IPLXFVzS0BTb3x2qVfak7O_lA,13224
46
+ kaq_quant_common/resources/kaq_mysql_resources.py,sha256=UYBFn-o_fFaNwG6bT2E7CYdsns82EmR4ve2XgC9wFJw,13452
47
47
  kaq_quant_common/resources/kaq_postgresql_resources.py,sha256=iG1eYkciI0xUIBdEpGqKGOLBFxvVrfbBoTuaOmhQ0v0,1762
48
48
  kaq_quant_common/resources/kaq_quant_hive_resources.py,sha256=r114aeRzWkp6ReFPOkNOImY4o3AFQNomdVkivdOD13Y,3438
49
49
  kaq_quant_common/resources/kaq_redis_resources.py,sha256=MFBdl0v6ehbtUVhQw0XzH_DmpxNTfjWqlOG210NWYAo,4480
@@ -61,6 +61,6 @@ kaq_quant_common/utils/signal_utils.py,sha256=zBSyEltNTKqkQCsrETd47kEBb3Q_OWUBUn
61
61
  kaq_quant_common/utils/sqlite_utils.py,sha256=UDDFKfwL0N-jFifl40HdyOCENh2YQfW5so6hRaSJpv0,5722
62
62
  kaq_quant_common/utils/uuid_utils.py,sha256=pm_pnXpd8n9CI66x3A20cOEUiriJyqHaKGCeLrgkBxU,71
63
63
  kaq_quant_common/utils/yml_utils.py,sha256=gcKjb_-uuUajBGAl5QBPIZTg2wXm7qeeJvtHflj_zOE,4513
64
- kaq_quant_common-0.1.85.dist-info/METADATA,sha256=VNPjNY7SWi_wUJxYNOWGOr9zGBDeg2QW7_KO7pdeH-4,1971
65
- kaq_quant_common-0.1.85.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
66
- kaq_quant_common-0.1.85.dist-info/RECORD,,
64
+ kaq_quant_common-0.1.87.dist-info/METADATA,sha256=7KulEJup2yRnNfueQSSHIWho0V7p457sRCur6WeJxh0,1971
65
+ kaq_quant_common-0.1.87.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
66
+ kaq_quant_common-0.1.87.dist-info/RECORD,,