Merge pull request #386 from find-happiness/master
Merge remote-tracking branch 'origin/dev'
This commit is contained in:
commit
065808a0b0
@ -12,9 +12,11 @@ from vnpy.trader.uiQt import qApp
|
||||
from vnpy.trader.uiMainWindow import MainWindow
|
||||
|
||||
# 加载底层接口
|
||||
from vnpy.trader.gateway import (ctpGateway, femasGateway, xspeedGateway,
|
||||
sgitGateway, oandaGateway, ibGateway,
|
||||
shzdGateway, huobiGateway, okcoinGateway)
|
||||
# from vnpy.trader.gateway import (ctpGateway, femasGateway, xspeedGateway,
|
||||
# sgitGateway, oandaGateway, ibGateway,
|
||||
# shzdGateway, huobiGateway, okcoinGateway)
|
||||
|
||||
from vnpy.trader.gateway import ( huobiGateway, okcoinGateway)
|
||||
|
||||
# 加载上层应用
|
||||
from vnpy.trader.app import (riskManager, ctaStrategy, spreadTrading)
|
||||
@ -30,13 +32,13 @@ def main():
|
||||
me = MainEngine(ee)
|
||||
|
||||
# 添加交易接口
|
||||
me.addGateway(ctpGateway)
|
||||
me.addGateway(femasGateway)
|
||||
me.addGateway(xspeedGateway)
|
||||
me.addGateway(sgitGateway)
|
||||
me.addGateway(oandaGateway)
|
||||
me.addGateway(ibGateway)
|
||||
me.addGateway(shzdGateway)
|
||||
# me.addGateway(ctpGateway)
|
||||
# me.addGateway(femasGateway)
|
||||
# me.addGateway(xspeedGateway)
|
||||
# me.addGateway(sgitGateway)
|
||||
# me.addGateway(oandaGateway)
|
||||
# me.addGateway(ibGateway)
|
||||
# me.addGateway(shzdGateway)
|
||||
me.addGateway(huobiGateway)
|
||||
me.addGateway(okcoinGateway)
|
||||
|
||||
|
@ -20,6 +20,7 @@ CURRENCY_USD = 'usd'
|
||||
# 电子货币代码
|
||||
SYMBOL_BTC = 'btc'
|
||||
SYMBOL_LTC = 'ltc'
|
||||
SYMBOL_ETH = 'eth'
|
||||
|
||||
# 行情深度
|
||||
DEPTH_20 = 20
|
||||
@ -42,6 +43,7 @@ INTERVAL_1W = 'week'
|
||||
# 交易代码,需要后缀货币名才能完整
|
||||
TRADING_SYMBOL_BTC = 'btc_'
|
||||
TRADING_SYMBOL_LTC = 'ltc_'
|
||||
TRADING_SYMBOL_ETH = 'eth_'
|
||||
|
||||
# 委托类型
|
||||
TYPE_BUY = 'buy'
|
||||
|
18
vnpy/trader/app/dataRecorder/DR_setting.json
Normal file
18
vnpy/trader/app/dataRecorder/DR_setting.json
Normal file
@ -0,0 +1,18 @@
|
||||
{
|
||||
"working": true,
|
||||
|
||||
"tick":
|
||||
[
|
||||
],
|
||||
|
||||
"bar":
|
||||
[
|
||||
["BTC_CNY_SPOT", "OKCOIN"],
|
||||
["LTC_CNY_SPOT", "OKCOIN"],
|
||||
["ETH_CNY_SPOT", "OKCOIN"]
|
||||
],
|
||||
|
||||
"active":
|
||||
{
|
||||
}
|
||||
}
|
@ -16,6 +16,7 @@ from copy import copy
|
||||
from threading import Condition
|
||||
from Queue import Queue
|
||||
from threading import Thread
|
||||
from time import sleep
|
||||
|
||||
from vnpy.api.okcoin import vnokcoin
|
||||
from vnpy.trader.vtGateway import *
|
||||
@ -55,16 +56,24 @@ LTC_USD_THISWEEK = 'LTC_USD_THISWEEK'
|
||||
LTC_USD_NEXTWEEK = 'LTC_USD_NEXTWEEK'
|
||||
LTC_USD_QUARTER = 'LTC_USD_QUARTER'
|
||||
|
||||
ETH_USD_SPOT = 'ETH_USD_SPOT'
|
||||
ETH_USD_THISWEEK = 'ETH_USD_THISWEEK'
|
||||
ETH_USD_NEXTWEEK = 'ETH_USD_NEXTWEEK'
|
||||
ETH_USD_QUARTER = 'ETH_USD_QUARTER'
|
||||
|
||||
# CNY
|
||||
BTC_CNY_SPOT = 'BTC_CNY_SPOT'
|
||||
LTC_CNY_SPOT = 'LTC_CNY_SPOT'
|
||||
ETH_CNY_SPOT = 'ETH_CNY_SPOT'
|
||||
|
||||
# 印射字典
|
||||
spotSymbolMap = {}
|
||||
spotSymbolMap['ltc_usd'] = LTC_USD_SPOT
|
||||
spotSymbolMap['btc_usd'] = BTC_USD_SPOT
|
||||
spotSymbolMap['ETH_usd'] = ETH_USD_SPOT
|
||||
spotSymbolMap['ltc_cny'] = LTC_CNY_SPOT
|
||||
spotSymbolMap['btc_cny'] = BTC_CNY_SPOT
|
||||
spotSymbolMap['eth_cny'] = ETH_CNY_SPOT
|
||||
spotSymbolMapReverse = {v: k for k, v in spotSymbolMap.items()}
|
||||
|
||||
|
||||
@ -76,16 +85,20 @@ channelSymbolMap = {}
|
||||
# USD
|
||||
channelSymbolMap['ok_sub_spotusd_btc_ticker'] = BTC_USD_SPOT
|
||||
channelSymbolMap['ok_sub_spotusd_ltc_ticker'] = LTC_USD_SPOT
|
||||
channelSymbolMap['ok_sub_spotusd_eth_ticker'] = ETH_USD_SPOT
|
||||
|
||||
channelSymbolMap['ok_sub_spotusd_btc_depth_20'] = BTC_USD_SPOT
|
||||
channelSymbolMap['ok_sub_spotusd_ltc_depth_20'] = LTC_USD_SPOT
|
||||
channelSymbolMap['ok_sub_spotusd_eth_depth_20'] = ETH_USD_SPOT
|
||||
|
||||
# CNY
|
||||
channelSymbolMap['ok_sub_spotcny_btc_ticker'] = BTC_CNY_SPOT
|
||||
channelSymbolMap['ok_sub_spotcny_ltc_ticker'] = LTC_CNY_SPOT
|
||||
channelSymbolMap['ok_sub_spotcny_eth_ticker'] = ETH_CNY_SPOT
|
||||
|
||||
channelSymbolMap['ok_sub_spotcny_btc_depth_20'] = BTC_CNY_SPOT
|
||||
channelSymbolMap['ok_sub_spotcny_ltc_depth_20'] = LTC_CNY_SPOT
|
||||
channelSymbolMap['ok_sub_spotcny_eth_depth_20'] = ETH_CNY_SPOT
|
||||
|
||||
|
||||
|
||||
@ -306,6 +319,7 @@ class Api(vnokcoin.OkCoinApi):
|
||||
|
||||
self.spotOrderInfo(vnokcoin.TRADING_SYMBOL_LTC, '-1')
|
||||
self.spotOrderInfo(vnokcoin.TRADING_SYMBOL_BTC, '-1')
|
||||
self.spotOrderInfo(vnokcoin.TRADING_SYMBOL_ETH, '-1')
|
||||
|
||||
# 连接后订阅现货的成交和账户数据
|
||||
self.subscribeSpotTrades()
|
||||
@ -313,9 +327,11 @@ class Api(vnokcoin.OkCoinApi):
|
||||
|
||||
self.subscribeSpotTicker(vnokcoin.SYMBOL_BTC)
|
||||
self.subscribeSpotTicker(vnokcoin.SYMBOL_LTC)
|
||||
self.subscribeSpotTicker(vnokcoin.SYMBOL_ETH)
|
||||
|
||||
self.subscribeSpotDepth(vnokcoin.SYMBOL_BTC, vnokcoin.DEPTH_20)
|
||||
self.subscribeSpotDepth(vnokcoin.SYMBOL_LTC, vnokcoin.DEPTH_20)
|
||||
self.subscribeSpotDepth(vnokcoin.SYMBOL_ETH, vnokcoin.DEPTH_20)
|
||||
|
||||
# 如果连接的是USD网站则订阅期货相关回报数据
|
||||
if self.currency == vnokcoin.CURRENCY_USD:
|
||||
@ -347,9 +363,11 @@ class Api(vnokcoin.OkCoinApi):
|
||||
# USD_SPOT
|
||||
self.cbDict['ok_sub_spotusd_btc_ticker'] = self.onTicker
|
||||
self.cbDict['ok_sub_spotusd_ltc_ticker'] = self.onTicker
|
||||
self.cbDict['ok_sub_spotusd_eth_ticker'] = self.onTicker
|
||||
|
||||
self.cbDict['ok_sub_spotusd_btc_depth_20'] = self.onDepth
|
||||
self.cbDict['ok_sub_spotusd_ltc_depth_20'] = self.onDepth
|
||||
self.cbDict['ok_sub_spotusd_eth_depth_20'] = self.onDepth
|
||||
|
||||
self.cbDict['ok_spotusd_userinfo'] = self.onSpotUserInfo
|
||||
self.cbDict['ok_spotusd_orderinfo'] = self.onSpotOrderInfo
|
||||
@ -363,9 +381,11 @@ class Api(vnokcoin.OkCoinApi):
|
||||
# CNY_SPOT
|
||||
self.cbDict['ok_sub_spotcny_btc_ticker'] = self.onTicker
|
||||
self.cbDict['ok_sub_spotcny_ltc_ticker'] = self.onTicker
|
||||
self.cbDict['ok_sub_spotcny_eth_ticker'] = self.onTicker
|
||||
|
||||
self.cbDict['ok_sub_spotcny_btc_depth_20'] = self.onDepth
|
||||
self.cbDict['ok_sub_spotcny_ltc_depth_20'] = self.onDepth
|
||||
self.cbDict['ok_sub_spotcny_eth_depth_20'] = self.onDepth
|
||||
|
||||
self.cbDict['ok_spotcny_userinfo'] = self.onSpotUserInfo
|
||||
self.cbDict['ok_spotcny_orderinfo'] = self.onSpotOrderInfo
|
||||
@ -453,7 +473,7 @@ class Api(vnokcoin.OkCoinApi):
|
||||
funds = rawData['info']['funds']
|
||||
|
||||
# 持仓信息
|
||||
for symbol in ['btc', 'ltc', self.currency]:
|
||||
for symbol in ['btc', 'ltc','eth', self.currency]:
|
||||
if symbol in funds['free']:
|
||||
pos = VtPositionData()
|
||||
pos.gatewayName = self.gatewayName
|
||||
@ -486,7 +506,7 @@ class Api(vnokcoin.OkCoinApi):
|
||||
info = rawData['info']
|
||||
|
||||
# 持仓信息
|
||||
for symbol in ['btc', 'ltc', self.currency]:
|
||||
for symbol in ['btc', 'ltc','eth', self.currency]:
|
||||
if symbol in info['free']:
|
||||
pos = VtPositionData()
|
||||
pos.gatewayName = self.gatewayName
|
||||
@ -617,6 +637,7 @@ class Api(vnokcoin.OkCoinApi):
|
||||
|
||||
contractList.append(self.generateSpecificContract(contract, BTC_CNY_SPOT))
|
||||
contractList.append(self.generateSpecificContract(contract, LTC_CNY_SPOT))
|
||||
contractList.append(self.generateSpecificContract(contract, ETH_CNY_SPOT))
|
||||
|
||||
return contractList
|
||||
|
||||
@ -634,6 +655,7 @@ class Api(vnokcoin.OkCoinApi):
|
||||
|
||||
contractList.append(self.generateSpecificContract(contract, BTC_USD_SPOT))
|
||||
contractList.append(self.generateSpecificContract(contract, LTC_USD_SPOT))
|
||||
contractList.append(self.generateSpecificContract(contract, ETH_USD_SPOT))
|
||||
|
||||
# 期货
|
||||
contract.productClass = PRODUCT_FUTURES
|
||||
@ -644,6 +666,9 @@ class Api(vnokcoin.OkCoinApi):
|
||||
contractList.append(self.generateSpecificContract(contract, LTC_USD_THISWEEK))
|
||||
contractList.append(self.generateSpecificContract(contract, LTC_USD_NEXTWEEK))
|
||||
contractList.append(self.generateSpecificContract(contract, LTC_USD_QUARTER))
|
||||
contractList.append(self.generateSpecificContract(contract, ETH_USD_THISWEEK))
|
||||
contractList.append(self.generateSpecificContract(contract, ETH_USD_NEXTWEEK))
|
||||
contractList.append(self.generateSpecificContract(contract, ETH_USD_QUARTER))
|
||||
|
||||
return contractList
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user