Skip to content

Commit

Permalink
Merge pull request #6 from noranhe/main
Browse files Browse the repository at this point in the history
[Mod] replace pytz + 更新版本号到1.0.2
  • Loading branch information
vnpy committed Aug 1, 2022
2 parents d3f0db4 + 3b35a6b commit c51efe1
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 11 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 1.0.2版本

1. 修复打包文件缺少lib的问题
2. 使用zoneinfo替换pytz库
3. 调整安装脚本setup.cfg,添加Python版本限制

# 1.0.1版本

1. 调整安装脚本setup.py,支持Windows下安装时根据Python版本进行编译
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</p>

<p align="center">
<img src ="https://img.shields.io/badge/version-1.0.1-blueviolet.svg"/>
<img src ="https://img.shields.io/badge/version-1.0.2-blueviolet.svg"/>
<img src ="https://img.shields.io/badge/platform-windows-yellow.svg"/>
<img src ="https://img.shields.io/badge/python-3.7|3.8|3.9|3.10-blue.svg" />
<img src ="https://img.shields.io/github/license/vnpy/vnpy.svg?color=orange"/>
Expand All @@ -20,7 +20,7 @@

## 安装

安装环境推荐基于3.0.0版本以上的【[**VeighNa Studio**](https://www.vnpy.com)】。
安装环境推荐基于3.3.0版本以上的【[**VeighNa Studio**](https://www.vnpy.com)】。

直接使用pip命令:

Expand Down
3 changes: 2 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = vnpy_hts
version = 1.0.1
version = 1.0.2
url = https://www.vnpy.com
license = MIT
author = Xiaoyou Chen
Expand Down Expand Up @@ -31,6 +31,7 @@ classifiers =
packages = find:
include_package_data = True
zip_safe = False
python_requires = >=3.7
install_requires =
importlib_metadata

Expand Down
6 changes: 5 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import platform

from setuptools import Extension, setup


def get_ext_modules() -> list:
"""
获取三方模块
Windows需要编译封装接口
Linux和Mac由于缺乏二进制库支持无法使用
"""
if platform.system() != "Windows":
return []

extra_compile_flags = ["-O2", "-MT"]
extra_link_args = []
runtime_library_dirs = []
Expand Down
13 changes: 6 additions & 7 deletions vnpy_hts/gateway/hts_gateway.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from typing import Any, Dict, List
from datetime import datetime
from copy import copy
import pytz

from vnpy.event import EventEngine
from vnpy.trader.event import EVENT_TIMER
Expand All @@ -26,7 +25,7 @@
PositionData,
AccountData
)
from vnpy.trader.utility import get_folder_path
from vnpy.trader.utility import get_folder_path, ZoneInfo

from ..api import (
MdApi,
Expand Down Expand Up @@ -105,7 +104,7 @@
}

# 其他常量
CHINA_TZ = pytz.timezone("Asia/Shanghai") # 中国时区
CHINA_TZ = ZoneInfo("Asia/Shanghai") # 中国时区

# 合约数据全局缓存字典
symbol_contract_map: Dict[str, ContractData] = {}
Expand Down Expand Up @@ -298,7 +297,7 @@ def onSOPMarketData(self, data: dict) -> None:
"""行情数据推送"""
timestamp: str = str(data["tradingDay"]) + str(data["updateTime"])
dt: datetime = datetime.strptime(timestamp, "%Y%m%d%H:%M:%S.%f")
dt: datetime = CHINA_TZ.localize(dt)
dt: datetime = dt.replace(tzinfo=CHINA_TZ)

tick: TickData = TickData(
symbol=data["securityID"],
Expand Down Expand Up @@ -461,7 +460,7 @@ def onSOPEntrustOrderRtn(self, data: dict) -> None:

timestamp: str = str(datetime.date(datetime.now())) + str(data["entrustTime"])
dt: datetime = datetime.strptime(timestamp, "%Y-%m-%d%H:%M:%S.%f")
dt: datetime = CHINA_TZ.localize(dt)
dt: datetime = dt.replace(tzinfo=CHINA_TZ)

if orderid in self.orders:
order: OrderData = self.orders[orderid]
Expand Down Expand Up @@ -493,7 +492,7 @@ def onSOPTradeRtn(self, data: dict) -> None:
"""成交数据推送"""
timestamp: str = str(datetime.date(datetime.now())) + str(data["tradeTime"])
dt: datetime = datetime.strptime(timestamp, "%Y-%m-%d%H:%M:%S.%f")
dt: datetime = CHINA_TZ.localize(dt)
dt: datetime = dt.replace(tzinfo=CHINA_TZ)
localid: str = str(data["localOrderID"])
sessionid: str = str(data["sessionID"])
orderid: str = f"{sessionid}_{localid}"
Expand Down Expand Up @@ -580,7 +579,7 @@ def onRspSOPEntrustOrder(self, data: dict, error: dict) -> None:

if order:
dt: datetime = datetime.now()
dt: datetime = CHINA_TZ.localize(dt)
dt: datetime = dt.replace(tzinfo=CHINA_TZ)
order.datetime = dt
order.status = Status.REJECTED
self.gateway.on_order(copy(order))
Expand Down

0 comments on commit c51efe1

Please sign in to comment.