Merge pull request #874 from cclauss/modernize-vnpy_api_h_and_i
Modernize vnpy/api/h* and i*
This commit is contained in:
commit
c28380a6ea
@ -1,3 +1,4 @@
|
||||
# encoding: UTF-8
|
||||
|
||||
from vnhuobi import TradeApi, DataApi
|
||||
from __future__ import absolute_import
|
||||
from .vnhuobi import TradeApi, DataApi
|
@ -5,7 +5,8 @@
|
||||
#import zlib
|
||||
#import time
|
||||
|
||||
from vnhuobi import DataApi
|
||||
from __future__ import absolute_import
|
||||
from .vnhuobi import DataApi
|
||||
|
||||
#if __name__ == '__main__':
|
||||
#while(1):
|
||||
|
@ -1,6 +1,8 @@
|
||||
# encoding: utf-8
|
||||
|
||||
from vnhuobi import *
|
||||
from __future__ import print_function
|
||||
from __future__ import absolute_import
|
||||
from .vnhuobi import *
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def testTrade():
|
||||
@ -15,9 +17,9 @@ def testTrade():
|
||||
api.start()
|
||||
|
||||
# 查询
|
||||
print api.getSymbols()
|
||||
print api.getCurrencys()
|
||||
print api.getTimestamp()
|
||||
print(api.getSymbols())
|
||||
print(api.getCurrencys())
|
||||
print(api.getTimestamp())
|
||||
|
||||
|
||||
#accountid = ''
|
||||
@ -27,7 +29,7 @@ def testTrade():
|
||||
#api.getAccountBalance(accountid)
|
||||
#api.getOrders(symbol, 'pre-submitted,submitted,partial-filled,partial-canceled,filled,canceled')
|
||||
#api.getOrders(symbol, 'filled')
|
||||
print api.getMatchResults(symbol)
|
||||
print(api.getMatchResults(symbol))
|
||||
|
||||
#api.getOrder('2440401255')
|
||||
#api.getMatchResult('2440401255')
|
||||
|
@ -1,5 +1,6 @@
|
||||
# encoding: utf-8
|
||||
|
||||
from __future__ import print_function
|
||||
import urllib
|
||||
import hmac
|
||||
import base64
|
||||
@ -419,71 +420,71 @@ class TradeApi(object):
|
||||
#----------------------------------------------------------------------
|
||||
def onError(self, msg, reqid):
|
||||
"""错误回调"""
|
||||
print msg, reqid
|
||||
print(msg, reqid)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def onGetSymbols(self, data, reqid):
|
||||
"""查询代码回调"""
|
||||
#print reqid, data
|
||||
for d in data:
|
||||
print d
|
||||
print(d)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def onGetCurrencys(self, data, reqid):
|
||||
"""查询货币回调"""
|
||||
print reqid, data
|
||||
print(reqid, data)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def onGetTimestamp(self, data, reqid):
|
||||
"""查询时间回调"""
|
||||
print reqid, data
|
||||
print(reqid, data)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def onGetAccounts(self, data, reqid):
|
||||
"""查询账户回调"""
|
||||
print reqid, data
|
||||
print(reqid, data)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def onGetAccountBalance(self, data, reqid):
|
||||
"""查询余额回调"""
|
||||
print reqid, data
|
||||
print(reqid, data)
|
||||
for d in data['data']['list']:
|
||||
print d
|
||||
print(d)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def onGetOrders(self, data, reqid):
|
||||
"""查询委托回调"""
|
||||
print reqid, data
|
||||
print(reqid, data)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def onGetMatchResults(self, data, reqid):
|
||||
"""查询成交回调"""
|
||||
print reqid, data
|
||||
print(reqid, data)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def onGetOrder(self, data, reqid):
|
||||
"""查询单一委托回调"""
|
||||
print reqid, data
|
||||
print(reqid, data)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def onGetMatchResult(self, data, reqid):
|
||||
"""查询单一成交回调"""
|
||||
print reqid, data
|
||||
print(reqid, data)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def onPlaceOrder(self, data, reqid):
|
||||
"""委托回调"""
|
||||
print reqid, data
|
||||
print(reqid, data)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def onCancelOrder(self, data, reqid):
|
||||
"""撤单回调"""
|
||||
print reqid, data
|
||||
print(reqid, data)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def onBatchCancel(self, data, reqid):
|
||||
"""批量撤单回调"""
|
||||
print reqid, data
|
||||
print(reqid, data)
|
||||
|
||||
|
||||
########################################################################
|
||||
@ -644,7 +645,7 @@ class DataApi(object):
|
||||
#----------------------------------------------------------------------
|
||||
def onError(self, msg):
|
||||
"""错误推送"""
|
||||
print msg
|
||||
print(msg)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def onData(self, data):
|
||||
@ -664,14 +665,14 @@ class DataApi(object):
|
||||
#----------------------------------------------------------------------
|
||||
def onMarketDepth(self, data):
|
||||
"""行情深度推送 """
|
||||
print data
|
||||
print(data)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def onTradeDetail(self, data):
|
||||
"""成交细节推送"""
|
||||
print data
|
||||
print(data)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def onMarketDetail(self, data):
|
||||
"""市场细节推送"""
|
||||
print data
|
||||
print(data)
|
@ -1,3 +1,4 @@
|
||||
# encoding: UTF-8
|
||||
|
||||
from vnib import *
|
||||
from __future__ import absolute_import
|
||||
from .vnib import *
|
@ -1,15 +1,18 @@
|
||||
# encoding: UTF-8
|
||||
|
||||
from __future__ import print_function
|
||||
import sys
|
||||
|
||||
from time import sleep
|
||||
|
||||
from six.moves import input
|
||||
|
||||
from vnib import IbApi
|
||||
|
||||
|
||||
########################################################################
|
||||
class TestApi(IbApi):
|
||||
print sys._getframe().f_code.co_name
|
||||
print(sys._getframe().f_code.co_name)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def __init__(self):
|
||||
@ -18,283 +21,283 @@ class TestApi(IbApi):
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def nextValidId(self, orderId):
|
||||
print sys._getframe().f_code.co_name
|
||||
print locals()
|
||||
print(sys._getframe().f_code.co_name)
|
||||
print(locals())
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def currentTime(self, time):
|
||||
print sys._getframe().f_code.co_name
|
||||
print locals()
|
||||
print(sys._getframe().f_code.co_name)
|
||||
print(locals())
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def connectAck(self):
|
||||
print sys._getframe().f_code.co_name
|
||||
print locals()
|
||||
print(sys._getframe().f_code.co_name)
|
||||
print(locals())
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def error(self, id_, errorCode, errorString):
|
||||
print sys._getframe().f_code.co_name
|
||||
print locals()
|
||||
print(sys._getframe().f_code.co_name)
|
||||
print(locals())
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def accountSummary(self, reqId, account, tag, value, curency):
|
||||
print sys._getframe().f_code.co_name
|
||||
print locals()
|
||||
print(sys._getframe().f_code.co_name)
|
||||
print(locals())
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def accountSummaryEnd(self, reqId):
|
||||
print sys._getframe().f_code.co_name
|
||||
print locals()
|
||||
print(sys._getframe().f_code.co_name)
|
||||
print(locals())
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def tickPrice(self, tickerId, field, price, canAutoExecute):
|
||||
print sys._getframe().f_code.co_name
|
||||
print locals()
|
||||
print(sys._getframe().f_code.co_name)
|
||||
print(locals())
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def tickSize(self, tickerId, field, size):
|
||||
print sys._getframe().f_code.co_name
|
||||
print locals()
|
||||
print(sys._getframe().f_code.co_name)
|
||||
print(locals())
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def tickOptionComputation(self, tickerId, tickType, impliedVol, delta, optPrice, pvDividend, gamma, vega, theta, undPrice):
|
||||
print sys._getframe().f_code.co_name
|
||||
print locals()
|
||||
print(sys._getframe().f_code.co_name)
|
||||
print(locals())
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def tickGeneric(self, tickerId, tickType, value):
|
||||
print sys._getframe().f_code.co_name
|
||||
print locals()
|
||||
print(sys._getframe().f_code.co_name)
|
||||
print(locals())
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def tickString(self, tickerId, tickType, value):
|
||||
print sys._getframe().f_code.co_name
|
||||
print locals()
|
||||
print(sys._getframe().f_code.co_name)
|
||||
print(locals())
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def tickEFP(self, tickerId, tickType, basisPoints, formattedBasisPoints, totalDividends, holdDays, futureLastTradeDate, dividendImpact, dividendsToLastTradeDate):
|
||||
print sys._getframe().f_code.co_name
|
||||
print locals()
|
||||
print(sys._getframe().f_code.co_name)
|
||||
print(locals())
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def orderStatus(self, orderId, status, filled, remaining, avgFillPrice, permId, parentId, lastFillPrice, clientId, whyHeld):
|
||||
print sys._getframe().f_code.co_name
|
||||
print locals()
|
||||
print(sys._getframe().f_code.co_name)
|
||||
print(locals())
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def openOrder(self, orderId, contract, order, orderState):
|
||||
print sys._getframe().f_code.co_name
|
||||
print locals()
|
||||
print(sys._getframe().f_code.co_name)
|
||||
print(locals())
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def openOrderEnd(self):
|
||||
print sys._getframe().f_code.co_name
|
||||
print locals()
|
||||
print(sys._getframe().f_code.co_name)
|
||||
print(locals())
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def winError(self, str_, lastError):
|
||||
print sys._getframe().f_code.co_name
|
||||
print locals()
|
||||
print(sys._getframe().f_code.co_name)
|
||||
print(locals())
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def connectionClosed(self):
|
||||
print sys._getframe().f_code.co_name
|
||||
print locals()
|
||||
print(sys._getframe().f_code.co_name)
|
||||
print(locals())
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def updateAccountValue(self, key, val, currency, accountName):
|
||||
print sys._getframe().f_code.co_name
|
||||
print locals()
|
||||
print(sys._getframe().f_code.co_name)
|
||||
print(locals())
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def updatePortfolio(self, contract, position, marketPrice, marketValue, averageCost, unrealizedPNL, realizedPNL, accountName):
|
||||
print sys._getframe().f_code.co_name
|
||||
print locals()
|
||||
print(sys._getframe().f_code.co_name)
|
||||
print(locals())
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def updateAccountTime(self, timeStamp):
|
||||
print sys._getframe().f_code.co_name
|
||||
print locals()
|
||||
print(sys._getframe().f_code.co_name)
|
||||
print(locals())
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def accountDownloadEnd(self, accountName):
|
||||
print sys._getframe().f_code.co_name
|
||||
print locals()
|
||||
print(sys._getframe().f_code.co_name)
|
||||
print(locals())
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def contractDetails(self, reqId, contractDetails):
|
||||
print sys._getframe().f_code.co_name
|
||||
print locals()
|
||||
print(sys._getframe().f_code.co_name)
|
||||
print(locals())
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def bondContractDetails(self, reqId, contractDetails):
|
||||
print sys._getframe().f_code.co_name
|
||||
print locals()
|
||||
print(sys._getframe().f_code.co_name)
|
||||
print(locals())
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def contractDetailsEnd(self, reqId):
|
||||
print sys._getframe().f_code.co_name
|
||||
print locals()
|
||||
print(sys._getframe().f_code.co_name)
|
||||
print(locals())
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def execDetails(self, reqId, contract, execution):
|
||||
print sys._getframe().f_code.co_name
|
||||
print locals()
|
||||
print(sys._getframe().f_code.co_name)
|
||||
print(locals())
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def execDetailsEnd(self, reqId):
|
||||
print sys._getframe().f_code.co_name
|
||||
print locals()
|
||||
print(sys._getframe().f_code.co_name)
|
||||
print(locals())
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def updateMktDepth(self, id_, position, operation, side, price, size):
|
||||
print sys._getframe().f_code.co_name
|
||||
print locals()
|
||||
print(sys._getframe().f_code.co_name)
|
||||
print(locals())
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def updateMktDepthL2(self, id_, position, marketMaker, operation, side, price, size):
|
||||
print sys._getframe().f_code.co_name
|
||||
print locals()
|
||||
print(sys._getframe().f_code.co_name)
|
||||
print(locals())
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def updateNewsBulletin(self, msgId, msgType, newsMessage, originExch):
|
||||
print sys._getframe().f_code.co_name
|
||||
print locals()
|
||||
print(sys._getframe().f_code.co_name)
|
||||
print(locals())
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def managedAccounts(self, accountsList):
|
||||
print sys._getframe().f_code.co_name
|
||||
print locals()
|
||||
print(sys._getframe().f_code.co_name)
|
||||
print(locals())
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def receiveFA(self, pFaDataType, cxml):
|
||||
print sys._getframe().f_code.co_name
|
||||
print locals()
|
||||
print(sys._getframe().f_code.co_name)
|
||||
print(locals())
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def historicalData(self, reqId, date, open_, high, low, close, volume, barCount, WAP, hasGaps):
|
||||
print sys._getframe().f_code.co_name
|
||||
print locals()
|
||||
print(sys._getframe().f_code.co_name)
|
||||
print(locals())
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def scannerParameters(self, xml):
|
||||
print sys._getframe().f_code.co_name
|
||||
print locals()
|
||||
print(sys._getframe().f_code.co_name)
|
||||
print(locals())
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def scannerData(self, reqId, rank, contractDetails, distance, benchmark, projection, legsStr):
|
||||
print sys._getframe().f_code.co_name
|
||||
print locals()
|
||||
print(sys._getframe().f_code.co_name)
|
||||
print(locals())
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def scannerDataEnd(self, reqId):
|
||||
print sys._getframe().f_code.co_name
|
||||
print locals()
|
||||
print(sys._getframe().f_code.co_name)
|
||||
print(locals())
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def realtimeBar(self, reqId, time, open_, high, low, close, volume, wap, count):
|
||||
print sys._getframe().f_code.co_name
|
||||
print locals()
|
||||
print(sys._getframe().f_code.co_name)
|
||||
print(locals())
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def fundamentalData(self, reqId, data):
|
||||
print sys._getframe().f_code.co_name
|
||||
print locals()
|
||||
print(sys._getframe().f_code.co_name)
|
||||
print(locals())
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def deltaNeutralValidation(self, reqId, underComp):
|
||||
print sys._getframe().f_code.co_name
|
||||
print locals()
|
||||
print(sys._getframe().f_code.co_name)
|
||||
print(locals())
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def tickSnapshotEnd(self, reqId):
|
||||
print sys._getframe().f_code.co_name
|
||||
print locals()
|
||||
print(sys._getframe().f_code.co_name)
|
||||
print(locals())
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def marketDataType(self, reqId, marketDataType):
|
||||
print sys._getframe().f_code.co_name
|
||||
print locals()
|
||||
print(sys._getframe().f_code.co_name)
|
||||
print(locals())
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def commissionReport(self, commissionReport):
|
||||
print sys._getframe().f_code.co_name
|
||||
print locals()
|
||||
print(sys._getframe().f_code.co_name)
|
||||
print(locals())
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def position(self, account, contract, position, avgCost):
|
||||
print sys._getframe().f_code.co_name
|
||||
print locals()
|
||||
print(sys._getframe().f_code.co_name)
|
||||
print(locals())
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def positionEnd(self):
|
||||
print sys._getframe().f_code.co_name
|
||||
print locals()
|
||||
print(sys._getframe().f_code.co_name)
|
||||
print(locals())
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def verifyMessageAPI(self, apiData):
|
||||
print sys._getframe().f_code.co_name
|
||||
print locals()
|
||||
print(sys._getframe().f_code.co_name)
|
||||
print(locals())
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def verifyCompleted(self, isSuccessful, errorText):
|
||||
print sys._getframe().f_code.co_name
|
||||
print locals()
|
||||
print(sys._getframe().f_code.co_name)
|
||||
print(locals())
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def displayGroupList(self, reqId, groups):
|
||||
print sys._getframe().f_code.co_name
|
||||
print locals()
|
||||
print(sys._getframe().f_code.co_name)
|
||||
print(locals())
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def displayGroupUpdated(self, reqId, contractInfo):
|
||||
print sys._getframe().f_code.co_name
|
||||
print locals()
|
||||
print(sys._getframe().f_code.co_name)
|
||||
print(locals())
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def verifyAndAuthMessageAPI(self, apiData, xyzChallange):
|
||||
print sys._getframe().f_code.co_name
|
||||
print locals()
|
||||
print(sys._getframe().f_code.co_name)
|
||||
print(locals())
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def verifyAndAuthCompleted(self, isSuccessful, errorText):
|
||||
print sys._getframe().f_code.co_name
|
||||
print locals()
|
||||
print(sys._getframe().f_code.co_name)
|
||||
print(locals())
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def positionMulti(self, reqId, account, modelCode, contract, pos, avgCost):
|
||||
print sys._getframe().f_code.co_name
|
||||
print locals()
|
||||
print(sys._getframe().f_code.co_name)
|
||||
print(locals())
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def positionMultiEnd(self, reqId):
|
||||
print sys._getframe().f_code.co_name
|
||||
print locals()
|
||||
print(sys._getframe().f_code.co_name)
|
||||
print(locals())
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def accountUpdateMulti(self, reqId, account, modelCode, key, value, currency):
|
||||
print sys._getframe().f_code.co_name
|
||||
print locals()
|
||||
print(sys._getframe().f_code.co_name)
|
||||
print(locals())
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def accountUpdateMultiEnd(self, reqId):
|
||||
print sys._getframe().f_code.co_name
|
||||
print locals()
|
||||
print(sys._getframe().f_code.co_name)
|
||||
print(locals())
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def securityDefinitionOptionalParameter(self, reqId, exchange, underlyingConId, tradingClass, multiplier, expirations, strikes):
|
||||
print sys._getframe().f_code.co_name
|
||||
print locals()
|
||||
print(sys._getframe().f_code.co_name)
|
||||
print(locals())
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def securityDefinitionOptionalParameterEnd(self, reqId):
|
||||
print sys._getframe().f_code.co_name
|
||||
print locals()
|
||||
print(sys._getframe().f_code.co_name)
|
||||
print(locals())
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def softDollarTiers(self, reqId, tiers):
|
||||
print sys._getframe().f_code.co_name
|
||||
print locals()
|
||||
print(sys._getframe().f_code.co_name)
|
||||
print(locals())
|
||||
|
||||
|
||||
|
||||
@ -302,14 +305,14 @@ if __name__ == '__main__':
|
||||
api = TestApi()
|
||||
|
||||
n = api.eConnect('127.0.0.1', 7497, 123, False)
|
||||
print n
|
||||
print(n)
|
||||
|
||||
#t = api.TwsConnectionTime()
|
||||
#print t
|
||||
|
||||
#
|
||||
sleep(1)
|
||||
print 'req time'
|
||||
print('req time')
|
||||
api.reqCurrentTime()
|
||||
|
||||
#
|
||||
@ -319,6 +322,6 @@ if __name__ == '__main__':
|
||||
#print 'disconnect'
|
||||
#api.eDisconnect()
|
||||
|
||||
raw_input()
|
||||
input()
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user