Skip to content

Commit 73dc941

Browse files
shinny-packshinny-mayanqiong
authored andcommitted
Update Version 3.5.2
1 parent 873f19d commit 73dc941

File tree

10 files changed

+140
-20
lines changed

10 files changed

+140
-20
lines changed

PKG-INFO

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Metadata-Version: 2.1
22
Name: tqsdk
3-
Version: 3.5.1
3+
Version: 3.5.2
44
Summary: TianQin SDK
55
Home-page: https://www.shinnytech.com/tqsdk
66
Author: TianQin

doc/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@
4848
# built documents.
4949
#
5050
# The short X.Y version.
51-
version = u'3.5.1'
51+
version = u'3.5.2'
5252
# The full version, including alpha/beta/rc tags.
53-
release = u'3.5.1'
53+
release = u'3.5.2'
5454

5555
# The language for content autogenerated by Sphinx. Refer to documentation
5656
# for a list of supported languages.

doc/version.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
版本变更
44
=============================
5+
3.5.2 (2024/02/07)
6+
7+
* 新增::py:class:`~tqsdk.objs.Quote` 增加以下属性
8+
:py:meth:`~tqsdk.objs.Quote.open_max_market_order_volume`、:py:meth:`~tqsdk.objs.Quote.open_max_limit_order_volume`、
9+
:py:meth:`~tqsdk.objs.Quote.open_min_market_order_volume`、:py:meth:`~tqsdk.objs.Quote.open_min_limit_order_volume`、
10+
:py:meth:`~tqsdk.objs.Quote.categories`
11+
12+
513
3.5.1 (2024/01/24)
614

