Skip to content

Commit

Permalink
[Add] 添加项目代码
Browse files Browse the repository at this point in the history
  • Loading branch information
vnpy committed Dec 20, 2021
1 parent 5afc5a0 commit cdc34c8
Show file tree
Hide file tree
Showing 99 changed files with 44,818 additions and 130 deletions.
5 changes: 5 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[flake8]
exclude = venv,build,__pycache__,__init__.py,ib,talib,uic
ignore =
E501 line too long, fixed by black
W503 line break before binary operator
161 changes: 35 additions & 126 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,129 +1,38 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
# Prerequisites
*.d

# Compiled Object files
*.slo
*.lo
*.o
*.obj

# Precompiled Headers
*.gch
*.pch

# Fortran module files
*.mod
*.smod

# Compiled Static libraries
*.lai
*.la
*.a

# Executables
*.exe
*.out
*.app

# Python
*.pyc
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site
build/
vnpy_ctp.egg-info/
__pycache__/

# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Visual Studio
.vs/
x64/

# Pyre type checker
.pyre/
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License
The MIT License (MIT)

Copyright (c) 2021 vn.py
Copyright (c) 2015-present, Xiaoyou Chen

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
recursive-include vnpy_ctp *.dll *.so *.pyd *.h *.cpp
68 changes: 66 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,66 @@
# vnpy_sec
vn.py框架的飞创ETF期权交易接口
# vn.py框架的顶点飞创交易接口

<p align="center">
<img src ="https://vnpy.oss-cn-shanghai.aliyuncs.com/vnpy-logo.png"/>
</p>

<p align="center">
<img src ="https://img.shields.io/badge/version-1.0.0-blueviolet.svg"/>
<img src ="https://img.shields.io/badge/platform-windows-yellow.svg"/>
<img src ="https://img.shields.io/badge/python-3.7-blue.svg" />
<img src ="https://img.shields.io/github/license/vnpy/vnpy.svg?color=orange"/>
</p>

## 说明

基于顶点飞创证券版的API接口封装开发,具体API版本为:

* 行情:1.6.44
* 交易:1.6.85

## 安装

安装需要基于2.9.0版本以上的[VN Studio](https://www.vnpy.com)

直接使用pip命令:

```
pip install vnpy_sec
```


或者下载解压后在cmd中运行:

```
python setup.py install
```

## 使用

以脚本方式启动(script/run.py):

```
from vnpy.event import EventEngine
from vnpy.trader.engine import MainEngine
from vnpy.trader.ui import MainWindow, create_qapp
from vnpy_sec import SecGateway
def main():
"""主入口函数"""
qapp = create_qapp()
event_engine = EventEngine()
main_engine = MainEngine(event_engine)
main_engine.add_gateway(SecGateway)
main_window = MainWindow(main_engine, event_engine)
main_window.showMaximized()
qapp.exec()
if __name__ == "__main__":
main()
```
23 changes: 23 additions & 0 deletions script/run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from vnpy.event import EventEngine
from vnpy.trader.engine import MainEngine
from vnpy.trader.ui import MainWindow, create_qapp

from vnpy_sec import SecGateway


def main():
"""主入口函数"""
qapp = create_qapp()

event_engine = EventEngine()
main_engine = MainEngine(event_engine)
main_engine.add_gateway(SecGateway)

main_window = MainWindow(main_engine, event_engine)
main_window.showMaximized()

qapp.exec()


if __name__ == "__main__":
main()
36 changes: 36 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
[metadata]
name = vnpy_sec
version = 1.0.0
url = https://www.vnpy.com
license = MIT
author = Xiaoyou Chen
author_email = xiaoyou.chen@mail.vnpy.com
description = CTP gateway for vn.py quant trading framework.
long_description = file: README.md
long_description_content_type = text/markdown
keywords =
quant
quantitative
investment
trading
algotrading
ctp
classifiers =
Development Status :: 5 - Production/Stable
Operating System :: Microsoft :: Windows
Programming Language :: Python :: 3
Programming Language :: Python :: 3.7
Topic :: Office/Business :: Financial :: Investment
Programming Language :: Python :: Implementation :: CPython
License :: OSI Approved :: MIT License
Natural Language :: Chinese (Simplified)

[options]
packages = find:
include_package_data = True
zip_safe = False
install_requires =
importlib_metadata

[options.package_data]
* = *.dll, *.so, *.pyd
66 changes: 66 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import platform

from setuptools import Extension, setup


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

compiler_flags = [
"-std=c++17",
"-O3",
"-Wno-delete-incomplete", "-Wno-sign-compare",
]
extra_link_args = ["-lstdc++"]
runtime_library_dirs = ["$ORIGIN"]

vnctpmd = Extension(
"vnpy_ctp.api.vnctpmd",
[
"vnpy_ctp/api/vnctp/vnctpmd/vnctpmd.cpp",
],
include_dirs=["vnpy_ctp/api/include",
"vnpy_ctp/api/vnctp"],
define_macros=[],
undef_macros=[],
library_dirs=["vnpy_ctp/api/libs", "vnpy_ctp/api"],
libraries=["thostmduserapi_se", "thosttraderapi_se"],
extra_compile_args=compiler_flags,
extra_link_args=extra_link_args,
runtime_library_dirs=runtime_library_dirs,
depends=[],
language="cpp",
)

vnctptd = Extension(
"vnpy_ctp.api.vnctptd",
[
"vnpy_ctp/api/vnctp/vnctptd/vnctptd.cpp",
],
include_dirs=["vnpy_ctp/api/include",
"vnpy_ctp/api/vnctp"],
define_macros=[],
undef_macros=[],
library_dirs=["vnpy_ctp/api/libs", "vnpy_ctp/api"],
libraries=["thostmduserapi_se", "thosttraderapi_se"],
extra_compile_args=compiler_flags,
extra_link_args=extra_link_args,
runtime_library_dirs=runtime_library_dirs,
depends=[],
language="cpp",
)

return [vnctptd, vnctpmd]


setup(
ext_modules=get_ext_modules(),
)

0 comments on commit cdc34c8

Please sign in to comment.