Skip to content

Commit

Permalink
Update Version 3.4.10
Browse files Browse the repository at this point in the history
  • Loading branch information
shinny-pack authored and shinny-mayanqiong committed Sep 22, 2023
1 parent 648d1b5 commit 596dada
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 13 deletions.
2 changes: 1 addition & 1 deletion PKG-INFO
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: tqsdk
Version: 3.4.9
Version: 3.4.10
Summary: TianQin SDK
Home-page: https://www.shinnytech.com/tqsdk
Author: TianQin
Expand Down
4 changes: 2 additions & 2 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@
# built documents.
#
# The short X.Y version.
version = u'3.4.9'
version = u'3.4.10'
# The full version, including alpha/beta/rc tags.
release = u'3.4.9'
release = u'3.4.10'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
6 changes: 6 additions & 0 deletions doc/version.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

版本变更
=============================
3.4.10 (2023/09/22)

* 修复:pandas 2.1.0 版本 fillna 、NumericBlock 会报 deprecated warning 的问题
* 优化:磁盘空间剩余小于10G,默认不写入日志


3.4.9 (2023/09/15)

* 修复:回测时 :py:class:`~tqsdk.TqSim` 可能出现 volume_short_today 为负数的问题
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

setuptools.setup(
name='tqsdk',
version="3.4.9",
version="3.4.10",
description='TianQin SDK',
author='TianQin',
author_email='[email protected]',
Expand Down
2 changes: 1 addition & 1 deletion tqsdk/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '3.4.9'
__version__ = '3.4.10'
10 changes: 6 additions & 4 deletions tqsdk/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@
from pandas._libs.internals import BlockPlacement
if tuple(map(int, pd.__version__.split("."))) < (1, 3, 0):
from pandas.core.internals import FloatBlock
else:
elif tuple(map(int, pd.__version__.split("."))) < (2, 1, 0):
from pandas.core.internals import NumericBlock as FloatBlock
else:
from pandas.core.internals.blocks import NumpyBlock as FloatBlock

from tqsdk.auth import TqAuth
from tqsdk.baseApi import TqBaseApi
Expand Down Expand Up @@ -136,7 +138,7 @@ def __init__(self, account: Optional[Union[TqMultiAccount, UnionTradeable]] = No
+ 仅有本地模拟账户 :py:class:`~tqsdk.TqSim`、:py:class:`~tqsdk.TqSimStock` 时,调试信息不输出。
+ 当有其他类型账户时,即 :py:class:`~tqsdk.TqAccount`、:py:class:`~tqsdk.TqKq`、:py:class:`~tqsdk.TqKqStock`,\
调试信息输出到指定文件夹 `~/.tqsdk/logs`(如果磁盘剩余空间不足 3G 则不会输出调试信息)。
调试信息输出到指定文件夹 `~/.tqsdk/logs`(如果磁盘剩余空间不足 10G 则不会输出调试信息)。
* True: 调试信息会输出到指定文件夹 `~/.tqsdk/logs`。
Expand Down Expand Up @@ -3117,8 +3119,8 @@ def _setup_connection(self):
if not self._logger.handlers and (self._debug or (not self._account._all_sim_account and self._debug is not False)):
_clear_logs() # 先清空日志
log_name = self._debug if isinstance(self._debug, str) else _get_log_name()
if self._debug is not None or _get_disk_free() >= 3:
# self._debug is None 并且磁盘剩余空间小于 3G 则不写入日志
if self._debug is not None or _get_disk_free() >= 10:
# self._debug is None 并且磁盘剩余空间小于 10G 则不写入日志
fh = logging.FileHandler(filename=log_name)
fh.setFormatter(JSONFormatter())
fh.setLevel(logging.DEBUG)
Expand Down
2 changes: 1 addition & 1 deletion tqsdk/calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def _ensure_cont_on_df(self, cont):
temp_df = pd.DataFrame(data=TqContCalendar.continuous[cont], columns=['date', 'underlying'])
temp_df['date'] = pd.Series(pd.to_datetime(temp_df['date'], format='%Y%m%d'))
merge_result = pd.merge(temp_df, self.df, sort=True, how="outer", on="date")
merge_result.fillna(method="ffill", inplace=True)
merge_result.ffill(inplace=True)
merge_result.fillna(value="", inplace=True)
s = merge_result.loc[merge_result.date.ge(self.start_dt) & merge_result.date.le(self.end_dt), 'underlying']
self.df[cont] = pd.Series(s.values)
Expand Down
9 changes: 6 additions & 3 deletions tqsdk/tradeable/sim/trade_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,12 @@ def settle(self):
positions = {}
for k, v in self._positions.items():
positions[k] = v.copy()
positions[k]["pos_long"] = v['pos_long_his'] + v['pos_long_today']
positions[k]["pos_short"] = v['pos_short_his'] + v['pos_short_today']
positions[k]["pos"] = positions[k]["pos_long"] - positions[k]["pos_short"]
if v.get('pos_long_his') is not None and v.get('pos_long_today') is not None:
positions[k]["pos_long"] = v['pos_long_his'] + v['pos_long_today']
if v.get('pos_short_his') is not None and v.get('pos_short_today') is not None:
positions[k]["pos_short"] = v['pos_short_his'] + v['pos_short_today']
if v.get('pos_long') is not None and v.get('pos_short') is not None:
positions[k]["pos"] = positions[k]["pos_long"] - positions[k]["pos_short"]
trade_log = {
"trades": self._trades,
"account": self._account.copy(),
Expand Down

0 comments on commit 596dada

Please sign in to comment.