Merge pull request #1311 from vnpy/master

[Merge]合并部分master分支的PR内容
This commit is contained in:
vn.py 2018-12-29 09:41:27 +08:00 committed by GitHub
commit 10e9983e14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 43 additions and 20 deletions

View File

@ -1,5 +1,7 @@
# encoding: UTF-8 # encoding: UTF-8
from __future__ import print_function
from csv import DictReader from csv import DictReader
from datetime import datetime from datetime import datetime
from collections import OrderedDict, defaultdict from collections import OrderedDict, defaultdict
@ -306,7 +308,7 @@ class BacktestingEngine(object):
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def output(self, content): def output(self, content):
"""输出信息""" """输出信息"""
print content print(content)
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def getTradeData(self, vtSymbol=''): def getTradeData(self, vtSymbol=''):
@ -432,4 +434,4 @@ class DailyResult(object):
def formatNumber(n): def formatNumber(n):
"""格式化数字到字符串""" """格式化数字到字符串"""
rn = round(n, 2) # 保留两位小数 rn = round(n, 2) # 保留两位小数
return format(rn, ',') # 加上千分符 return format(rn, ',') # 加上千分符

View File

@ -10,25 +10,41 @@ function check_result() {
} }
#Build ctp/lts/ib api #Build ctp/lts/ib api
pushd vnpy/api/ctp echo "是否要安装'CTP'接口? (Do you need 'CTP' interface?)"
bash build.sh read -p "Enter [y]n: " var1
check_result "build api.ctp" var1=${var1:-y}
popd if [ "$var1" = "y" ]; then
pushd vnpy/api/ctp
bash build.sh
popd
fi
pushd vnpy/api/lts echo "是否要安装'LTS'接口? (Do you need 'LTS' interface?)"
bash build.sh read -p "Enter [y]n: " var1
check_result "build api.lts" var1=${var1:-y}
popd if [ "$var1" = "y" ]; then
pushd vnpy/api/lts
bash build.sh
popd
fi
pushd vnpy/api/xtp echo "是否要安装'XTP'接口? (Do you need 'XTP' interface?)"
bash build.sh read -p "Enter [y]n: " var1
check_result "build api.xtp" var1=${var1:-y}
popd if [ "$var1" = "y" ]; then
pushd vnpy/api/xtp
bash build.sh
popd
fi
pushd vnpy/api/ib echo "是否要安装'IB'接口? (Do you need 'IB' interface?)"
bash build.sh read -p "Enter [y]n: " var1
check_result "build api.ib" var1=${var1:-y}
popd if [ "$var1" = "y" ]; then
pushd vnpy/api/ib
bash build.sh
popd
fi
#Install Python Modules #Install Python Modules
pip install -r requirements.txt pip install -r requirements.txt

View File

@ -263,11 +263,16 @@ class WebsocketClient(object):
""" """
用于Debug 记录最后一次发送出去的text 用于Debug 记录最后一次发送出去的text
""" """
self._lastSentText = text[:500] self._lastSentText = text[:1000]
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def _recordLastReceivedText(self, text): def _recordLastReceivedText(self, text):
""" """
用于Debug 记录最后一次发送出去的text 用于Debug 记录最后一次发送出去的text
""" """
self._lastReceivedText = text[:500] try:
# 尝试解包,解不了就算
text = str(self.unpackData(text))
except:
pass
self._lastReceivedText = text[:1000]