Skip to content

Commit 5e121fc

Browse files
committed
Support pull mode for JoinQuant
1 parent 4706a52 commit 5e121fc

25 files changed

+400
-13
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,6 @@ ENV/
8989
.ropeproject
9090

9191
.idea/
92+
examples/joinquant/config/config.ini
93+
tests/config/config.ini
94+

README.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,18 @@
1616

1717
#### 步骤
1818
* 将 shipane_sdk/client.py 上传至聚宽“投资研究”根目录,并重命名为 shipane_sdk.py。
19-
* 将 shipane_sdk/joinquant_executor.py 追加到 shpane_sdk.py 中。
20-
* 用法请参考 examples/simply_joinquant_strategy.py (注意将其中的 xxx.xxx.xxx.xxx 替换为实际 IP)。
19+
* 将 shipane_sdk/joinquant/executor.py 追加到 shpane_sdk.py 中。
20+
* 用法请参考 examples/joinquant/simply_strategy.py (注意将其中的 xxx.xxx.xxx.xxx 替换为实际 IP)。
2121

2222
### 二. 抓取方式
23-
开发中
23+
无需云服务器,采用定时轮询的方式,实时性不如"推送方式"。
24+
25+
#### 先决条件
26+
* 部署实盘易成功
27+
* 手动测试通过
28+
29+
#### 步骤
30+
* git clone 或下载项目到本地。
31+
* 安装必要的依赖 "pip install requests"。
32+
* 参考 examples/joinquant/config/config.ini.template 创建 examples/joinquant/config/config.ini,并完善配置。
33+
* 命令行运行 "python ./examples/joinquant/simple_runner.py"。

examples/__init__.py

Whitespace-only changes.

examples/joinquant/__init__.py

Whitespace-only changes.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[ShiPanE]
2+
host=localhost
3+
port=8888
4+
key=
5+
6+
[JoinQuant]
7+
username=
8+
password=
9+
backtestId=
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# -*- coding: utf-8 -*-
2+
3+
import ConfigParser
4+
import logging
5+
import os
6+
7+
from shipane_sdk import Client
8+
from shipane_sdk.joinquant.client import JoinQuantClient
9+
from shipane_sdk.joinquant.runner import JoinQuantRunner
10+
11+
if __name__ == "__main__":
12+
logging.basicConfig(level=logging.INFO, format='%(asctime)-15s %(levelname)-6s %(message)s')
13+
14+
dir_path = os.path.dirname(os.path.realpath(__file__))
15+
16+
config = ConfigParser.RawConfigParser()
17+
config.read('{}/config/config.ini'.format(dir_path))
18+
19+
shipane_client = Client(host=config.get('ShiPanE', 'host'),
20+
port=config.get('ShiPanE', 'port'),
21+
key=config.get('ShiPanE', 'key'))
22+
jq_client = JoinQuantClient(username=config.get('JoinQuant', 'username'),
23+
password=config.get('JoinQuant', 'password'),
24+
backtest_id=config.get('JoinQuant', 'backtestId'))
25+
jq_client.login()
26+
runner = JoinQuantRunner(shipane_client, jq_client, interval=15)
27+
28+
runner.run()
File renamed without changes.

shipane_sdk/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# -*- coding: utf-8 -*-
22

33
from .client import Client
4-
from .joinquant_executor import JoinQuantExecutor
4+
from .joinquant.executor import JoinQuantExecutor

shipane_sdk/client.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ def buy(self, symbol, price, amount):
7575
def sell(self, symbol, price, amount):
7676
return self.__execute('SELL', symbol, price, amount)
7777

78+
def execute(self, order_type, symbol, price, amount):
79+
return self.__execute(order_type, symbol, price, amount)
80+
7881
def cancel(self, order_id):
7982
return requests.delete(self.__create_order_url(order_id), timeout=self._timeout)
8083

shipane_sdk/joinquant/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)