From e455081c2780505db2ed601271ba6ffe5e170d1e Mon Sep 17 00:00:00 2001 From: LeoK Date: Wed, 7 Nov 2018 18:18:04 +0800 Subject: [PATCH 1/5] Update install.sh Added user options --- install.sh | 45 +++++++++++++++++++++++++++++++++------------ 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/install.sh b/install.sh index 27fd9235..da90c17b 100755 --- a/install.sh +++ b/install.sh @@ -1,21 +1,42 @@ #!/bin/bash #Build ctp/lts/ib api -pushd vnpy/api/ctp -bash build.sh -popd -pushd vnpy/api/lts -bash build.sh -popd +echo "是否要安装'CTP'接口? (Do you want to install 'CTP'?)" +read -p "Enter [y]n: " var1 +var1=${var1:-y} +if [ "$var1" = "y" ]; then + pushd vnpy/api/ctp + bash build.sh + popd +fi -pushd vnpy/api/xtp -bash build.sh -popd +echo "是否要安装'LTS'接口? (Do you want to install 'LTS'?)" +read -p "Enter [y]n: " var1 +var1=${var1:-y} +if [ "$var1" = "y" ]; then + pushd vnpy/api/lts + bash build.sh + popd +fi -pushd vnpy/api/ib -bash build.sh -popd +echo "是否要安装'XTP'接口? (Do you want to install 'XTP'?)" +read -p "Enter [y]n: " var1 +var1=${var1:-y} +if [ "$var1" = "y" ]; then + pushd vnpy/api/xtp + bash build.sh + popd +fi + +echo "是否要安装'IB'接口? (Do you want to install 'IB'?)" +read -p "Enter [y]n: " var1 +var1=${var1:-y} +if [ "$var1" = "y" ]; then + pushd vnpy/api/ib + bash build.sh + popd +fi #Install Python Modules pip install -r requirements.txt From f143849ac58bd98a356194fdb2ca20fc55a19d04 Mon Sep 17 00:00:00 2001 From: LeoK Date: Wed, 7 Nov 2018 18:29:13 +0800 Subject: [PATCH 2/5] Update install.sh changed English questions --- install.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/install.sh b/install.sh index da90c17b..33a4263c 100755 --- a/install.sh +++ b/install.sh @@ -2,7 +2,7 @@ #Build ctp/lts/ib api -echo "是否要安装'CTP'接口? (Do you want to install 'CTP'?)" +echo "是否要安装'CTP'接口? (Do you need 'CTP' interface?)" read -p "Enter [y]n: " var1 var1=${var1:-y} if [ "$var1" = "y" ]; then @@ -11,7 +11,7 @@ if [ "$var1" = "y" ]; then popd fi -echo "是否要安装'LTS'接口? (Do you want to install 'LTS'?)" +echo "是否要安装'LTS'接口? (Do you need 'LTS' interface?)" read -p "Enter [y]n: " var1 var1=${var1:-y} if [ "$var1" = "y" ]; then @@ -20,7 +20,7 @@ if [ "$var1" = "y" ]; then popd fi -echo "是否要安装'XTP'接口? (Do you want to install 'XTP'?)" +echo "是否要安装'XTP'接口? (Do you need 'XTP' interface?)" read -p "Enter [y]n: " var1 var1=${var1:-y} if [ "$var1" = "y" ]; then @@ -29,7 +29,7 @@ if [ "$var1" = "y" ]; then popd fi -echo "是否要安装'IB'接口? (Do you want to install 'IB'?)" +echo "是否要安装'IB'接口? (Do you need 'IB' interface?)" read -p "Enter [y]n: " var1 var1=${var1:-y} if [ "$var1" = "y" ]; then From 268f833bdc62467698d2df07f38c032721b009de Mon Sep 17 00:00:00 2001 From: nanoric Date: Mon, 26 Nov 2018 04:15:23 -0400 Subject: [PATCH 3/5] =?UTF-8?q?[Add]=20ws:=E5=9C=A8=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E6=9C=80=E5=90=8E=E6=8E=A5=E6=94=B6=E5=88=B0=E7=9A=84=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=97=B6=E5=B0=9D=E8=AF=95=E8=A7=A3=E5=8C=85=EF=BC=8C?= =?UTF-8?q?=E8=8B=A5=E8=A7=A3=E5=8C=85=E5=A4=B1=E8=B4=A5=E5=88=99=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E5=8E=9F=E6=9D=A5=E7=9A=84=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vnpy/api/websocket/WebsocketClient.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/vnpy/api/websocket/WebsocketClient.py b/vnpy/api/websocket/WebsocketClient.py index b9d75e84..8583d4f7 100644 --- a/vnpy/api/websocket/WebsocketClient.py +++ b/vnpy/api/websocket/WebsocketClient.py @@ -263,11 +263,16 @@ class WebsocketClient(object): """ 用于Debug: 记录最后一次发送出去的text """ - self._lastSentText = text[:500] + self._lastSentText = text[:1000] #---------------------------------------------------------------------- def _recordLastReceivedText(self, text): """ 用于Debug: 记录最后一次发送出去的text """ - self._lastReceivedText = text[:500] + try: + # 尝试解包,解不了就算 + text = str(self.unpackData(text)) + except: + pass + self._lastReceivedText = text[:1000] From fc7eb662264194ac5f8606d7edade141ef91f089 Mon Sep 17 00:00:00 2001 From: nanoric Date: Mon, 26 Nov 2018 04:18:21 -0400 Subject: [PATCH 4/5] =?UTF-8?q?[Fix]=20Okex=20=E4=BF=AE=E6=AD=A3=E4=BA=86?= =?UTF-8?q?=E7=99=BB=E5=BD=95=E6=97=B6=E6=97=A0=E6=8C=81=E4=BB=93=E6=97=B6?= =?UTF-8?q?=E7=9A=84=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gateway/okexfGateway/okexfGateway.py | 43 ++++++++++--------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/vnpy/trader/gateway/okexfGateway/okexfGateway.py b/vnpy/trader/gateway/okexfGateway/okexfGateway.py index a81ad856..56c1dd7e 100644 --- a/vnpy/trader/gateway/okexfGateway/okexfGateway.py +++ b/vnpy/trader/gateway/okexfGateway/okexfGateway.py @@ -388,27 +388,28 @@ class OkexfRestApi(RestClient): #---------------------------------------------------------------------- def onQueryPosition(self, data, request): """""" - for d in data['holding'][0]: - longPosition = VtPositionData() - longPosition.gatewayName = self.gatewayName - longPosition.symbol = d['instrument_id'] - longPosition.exchange = 'OKEX' - longPosition.vtSymbol = '.'.join([longPosition.symbol, longPosition.exchange]) - longPosition.direction = DIRECTION_LONG - longPosition.vtPositionName = '.'.join([longPosition.vtSymbol, longPosition.direction]) - longPosition.position = int(d['long_qty']) - longPosition.frozen = longPosition.position - int(d['long_avail_qty']) - longPosition.price = float(d['long_avg_cost']) - - shortPosition = copy(longPosition) - shortPosition.direction = DIRECTION_SHORT - shortPosition.vtPositionName = '.'.join([shortPosition.vtSymbol, shortPosition.direction]) - shortPosition.position = int(d['short_qty']) - shortPosition.frozen = shortPosition.position - int(d['short_avail_qty']) - shortPosition.price = float(d['short_avg_cost']) - - self.gateway.onPosition(longPosition) - self.gateway.onPosition(shortPosition) + for holding in data['holding']: + for d in holding: + longPosition = VtPositionData() + longPosition.gatewayName = self.gatewayName + longPosition.symbol = d['instrument_id'] + longPosition.exchange = 'OKEX' + longPosition.vtSymbol = '.'.join([longPosition.symbol, longPosition.exchange]) + longPosition.direction = DIRECTION_LONG + longPosition.vtPositionName = '.'.join([longPosition.vtSymbol, longPosition.direction]) + longPosition.position = int(d['long_qty']) + longPosition.frozen = longPosition.position - int(d['long_avail_qty']) + longPosition.price = float(d['long_avg_cost']) + + shortPosition = copy(longPosition) + shortPosition.direction = DIRECTION_SHORT + shortPosition.vtPositionName = '.'.join([shortPosition.vtSymbol, shortPosition.direction]) + shortPosition.position = int(d['short_qty']) + shortPosition.frozen = shortPosition.position - int(d['short_avail_qty']) + shortPosition.price = float(d['short_avg_cost']) + + self.gateway.onPosition(longPosition) + self.gateway.onPosition(shortPosition) #---------------------------------------------------------------------- def onQueryOrder(self, data, request): From 870723660942e9acf06d284b1da90df83348a36d Mon Sep 17 00:00:00 2001 From: cclauss Date: Fri, 28 Dec 2018 23:47:57 +0100 Subject: [PATCH 5/5] Use print() function in both Python 2 and Python 3 Legacy __print__ statements are syntax errors in Python 3 but __print()__ function works as expected in both Python 2 and Python 3. --- examples/TurtleStrategy/turtleEngine.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/TurtleStrategy/turtleEngine.py b/examples/TurtleStrategy/turtleEngine.py index 5c3b09e9..aa6603f6 100644 --- a/examples/TurtleStrategy/turtleEngine.py +++ b/examples/TurtleStrategy/turtleEngine.py @@ -1,5 +1,7 @@ # encoding: UTF-8 +from __future__ import print_function + from csv import DictReader from datetime import datetime from collections import OrderedDict, defaultdict @@ -306,7 +308,7 @@ class BacktestingEngine(object): #---------------------------------------------------------------------- def output(self, content): """输出信息""" - print content + print(content) #---------------------------------------------------------------------- def getTradeData(self, vtSymbol=''): @@ -432,4 +434,4 @@ class DailyResult(object): def formatNumber(n): """格式化数字到字符串""" rn = round(n, 2) # 保留两位小数 - return format(rn, ',') # 加上千分符 \ No newline at end of file + return format(rn, ',') # 加上千分符