715
* 修复::py:meth:`~tqsdk.TqApi.query_his_cont_quotes` 接口在 3.4.11、3.5.0 版本上报错的问题

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
setuptools.setup(
1010
name='tqsdk',
11-
version="3.5.1",
11+
version="3.5.2",
1212
description='TianQin SDK',
1313
author='TianQin',
1414
author_email='tianqincn@gmail.com',

tqsdk/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '3.5.1'
1+
__version__ = '3.5.2'

tqsdk/api.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3341,7 +3341,12 @@ def _init_serial(self, root_list, width, default, adj_type):
33413341
values = serial["array"].T
33423342
block = FloatBlock(values=values, ndim=2, placement=BlockPlacement(slice(0, len(columns))))
33433343
bm = BlockManagerUnconsolidated(blocks=[block], axes=[columns, index])
3344-
serial["df"] = TqDataFrame(self, bm, copy=False)
3344+
# DeprecationWarning:
3345+
# Passing a BlockManagerUnconsolidated to TqDataFrame is deprecated and will raise in a future version.
3346+
# Use an empty dataframe instead.
3347+
temp_df = pd.DataFrame()
3348+
temp_df._mgr = bm
3349+
serial["df"] = TqDataFrame(self, temp_df, copy=False)
33453350
serial["df"]["symbol"] = root_list[0]["_path"][1]
33463351
for i in range(1, len(root_list)):
33473352
serial["df"]["symbol" + str(i)] = root_list[i]["_path"][1]

tqsdk/calendar.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,7 @@ def _get_trading_calendar(start_dt: date, end_dt: date, headers=None):
4747
_init_chinese_rest_days(headers=headers)
4848
df = pd.DataFrame()
4949
df['date'] = pd.Series(pd.date_range(start=start_dt, end=end_dt, freq="D"))
50-
df['trading'] = df['date'].dt.dayofweek.lt(5)
51-
result = pd.merge(rest_days_df, df, sort=True, how="right", on="date")
52-
result.fillna(True, inplace=True)
53-
df['trading'] = result['trading'] & result['trading_restdays']
50+
df['trading'] = df['date'].dt.dayofweek.lt(5) & ~df['date'].isin(rest_days_df['date'])
5451
return df
5552

5653

tqsdk/ins_schema.py

Lines changed: 77 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@
1414
########################################################################
1515
Boolean = sgqlc.types.Boolean
1616

17+
18+
class Category(sgqlc.types.Enum):
19+
__schema__ = ins_schema
20+
__choices__ = ('AGRICULTURAL', 'CHEMICAL', 'COAL', 'EQUITY_INDEX', 'FERROUS', 'GRAIN', 'GREASE', 'LIGHT_INDUSTRY', 'NONFERROUS_METALS', 'OIL', 'PRECIOUS_METALS', 'SOFT_COMMODITY', 'TREASURY_BOND')
21+
22+
1723
class Class(sgqlc.types.Enum):
1824
__schema__ = ins_schema
1925
__choices__ = ('BOND', 'COMBINE', 'CONT', 'FUND', 'FUTURE', 'INDEX', 'OPTION', 'SPOT', 'STOCK')
@@ -39,11 +45,12 @@ class Int64(sgqlc.types.Scalar):
3945
########################################################################
4046
class basic(sgqlc.types.Interface):
4147
__schema__ = ins_schema
42-
__field_names__ = ('price_tick', 'derivatives', 'trading_time', 'trading_day', 'instrument_name', 'english_name', 'price_decs', 'class_', 'instrument_id', 'exchange_id', 'derivative')
48+
__field_names__ = ('trading_time', 'instrument_name', 'instrument_id', 'derivative', 'ins_id', 'derivatives', 'exchange_id', 'instrument_name_wh', 'trading_day', 'english_name', 'price_decs', 'class_', 'py_wh', 'price_tick')
4349
price_tick = sgqlc.types.Field(Float, graphql_name='price_tick')
4450
derivatives = sgqlc.types.Field('derivativeConnection', graphql_name='derivatives', args=sgqlc.types.ArgDict((
4551
('class_', sgqlc.types.Arg(sgqlc.types.list_of(Class), graphql_name='class', default=None)),
4652
('exchange_id', sgqlc.types.Arg(sgqlc.types.list_of(String), graphql_name='exchange_id', default=None)),
53+
('expired', sgqlc.types.Arg(Boolean, graphql_name='expired', default=None)),
4754
('timestamp', sgqlc.types.Arg(Int64, graphql_name='timestamp', default=None)),
4855
))
4956
)
@@ -55,13 +62,17 @@ class basic(sgqlc.types.Interface):
5562
class_ = sgqlc.types.Field(String, graphql_name='class')
5663
instrument_id = sgqlc.types.Field(String, graphql_name='instrument_id')
5764
exchange_id = sgqlc.types.Field(String, graphql_name='exchange_id')
65+
ins_id = sgqlc.types.Field(String, graphql_name='ins_id')
66+
instrument_name_wh = sgqlc.types.Field(String, graphql_name='instrument_name_wh')
67+
py_wh = sgqlc.types.Field(String, graphql_name='py_wh')
68+
price_tick = sgqlc.types.Field(Float, graphql_name='price_tick')
5869
derivative = sgqlc.types.Field('derivativeConnection', graphql_name='derivative', args=sgqlc.types.ArgDict((
5970
('class_', sgqlc.types.Arg(Class, graphql_name='class', default=None)),
6071
('exchange_id', sgqlc.types.Arg(String, graphql_name='exchange_id', default=None)),
72+
('expired', sgqlc.types.Arg(Boolean, graphql_name='expired', default=None)),
6173
))
6274
)
6375

64-
6576
class derivative(sgqlc.types.Interface):
6677
__schema__ = ins_schema
6778
__field_names__ = ('underlying',)
@@ -94,6 +105,7 @@ class rootQuery(sgqlc.types.Type):
94105
('expired', sgqlc.types.Arg(Boolean, graphql_name='expired', default=None)),
95106
('has_night', sgqlc.types.Arg(Boolean, graphql_name='has_night', default=None)),
96107
('has_derivatives', sgqlc.types.Arg(Boolean, graphql_name='has_derivatives', default=None)),
108+
('categories', sgqlc.types.Arg(sgqlc.types.list_of(Category), graphql_name='categories', default=None)),
97109
))
98110
)
99111
symbol_info = sgqlc.types.Field(sgqlc.types.list_of('allClassUnion'), graphql_name='symbol_info', args=sgqlc.types.ArgDict((
@@ -110,7 +122,7 @@ class rootQuery(sgqlc.types.Type):
110122

111123
class securities(sgqlc.types.Interface):
112124
__schema__ = ins_schema
113-
__field_names__ = ('status', 'public_float_share_quantity', 'currency', 'face_value', 'first_trading_day', 'first_trading_datetime', 'buy_volume_unit', 'sell_volume_unit')
125+
__field_names__ = ('currency', 'face_value', 'first_trading_day', 'first_trading_datetime', 'buy_volume_unit', 'sell_volume_unit', 'status', 'public_float_share_quantity')
114126
status = sgqlc.types.Field(String, graphql_name='status')
115127
public_float_share_quantity = sgqlc.types.Field(Int64, graphql_name='public_float_share_quantity')
116128
currency = sgqlc.types.Field(String, graphql_name='currency')
@@ -123,14 +135,21 @@ class securities(sgqlc.types.Interface):
123135

124136
class tradeable(sgqlc.types.Interface):
125137
__schema__ = ins_schema
126-
__field_names__ = ('quote_multiple', 'pre_close', 'upper_limit', 'lower_limit', 'volume_multiple')
138+
__field_names__ = ('volume_multiple', 'quote_multiple', 'pre_close', 'upper_limit', 'lower_limit')
127139
quote_multiple = sgqlc.types.Field(Float, graphql_name='quote_multiple')
128140
pre_close = sgqlc.types.Field(Float, graphql_name='pre_close')
129141
upper_limit = sgqlc.types.Field(Float, graphql_name='upper_limit')
130142
lower_limit = sgqlc.types.Field(Float, graphql_name='lower_limit')
131143
volume_multiple = sgqlc.types.Field(Float, graphql_name='volume_multiple')
132144

133145

146+
class categoryInfo(sgqlc.types.Type):
147+
__schema__ = ins_schema
148+
__field_names__ = ('id', 'name')
149+
id = sgqlc.types.Field(String, graphql_name='id')
150+
name = sgqlc.types.Field(String, graphql_name='name')
151+
152+
134153
class tradingTime(sgqlc.types.Type):
135154
__schema__ = ins_schema
136155
__field_names__ = ('day', 'night')
@@ -147,13 +166,23 @@ class bond(sgqlc.types.Type, basic, tradeable, securities):
147166

148167
class combine(sgqlc.types.Type, basic):
149168
__schema__ = ins_schema
150-
__field_names__ = ('expire_datetime', 'expired', 'leg1', 'leg2', 'max_limit_order_volume', 'max_market_order_volume', 'product_id')
169+
__field_names__ = ('close_max_limit_order_volume', 'close_max_market_order_volume', 'close_min_limit_order_volume', 'close_min_market_order_volume', 'expire_datetime', 'expired', 'leg1', 'leg2', 'max_limit_order_volume', 'max_market_order_volume', 'min_limit_order_volume', 'min_market_order_volume', 'open_max_limit_order_volume', 'open_max_market_order_volume', 'open_min_limit_order_volume', 'open_min_market_order_volume', 'product_id')
170+
close_max_limit_order_volume = sgqlc.types.Field(Int, graphql_name='close_max_limit_order_volume')
171+
close_max_market_order_volume = sgqlc.types.Field(Int, graphql_name='close_max_market_order_volume')
172+
close_min_limit_order_volume = sgqlc.types.Field(Int, graphql_name='close_min_limit_order_volume')
173+
close_min_market_order_volume = sgqlc.types.Field(Int, graphql_name='close_min_market_order_volume')
151174
expire_datetime = sgqlc.types.Field(Int64, graphql_name='expire_datetime')
152175
expired = sgqlc.types.Field(Boolean, graphql_name='expired')
153176
leg1 = sgqlc.types.Field('allClassUnion', graphql_name='leg1')
154177
leg2 = sgqlc.types.Field('allClassUnion', graphql_name='leg2')
155178
max_limit_order_volume = sgqlc.types.Field(Int, graphql_name='max_limit_order_volume')
156179
max_market_order_volume = sgqlc.types.Field(Int, graphql_name='max_market_order_volume')
180+
min_limit_order_volume = sgqlc.types.Field(Int, graphql_name='min_limit_order_volume')
181+
min_market_order_volume = sgqlc.types.Field(Int, graphql_name='min_market_order_volume')
182+
open_max_limit_order_volume = sgqlc.types.Field(Int, graphql_name='open_max_limit_order_volume')
183+
open_max_market_order_volume = sgqlc.types.Field(Int, graphql_name='open_max_market_order_volume')
184+
open_min_limit_order_volume = sgqlc.types.Field(Int, graphql_name='open_min_limit_order_volume')
185+
open_min_market_order_volume = sgqlc.types.Field(Int, graphql_name='open_min_market_order_volume')
157186
product_id = sgqlc.types.Field(String, graphql_name='product_id')
158187

159188

@@ -170,7 +199,12 @@ class fund(sgqlc.types.Type, basic, tradeable, securities):
170199

171200
class future(sgqlc.types.Type, basic, tradeable):
172201
__schema__ = ins_schema
173-
__field_names__ = ('commission', 'delivery_month', 'delivery_year', 'expire_datetime', 'expired', 'margin', 'max_limit_order_volume', 'max_market_order_volume', 'mmsa', 'pre_open_interest', 'product_id', 'product_short_name', 'settlement_price')
202+
__field_names__ = ('categories', 'close_max_limit_order_volume', 'close_max_market_order_volume', 'close_min_limit_order_volume', 'close_min_market_order_volume', 'commission', 'delivery_month', 'delivery_year', 'expire_datetime', 'expired', 'margin', 'max_limit_order_volume', 'max_market_order_volume', 'min_limit_order_volume', 'min_market_order_volume', 'mmsa', 'open_max_limit_order_volume', 'open_max_market_order_volume', 'open_min_limit_order_volume', 'open_min_market_order_volume', 'pre_open_interest', 'product_id', 'product_short_name', 'product_short_name_wh', 'settlement_price')
203+
categories = sgqlc.types.Field(sgqlc.types.list_of(categoryInfo), graphql_name='categories')
204+
close_max_limit_order_volume = sgqlc.types.Field(Int, graphql_name='close_max_limit_order_volume')
205+
close_max_market_order_volume = sgqlc.types.Field(Int, graphql_name='close_max_market_order_volume')
206+
close_min_limit_order_volume = sgqlc.types.Field(Int, graphql_name='close_min_limit_order_volume')
207+
close_min_market_order_volume = sgqlc.types.Field(Int, graphql_name='close_min_market_order_volume')
174208
commission = sgqlc.types.Field(Float, graphql_name='commission')
175209
delivery_month = sgqlc.types.Field(Int, graphql_name='delivery_month')
176210
delivery_year = sgqlc.types.Field(Int, graphql_name='delivery_year')
@@ -179,10 +213,17 @@ class future(sgqlc.types.Type, basic, tradeable):
179213
margin = sgqlc.types.Field(Float, graphql_name='margin')
180214
max_limit_order_volume = sgqlc.types.Field(Int, graphql_name='max_limit_order_volume')
181215
max_market_order_volume = sgqlc.types.Field(Int, graphql_name='max_market_order_volume')
216+
min_limit_order_volume = sgqlc.types.Field(Int, graphql_name='min_limit_order_volume')
217+
min_market_order_volume = sgqlc.types.Field(Int, graphql_name='min_market_order_volume')
182218
mmsa = sgqlc.types.Field(Boolean, graphql_name='mmsa')
219+
open_max_limit_order_volume = sgqlc.types.Field(Int, graphql_name='open_max_limit_order_volume')
220+
open_max_market_order_volume = sgqlc.types.Field(Int, graphql_name='open_max_market_order_volume')
221+
open_min_limit_order_volume = sgqlc.types.Field(Int, graphql_name='open_min_limit_order_volume')
222+
open_min_market_order_volume = sgqlc.types.Field(Int, graphql_name='open_min_market_order_volume')
183223
pre_open_interest = sgqlc.types.Field(Int64, graphql_name='pre_open_interest')
184224
product_id = sgqlc.types.Field(String, graphql_name='product_id')
185225
product_short_name = sgqlc.types.Field(String, graphql_name='product_short_name')
226+
product_short_name_wh = sgqlc.types.Field(String, graphql_name='product_short_name_wh')
186227
settlement_price = sgqlc.types.Field(Float, graphql_name='settlement_price')
187228

188229

@@ -194,15 +235,25 @@ class index(sgqlc.types.Type, basic):
194235

195236
class option(sgqlc.types.Type, basic, tradeable, derivative):
196237
__schema__ = ins_schema
197-
__field_names__ = ('call_or_put', 'exercise_type', 'expire_datetime', 'expired', 'last_exercise_datetime', 'last_exercise_day', 'max_limit_order_volume', 'max_market_order_volume', 'pre_open_interest', 'product_short_name', 'settlement_price', 'strike_price')
238+
__field_names__ = ('call_or_put', 'close_max_limit_order_volume', 'close_max_market_order_volume', 'close_min_limit_order_volume', 'close_min_market_order_volume', 'exercise_type', 'expire_datetime', 'expired', 'last_exercise_datetime', 'last_exercise_day', 'max_limit_order_volume', 'max_market_order_volume', 'min_limit_order_volume', 'min_market_order_volume', 'open_max_limit_order_volume', 'open_max_market_order_volume', 'open_min_limit_order_volume', 'open_min_market_order_volume', 'pre_open_interest', 'product_short_name', 'settlement_price', 'strike_price')
198239
call_or_put = sgqlc.types.Field(String, graphql_name='call_or_put')
240+
close_max_limit_order_volume = sgqlc.types.Field(Int, graphql_name='close_max_limit_order_volume')
241+
close_max_market_order_volume = sgqlc.types.Field(Int, graphql_name='close_max_market_order_volume')
242+
close_min_limit_order_volume = sgqlc.types.Field(Int, graphql_name='close_min_limit_order_volume')
243+
close_min_market_order_volume = sgqlc.types.Field(Int, graphql_name='close_min_market_order_volume')
199244
exercise_type = sgqlc.types.Field(String, graphql_name='exercise_type')
200245
expire_datetime = sgqlc.types.Field(Int64, graphql_name='expire_datetime')
201246
expired = sgqlc.types.Field(Boolean, graphql_name='expired')
202247
last_exercise_datetime = sgqlc.types.Field(Int64, graphql_name='last_exercise_datetime')
203248
last_exercise_day = sgqlc.types.Field(Int64, graphql_name='last_exercise_day')
204249
max_limit_order_volume = sgqlc.types.Field(Int, graphql_name='max_limit_order_volume')
205250
max_market_order_volume = sgqlc.types.Field(Int, graphql_name='max_market_order_volume')
251+
min_limit_order_volume = sgqlc.types.Field(Int, graphql_name='min_limit_order_volume')
252+
min_market_order_volume = sgqlc.types.Field(Int, graphql_name='min_market_order_volume')
253+
open_max_limit_order_volume = sgqlc.types.Field(Int, graphql_name='open_max_limit_order_volume')
254+
open_max_market_order_volume = sgqlc.types.Field(Int, graphql_name='open_max_market_order_volume')
255+
open_min_limit_order_volume = sgqlc.types.Field(Int, graphql_name='open_min_limit_order_volume')
256+
open_min_market_order_volume = sgqlc.types.Field(Int, graphql_name='open_min_market_order_volume')
206257
pre_open_interest = sgqlc.types.Field(Int64, graphql_name='pre_open_interest')
207258
product_short_name = sgqlc.types.Field(String, graphql_name='product_short_name')
208259
settlement_price = sgqlc.types.Field(Float, graphql_name='settlement_price')
@@ -294,9 +345,16 @@ class allClassUnion(sgqlc.types.Union):
294345
future_frag.settlement_price()
295346
future_frag.max_market_order_volume()
296347
future_frag.max_limit_order_volume()
348+
future_frag.min_market_order_volume()
349+
future_frag.min_limit_order_volume()
350+
future_frag.open_max_market_order_volume()
351+
future_frag.open_max_limit_order_volume()
352+
future_frag.open_min_market_order_volume()
353+
future_frag.open_min_limit_order_volume()
297354
future_frag.margin()
298355
future_frag.commission()
299356
future_frag.mmsa()
357+
future_frag.categories()
300358

301359
option_frag = Fragment(option, 'option')
302360
option_frag.pre_open_interest()
@@ -307,6 +365,12 @@ class allClassUnion(sgqlc.types.Union):
307365
option_frag.settlement_price()
308366
option_frag.max_market_order_volume()
309367
option_frag.max_limit_order_volume()
368+
option_frag.min_market_order_volume()
369+
option_frag.min_limit_order_volume()
370+
option_frag.open_max_market_order_volume()
371+
option_frag.open_max_limit_order_volume()
372+
option_frag.open_min_market_order_volume()
373+
option_frag.open_min_limit_order_volume()
310374
option_frag.strike_price()
311375
option_frag.call_or_put()
312376
option_frag.exercise_type()
@@ -317,6 +381,12 @@ class allClassUnion(sgqlc.types.Union):
317381
combine_frag.expire_datetime()
318382
combine_frag.max_market_order_volume()
319383
combine_frag.max_limit_order_volume()
384+
combine_frag.min_market_order_volume()
385+
combine_frag.min_limit_order_volume()
386+
combine_frag.open_max_market_order_volume()
387+
combine_frag.open_max_limit_order_volume()
388+
combine_frag.open_min_market_order_volume()
389+
combine_frag.open_min_limit_order_volume()
320390
combine_frag.leg1().__as__(basic).instrument_id()
321391
combine_frag.leg2().__as__(basic).instrument_id()
322392

tqsdk/objs.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import copy
66
import json
77
import warnings
8+
from typing import List
89

910
from tqsdk.diff import _get_obj
1011
from tqsdk.entity import Entity
@@ -128,6 +129,14 @@ def __init__(self, api):
128129
self.min_limit_order_volume: int = 0
129130
#: 最小市价单手数
130131
self.min_market_order_volume: int = 0
132+
#: 最大市价开仓手数
133+
self.open_max_market_order_volume: int = 0
134+
#: 最大限价开仓手数
135+
self.open_max_limit_order_volume: int = 0
136+
#: 最小市价开仓手数
137+
self.open_min_market_order_volume: int = 0
138+
#: 最小限价开仓手数
139+
self.open_min_limit_order_volume: int = 0
131140
#: 标的合约
132141
self.underlying_symbol: str = ""
133142
#: 行权价
@@ -172,6 +181,8 @@ def __init__(self, api):
172181
self.cash_dividend_ratio: list = []
173182
#: 距离到期日的剩余天数(自然日天数),正数表示距离到期日的剩余天数,0表示到期日当天,负数表示距离到期日已经过去的天数
174183
self.expire_rest_days: int = float('nan')
184+
#: 板块信息
185+
self.categories: List[CategoryInfo] = []
175186

176187
def _instance_entity(self, path):
177188
super(Quote, self)._instance_entity(path)
@@ -194,6 +205,16 @@ def __await__(self):
194205
return self._task.__await__()
195206

196207

208+
class CategoryInfo(Entity):
209+
"""CategoryInfo 是一个板块信息对象"""
210+
211+
def __init__(self):
212+
#: 板块代码
213+
self.id: str = ""
214+
#: 板块名称
215+
self.name: str = ""
216+
217+
197218
class TradingTime(Entity):
198219
""" TradingTime 是一个交易时间对象
199220
它不是一个可单独使用的类,而是用于定义 Quote 的 trading_time 字段的类型

0 commit comments

Comments
 (0)