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, ',') # 加上千分符 diff --git a/install.sh b/install.sh index 221547d3..b3e29e3c 100755 --- a/install.sh +++ b/install.sh @@ -10,25 +10,41 @@ function check_result() { } #Build ctp/lts/ib api -pushd vnpy/api/ctp -bash build.sh -check_result "build api.ctp" -popd +echo "是否要安装'CTP'接口? (Do you need 'CTP' interface?)" +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/lts -bash build.sh -check_result "build api.lts" -popd +echo "是否要安装'LTS'接口? (Do you need 'LTS' interface?)" +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/xtp -bash build.sh -check_result "build api.xtp" -popd +echo "是否要安装'XTP'接口? (Do you need 'XTP' interface?)" +read -p "Enter [y]n: " var1 +var1=${var1:-y} +if [ "$var1" = "y" ]; then + pushd vnpy/api/xtp + bash build.sh + popd +fi -pushd vnpy/api/ib -bash build.sh -check_result "build api.ib" -popd +echo "是否要安装'IB'接口? (Do you need 'IB' interface?)" +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 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]