Merge pull request #850 from cclauss/modernize-beta

Modernize beta
This commit is contained in:
vn.py 2018-05-10 10:45:27 +08:00 committed by GitHub
commit c6d9541441
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
30 changed files with 170 additions and 138 deletions

View File

@ -1,3 +1,4 @@
# encoding: UTF-8 # encoding: UTF-8
from vncoincheck import TradeApi, DataApi from __future__ import absolute_import
from .vncoincheck import TradeApi, DataApi

View File

@ -1,6 +1,7 @@
# encoding: utf-8 # encoding: utf-8
from vncoincheck import * from __future__ import absolute_import
from .vncoincheck import *
def testTrade(): def testTrade():
"""测试交易""" """测试交易"""

View File

@ -1,6 +1,7 @@
# encoding: utf-8 # encoding: utf-8
from __future__ import print_function
from coincheck import order,market,account from coincheck import order,market,account
ok = order.Order(access_key="你的accessKey", secret_key="你的secretKey") ok = order.Order(access_key="你的accessKey", secret_key="你的secretKey")
print ok.buy_btc_jpy(amount=0.01,rate=200) print(ok.buy_btc_jpy(amount=0.01,rate=200))

View File

@ -1,6 +1,8 @@
# encoding: utf-8 # encoding: utf-8
from vncoincheck import * from __future__ import print_function
from __future__ import absolute_import
from .vncoincheck import *
import socket import socket
import json import json
@ -10,7 +12,7 @@ from websocket import create_connection
ws = None ws = None
def open(): def open():
global ws global ws
print "open" print("open")
ws.send( json.dumps({"type": "subscribe", "channel": "btc_jpy-trades"})) ws.send( json.dumps({"type": "subscribe", "channel": "btc_jpy-trades"}))
def testWebsocket(): def testWebsocket():
@ -20,7 +22,7 @@ def testWebsocket():
ws = create_connection("wss://ws-api.coincheck.com/", on_open=open) ws = create_connection("wss://ws-api.coincheck.com/", on_open=open)
if ws.connected: if ws.connected:
print ws.recv() print(ws.recv())
sleep(5) sleep(5)

View File

@ -1,6 +1,7 @@
# encoding: utf-8 # encoding: utf-8
from vncoincheck import * from __future__ import absolute_import
from .vncoincheck import *
def test(): def test():

View File

@ -1,5 +1,6 @@
# encoding: utf-8 # encoding: utf-8
from __future__ import print_function
import urllib import urllib
import hashlib import hashlib
@ -108,7 +109,7 @@ class TradeApi(object):
if r != None and r.status_code == 200: if r != None and r.status_code == 200:
data = r.json() data = r.json()
if data['success'] == 0: if data['success'] == 0:
print "error in coincheck %s" % method print("error in coincheck %s" % method)
return data return data
else: else:
return data return data
@ -116,7 +117,7 @@ class TradeApi(object):
try: try:
data = json.loads(r.text) data = json.loads(r.text)
return data return data
except Exception,ex: except Exception as ex:
return None return None
#---------------------------------------------------------------------- #----------------------------------------------------------------------
@ -138,12 +139,12 @@ class TradeApi(object):
# 请求成功 # 请求成功
if data != None : if data != None :
if self.DEBUG: if self.DEBUG:
print callback.__name__ print(callback.__name__)
callback(data, req, reqID) callback(data, req, reqID)
self.reqQueue.pop(0) self.reqQueue.pop(0)
sleep(0.1) sleep(0.1)
except Exception,ex: except Exception as ex:
pass pass
#---------------------------------------------------------------------- #----------------------------------------------------------------------
@ -205,11 +206,11 @@ class TradeApi(object):
return self.sendRequest( self.API_balance , FUNCTIONCODE_GET_BALANCE_COINCHECK , self.onGet_balance , None) return self.sendRequest( self.API_balance , FUNCTIONCODE_GET_BALANCE_COINCHECK , self.onGet_balance , None)
def buy_btc_jpy(self , **kwargs): def buy_btc_jpy(self , **kwargs):
print "buy_btc_jpy" print("buy_btc_jpy")
return self.sendRequest( self.API_trade , FUNCTIONCODE_BUY_ORDER_COINCHECK , self.onBuy_btc , kwargs = kwargs, optional = None) return self.sendRequest( self.API_trade , FUNCTIONCODE_BUY_ORDER_COINCHECK , self.onBuy_btc , kwargs = kwargs, optional = None)
def sell_btc_jpy(self, **kwargs): def sell_btc_jpy(self, **kwargs):
print "sell_btc_jpy" print("sell_btc_jpy")
return self.sendRequest( self.API_trade , FUNCTIONCODE_SELL_ORDER_COINCHECK , self.onSell_btc , kwargs = kwargs, optional = None) return self.sendRequest( self.API_trade , FUNCTIONCODE_SELL_ORDER_COINCHECK , self.onSell_btc , kwargs = kwargs, optional = None)
def list_orders(self): def list_orders(self):
@ -225,19 +226,19 @@ class TradeApi(object):
## 回调函数 ## 回调函数
#################################################### ####################################################
def onGet_info(self, data, req, reqID): def onGet_info(self, data, req, reqID):
print data print(data)
def onGet_balance(self, data, req, reqID): def onGet_balance(self, data, req, reqID):
print data print(data)
def onBuy_btc(self, data, req, reqID): def onBuy_btc(self, data, req, reqID):
print data print(data)
def onSell_btc(self, data, req, reqID): def onSell_btc(self, data, req, reqID):
print data print(data)
def onList_order(self, data, req, reqID): def onList_order(self, data, req, reqID):
print data print(data)
def onCancel_orders(self, data, req, reqID): def onCancel_orders(self, data, req, reqID):
print data print(data)
def onHistory_orders(self, data, req, reqID): def onHistory_orders(self, data, req, reqID):
print data print(data)
class DataApiSocket(object): class DataApiSocket(object):
"""基于websocket的API对象""" """基于websocket的API对象"""
@ -257,24 +258,24 @@ class DataApiSocket(object):
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def onMessage(self, ws, evt): def onMessage(self, ws, evt):
"""信息推送""" """信息推送"""
print 'onMessage' print('onMessage')
print evt print(evt)
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def onError(self, ws, evt): def onError(self, ws, evt):
"""错误推送""" """错误推送"""
print 'onError' print('onError')
print evt print(evt)
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def onClose(self, ws): def onClose(self, ws):
"""接口断开""" """接口断开"""
print 'onClose' print('onClose')
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def onOpen(self, ws): def onOpen(self, ws):
"""接口打开""" """接口打开"""
print "onOpen" print("onOpen")
self.sendOrderbookRequest() self.sendOrderbookRequest()
self.sendTradesRequest() self.sendTradesRequest()
@ -415,10 +416,10 @@ class DataApi(object):
if r.status_code == 200: if r.status_code == 200:
data = r.json() data = r.json()
if self.DEBUG: if self.DEBUG:
print callback.__name__ print(callback.__name__)
callback(data) callback(data)
except Exception, e: except Exception as e:
print e print(e)
sleep(self.taskInterval) sleep(self.taskInterval)
#---------------------------------------------------------------------- #----------------------------------------------------------------------
@ -445,16 +446,16 @@ class DataApi(object):
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def onTick(self, data): def onTick(self, data):
"""实时成交推送""" """实时成交推送"""
print data print(data)
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def onTrades(self, data): def onTrades(self, data):
"""实时成交推送""" """实时成交推送"""
print data print(data)
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def onOrderbooks(self, data): def onOrderbooks(self, data):
"""实时成交推送""" """实时成交推送"""
print data print(data)
if __name__ == '__main__': if __name__ == '__main__':
pass pass

View File

@ -1,3 +1,4 @@
# encoding: UTF-8 # encoding: UTF-8
from vnkorbit import Korbit_TradeApi, Korbit_DataApi , KORBIT_ALL_SYMBOL_PAIR , KORBIT_ALL_SYMBOLS from __future__ import absolute_import
from .vnkorbit import Korbit_TradeApi, Korbit_DataApi , KORBIT_ALL_SYMBOL_PAIR , KORBIT_ALL_SYMBOLS

View File

@ -1,6 +1,8 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from __future__ import print_function
from __future__ import absolute_import
import time import time
from public_api import PublicAPI from .public_api import PublicAPI
class PrivateAPI(PublicAPI): class PrivateAPI(PublicAPI):
@ -105,7 +107,7 @@ class PrivateAPI(PublicAPI):
'offset': offset, 'offset': offset,
'limit': limit 'limit': limit
} }
print "user/orders" , self.headers , params print("user/orders" , self.headers , params)
return self.request_get("user/orders", headers=self.headers, params=params) return self.request_get("user/orders", headers=self.headers, params=params)
def view_transfers(self, offset=0, limit=10, currency="btc"): def view_transfers(self, offset=0, limit=10, currency="btc"):

View File

@ -1,5 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from __future__ import print_function
import requests import requests
import json import json
import logging import logging
@ -53,9 +54,9 @@ class PublicAPI:
return self.request_get("constants") return self.request_get("constants")
def request_get(self, path, headers=None, params=None): def request_get(self, path, headers=None, params=None):
print urljoin(self.host, path) print(urljoin(self.host, path))
response = requests.get(urljoin(self.host, path), headers=headers, params=params, timeout=self.__timeout) response = requests.get(urljoin(self.host, path), headers=headers, params=params, timeout=self.__timeout)
print response print(response)
try: try:
return response.json() return response.json()
except json.decoder.JSONDecodeError as e: except json.decoder.JSONDecodeError as e:
@ -63,9 +64,9 @@ class PublicAPI:
return response.text return response.text
def request_post(self, path, headers=None, data=None): def request_post(self, path, headers=None, data=None):
print urljoin(self.host, path) , headers , data print(urljoin(self.host, path) , headers , data)
response = requests.post(urljoin(self.host, path), headers=headers, data=data, timeout=self.__timeout) response = requests.post(urljoin(self.host, path), headers=headers, data=data, timeout=self.__timeout)
print response print(response)
try: try:
return response.json() return response.json()
except json.decoder.JSONDecodeError as e: except json.decoder.JSONDecodeError as e:

View File

@ -1,10 +1,12 @@
# encoding: utf-8 # encoding: utf-8
from private_api import * from __future__ import print_function
from __future__ import absolute_import
from .private_api import *
api = PrivateAPI('FssV9Jw0aZVCOYbu9YlqVNc2Rhgmh1QpruNgSVhvVmFP1iw1aPfc3APbfz0ZM', 'lSMc1TT2AZYX5pyEm01SFqx7PgMjNB18eXWpi8DQKHf0rcYhLiaiRVzJwaVZR') api = PrivateAPI('FssV9Jw0aZVCOYbu9YlqVNc2Rhgmh1QpruNgSVhvVmFP1iw1aPfc3APbfz0ZM', 'lSMc1TT2AZYX5pyEm01SFqx7PgMjNB18eXWpi8DQKHf0rcYhLiaiRVzJwaVZR')
print api.create_token_directly('xiaoshuang8921@naver.com', 'Wxiaoshuang8921') print(api.create_token_directly('xiaoshuang8921@naver.com', 'Wxiaoshuang8921'))
# print api.view_exchange_orders( 0 , 10 , "btc_krw") # print api.view_exchange_orders( 0 , 10 , "btc_krw")
#api.limit_bid_order(coin_amount = 0.01 , price = 1000 , currency_pair="btc_krw") #api.limit_bid_order(coin_amount = 0.01 , price = 1000 , currency_pair="btc_krw")

View File

@ -1,6 +1,7 @@
# encoding: UTF-8 # encoding: UTF-8
from vnkorbit import Korbit_TradeApi , Korbit_DataApi from __future__ import absolute_import
from .vnkorbit import Korbit_TradeApi , Korbit_DataApi
apiKey = 'FssV9Jw0aZVCOYbu9YlqVNc2Rhgmh1QpruNgSVhvVmFP1iw1aPfc3APbfz0ZM' apiKey = 'FssV9Jw0aZVCOYbu9YlqVNc2Rhgmh1QpruNgSVhvVmFP1iw1aPfc3APbfz0ZM'
secretKey = 'lSMc1TT2AZYX5pyEm01SFqx7PgMjNB18eXWpi8DQKHf0rcYhLiaiRVzJwaVZR' secretKey = 'lSMc1TT2AZYX5pyEm01SFqx7PgMjNB18eXWpi8DQKHf0rcYhLiaiRVzJwaVZR'

View File

@ -1,5 +1,6 @@
# encoding: utf-8 # encoding: utf-8
from __future__ import print_function
import urllib import urllib
import hashlib import hashlib
@ -63,7 +64,7 @@ class Korbit_TradeApi(object):
try: try:
return response.json() return response.json()
except json.decoder.JSONDecodeError as e: except json.decoder.JSONDecodeError as e:
print "exception: {}, response_text: {}".format(e, response.text) print("exception: {}, response_text: {}".format(e, response.text))
return response.text return response.text
''' '''
@ -170,10 +171,10 @@ class Korbit_TradeApi(object):
else: else:
try: try:
data = json.loads(r.text) data = json.loads(r.text)
print "Error in r , " , data print("Error in r , " , data)
return data return data
except Exception,ex: except Exception as ex:
print ex print(ex)
return None return None
#---------------------------------------------------------------------- #----------------------------------------------------------------------
@ -194,13 +195,13 @@ class Korbit_TradeApi(object):
# 请求成功 # 请求成功
if data != None : if data != None :
if self.DEBUG: if self.DEBUG:
print callback.__name__ print(callback.__name__)
callback(data, req, reqID) callback(data, req, reqID)
sleep(0.1) sleep(0.1)
except Exception,ex: except Exception as ex:
print ex print(ex)
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def sendRequest(self, url , method, callback, kwargs = None,optional=None): def sendRequest(self, url , method, callback, kwargs = None,optional=None):
@ -277,19 +278,19 @@ class Korbit_TradeApi(object):
## 回调函数 ## 回调函数
#################################################### ####################################################
def on_buy_currency(self, data , req, reqID): def on_buy_currency(self, data , req, reqID):
print data print(data)
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def on_sell_currency(self, data , req, reqID): def on_sell_currency(self, data , req, reqID):
print data print(data)
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def on_list_exchange_orders(self, data , req, reqID): def on_list_exchange_orders(self, data , req, reqID):
print data print(data)
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def onCancelOrders(self, data , req, reqID): def onCancelOrders(self, data , req, reqID):
print data print(data)
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def onBalances(self, data , req, reqID): def onBalances(self, data , req, reqID):
print data print(data)
class Korbit_DataApi(object): class Korbit_DataApi(object):
@ -334,10 +335,10 @@ class Korbit_DataApi(object):
data = r.json() data = r.json()
data["symbol"] = symbol data["symbol"] = symbol
if self.DEBUG: if self.DEBUG:
print callback.__name__ print(callback.__name__)
callback(data) callback(data)
except Exception, e: except Exception as e:
print "Korbit_DataApi" , e print("Korbit_DataApi" , e)
sleep(self.taskInterval) sleep(self.taskInterval)
#---------------------------------------------------------------------- #----------------------------------------------------------------------
@ -365,13 +366,13 @@ class Korbit_DataApi(object):
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def onTick(self, data): def onTick(self, data):
"""实时成交推送""" """实时成交推送"""
print data print(data)
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def onTrades(self, data): def onTrades(self, data):
"""实时成交推送""" """实时成交推送"""
print data print(data)
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def onOrderbooks(self, data): def onOrderbooks(self, data):
"""实时成交推送""" """实时成交推送"""
print data print(data)

View File

@ -1,3 +1,4 @@
# encoding: UTF-8 # encoding: UTF-8
from vnokex import OkexSpotApi, OkexFuturesApi, CONTRACT_SYMBOL, SPOT_CURRENCY from __future__ import absolute_import
from .vnokex import OkexSpotApi, OkexFuturesApi, CONTRACT_SYMBOL, SPOT_CURRENCY

View File

@ -1,6 +1,7 @@
# encoding: UTF-8 # encoding: UTF-8
from vnokex import * from __future__ import absolute_import
from .vnokex import *
# 在OkCoin网站申请这两个Key分别对应用户名和密码 # 在OkCoin网站申请这两个Key分别对应用户名和密码
apiKey = '你的accessKey' apiKey = '你的accessKey'

View File

@ -1,5 +1,6 @@
# encoding: UTF-8 # encoding: UTF-8
from __future__ import print_function
import hashlib import hashlib
import zlib import zlib
import json import json
@ -129,23 +130,23 @@ class OkexApi(object):
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def onMessage(self, ws, evt): def onMessage(self, ws, evt):
"""信息推送""" """信息推送"""
print evt print(evt)
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def onError(self, ws, evt): def onError(self, ws, evt):
"""错误推送""" """错误推送"""
print 'onError' print('onError')
print evt print(evt)
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def onClose(self, ws): def onClose(self, ws):
"""接口断开""" """接口断开"""
print 'onClose' print('onClose')
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def onOpen(self, ws): def onOpen(self, ws):
"""接口打开""" """接口打开"""
print 'onOpen' print('onOpen')
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def generateSign(self, params): def generateSign(self, params):

View File

@ -1,3 +1,4 @@
# encoding: UTF-8 # encoding: UTF-8
from vnzaif import TradeApi, DataApi from __future__ import absolute_import
from .vnzaif import TradeApi, DataApi

View File

@ -1,6 +1,7 @@
# encoding: utf-8 # encoding: utf-8
from vnzaif import * from __future__ import absolute_import
from .vnzaif import *
def testTrade(): def testTrade():
"""测试交易""" """测试交易"""

View File

@ -1,5 +1,6 @@
# encoding: utf-8 # encoding: utf-8
from __future__ import print_function
import urllib import urllib
import hashlib import hashlib
@ -175,11 +176,11 @@ class TradeApi(object):
try: try:
data = r.json() data = r.json()
if data['success'] == 0: if data['success'] == 0:
print "error in vnzaif %s" % method print("error in vnzaif %s" % method)
return data return data
else: else:
return data return data
except Exception,ex: except Exception as ex:
return None return None
else: else:
return None return None
@ -218,7 +219,7 @@ class TradeApi(object):
# 请求成功 # 请求成功
else: else:
if self.DEBUG: if self.DEBUG:
print callback.__name__ print(callback.__name__)
callback(data, req, reqID) callback(data, req, reqID)
except Empty: except Empty:
@ -344,29 +345,29 @@ class TradeApi(object):
print data print data
''' '''
def onTrade(self, data, req, reqID): def onTrade(self, data, req, reqID):
print data print(data)
def onCancelOrder(self, data, req, reqID): def onCancelOrder(self, data, req, reqID):
print data print(data)
def onWithdraw(self, data, req, reqID): def onWithdraw(self, data, req, reqID):
print data print(data)
def onDepositHistory(self, data, req, reqID): def onDepositHistory(self, data, req, reqID):
print data print(data)
def onWithdrawHistory(self, data, req, reqID): def onWithdrawHistory(self, data, req, reqID):
print data print(data)
def onTradeHistory(self, data, req, reqID): def onTradeHistory(self, data, req, reqID):
print data print(data)
def onActiveOrders(self, data, req, reqID): def onActiveOrders(self, data, req, reqID):
print data print(data)
def onGet_info2(self, data, req, reqID): def onGet_info2(self, data, req, reqID):
"""用户信息""" """用户信息"""
print data print(data)
@ -435,13 +436,13 @@ class DataApi(object):
if r.status_code == 200: if r.status_code == 200:
data = r.json() data = r.json()
if self.DEBUG: if self.DEBUG:
print callback.__name__ print(callback.__name__)
data = {"return_symbol": (url.split('/'))[-1].split('_')[0] , "data":data} data = {"return_symbol": (url.split('/'))[-1].split('_')[0] , "data":data}
#data["return_symbol"] = #data["return_symbol"] =
callback(data) callback(data)
except Exception, e: except Exception as e:
print e print(e)
sleep(self.taskInterval) sleep(self.taskInterval)
@ -483,18 +484,18 @@ class DataApi(object):
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def onTick(self, data): def onTick(self, data):
"""实时成交推送""" """实时成交推送"""
print data print(data)
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def onLast(self, data): def onLast(self, data):
"""实时深度推送""" """实时深度推送"""
print data print(data)
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def onTrades(self, data): def onTrades(self, data):
"""实时深度推送""" """实时深度推送"""
print data print(data)
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def onDepth(self, data): def onDepth(self, data):
"""实时深度推送""" """实时深度推送"""
print data print(data)

View File

@ -1,3 +1,4 @@
# encoding: UTF-8 # encoding: UTF-8
from vnzb import ZB_Sub_Spot_Api , zb_all_symbol_pairs , zb_all_symbols , zb_all_real_pair from __future__ import absolute_import
from .vnzb import ZB_Sub_Spot_Api , zb_all_symbol_pairs , zb_all_symbols , zb_all_real_pair

View File

@ -1,6 +1,7 @@
# encoding: UTF-8 # encoding: UTF-8
from vnzb import * from __future__ import absolute_import
from .vnzb import *
# 在OkCoin网站申请这两个Key分别对应用户名和密码 # 在OkCoin网站申请这两个Key分别对应用户名和密码
apiKey = '你的apiKey' apiKey = '你的apiKey'

View File

@ -1,15 +1,16 @@
# encoding: UTF-8 # encoding: UTF-8
from __future__ import print_function
import hashlib import hashlib
import zlib
import json import json
from time import sleep import sha
import struct
from threading import Thread from threading import Thread
from six import xrange
import websocket import websocket
import urllib2, hashlib,struct,sha,time
# OKEX网站 # OKEX网站
zb_usd_url = "wss://api.zb.com:9999/websocket" zb_usd_url = "wss://api.zb.com:9999/websocket"
@ -88,23 +89,23 @@ class ZB_Sub_Spot_Api(object):
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def onMessage(self, ws, evt): def onMessage(self, ws, evt):
"""信息推送""" """信息推送"""
print evt print(evt)
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def onError(self, ws, evt): def onError(self, ws, evt):
"""错误推送""" """错误推送"""
print 'onError' print('onError')
print evt print(evt)
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def onClose(self, ws): def onClose(self, ws):
"""接口断开""" """接口断开"""
print 'onClose' print('onClose')
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def onOpen(self, ws): def onOpen(self, ws):
"""接口打开""" """接口打开"""
print 'onOpen' print('onOpen')
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def subscribeSpotTicker(self, symbol_pair): def subscribeSpotTicker(self, symbol_pair):
@ -210,7 +211,7 @@ class ZB_Sub_Spot_Api(object):
channel = symbol_pair.lower() + "_order" channel = symbol_pair.lower() + "_order"
print channel , str(type_) , str(price) , str(amount) print(channel , str(type_) , str(price) , str(amount))
self.sendTradingRequest(channel, params) self.sendTradingRequest(channel, params)
#---------------------------------------------------------------------- #----------------------------------------------------------------------

View File

@ -1,7 +1,8 @@
# encoding: UTF-8 # encoding: UTF-8
from __future__ import absolute_import
from vnpy.trader import vtConstant from vnpy.trader import vtConstant
from coincheckGateway import CoincheckGateway, CoincheckTradeApi , CoincheckSocketDataApi from .coincheckGateway import CoincheckGateway, CoincheckTradeApi , CoincheckSocketDataApi
gatewayClass = CoincheckGateway gatewayClass = CoincheckGateway
gatewayName = 'COINCHECK' gatewayName = 'COINCHECK'

View File

@ -3,6 +3,7 @@
''' '''
vn.coincheck的gateway接入 vn.coincheck的gateway接入
''' '''
from __future__ import print_function
import os import os
import json import json
from datetime import datetime from datetime import datetime
@ -146,7 +147,7 @@ class CoincheckGateway(VtGateway):
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def onListOrder(self, data): def onListOrder(self, data):
print data print(data)
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def setQryEnabled(self, qryEnabled): def setQryEnabled(self, qryEnabled):
@ -181,7 +182,7 @@ class CoincheckTradeApi(vncoincheck.TradeApi):
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def onError(self, method ,data): def onError(self, method ,data):
print method , data print(method , data)
# #
''' '''
"return" : "return" :
@ -191,7 +192,7 @@ ty_status': u'identity_verified', u'id': 1007549}
''' '''
def onGet_info(self, data, req, reqID): def onGet_info(self, data, req, reqID):
"""用户信息""" """用户信息"""
print data print(data)
''' '''
{u'zec': u'0', u'rep_debt': u'0.0', u'xem': u'0', u'lsk': u'0', u'rep_lend_in_use': u'0.0', u'ltc_de {u'zec': u'0', u'rep_debt': u'0.0', u'xem': u'0', u'lsk': u'0', u'rep_lend_in_use': u'0.0', u'ltc_de
bt': u'0.0', u'xmr_reserved': u'0.0', u'cny': u'0', u'btc_reserved': u'0.0', u'dao_reserved': u'0.0' bt': u'0.0', u'xmr_reserved': u'0.0', u'cny': u'0', u'btc_reserved': u'0.0', u'dao_reserved': u'0.0'
@ -215,8 +216,8 @@ u'dash': u'0', u'cny_debt': u'0.0', u'xrp_lend_in_use': u'0.0', u'xem_reserved':
''' '''
def onGet_balance(self, data, req, reqID): def onGet_balance(self, data, req, reqID):
if data["success"] == 0: if data["success"] == 0:
print "Error in onGet_balance" print("Error in onGet_balance")
print data print(data)
else: else:
account = VtAccountData() account = VtAccountData()
account.gatewayName = self.gatewayName account.gatewayName = self.gatewayName
@ -308,8 +309,8 @@ u'id': 324141928}
# print "onBuy_btc" # print "onBuy_btc"
# print data # print data
if data["success"] == 0: if data["success"] == 0:
print "Error in onBuy_btc" print("Error in onBuy_btc")
print data print(data)
else: else:
localID = self.reqLocalDict[reqID] localID = self.reqLocalDict[reqID]
systemID = data['id'] systemID = data['id']
@ -335,7 +336,7 @@ u'id': 324141928}
# print data # print data
"""卖出回调""" """卖出回调"""
if data["success"] == 0: if data["success"] == 0:
print "Error in onSell_btc" print("Error in onSell_btc")
else: else:
localID = self.reqLocalDict[reqID] localID = self.reqLocalDict[reqID]
systemID = data['id'] systemID = data['id']
@ -513,7 +514,7 @@ pending_market_buy_amount': None, u'rate': u'100.0', u'pair': u'btc_jpy', u'stop
self.gateway.onOrder(order) self.gateway.onOrder(order)
def onHistory_orders(self, data, req, reqID): def onHistory_orders(self, data, req, reqID):
print data print(data)
def cancel(self, req): def cancel(self, req):
localID = req.orderID localID = req.orderID
@ -594,7 +595,7 @@ class CoincheckSocketDataApi(vncoincheck.DataApiSocket):
tick.bidPrice3, tick.bidVolume3 = bids[2] tick.bidPrice3, tick.bidVolume3 = bids[2]
tick.bidPrice4, tick.bidVolume4 = bids[3] tick.bidPrice4, tick.bidVolume4 = bids[3]
tick.bidPrice5, tick.bidVolume5 = bids[4] tick.bidPrice5, tick.bidVolume5 = bids[4]
except Exception,ex: except Exception as ex:
pass pass
try: try:
@ -603,7 +604,7 @@ class CoincheckSocketDataApi(vncoincheck.DataApiSocket):
tick.askPrice3, tick.askVolume3 = asks[2] tick.askPrice3, tick.askVolume3 = asks[2]
tick.askPrice4, tick.askVolume4 = asks[3] tick.askPrice4, tick.askVolume4 = asks[3]
tick.askPrice5, tick.askVolume5 = asks[4] tick.askPrice5, tick.askVolume5 = asks[4]
except Exception,ex: except Exception as ex:
pass pass
now = datetime.now() now = datetime.now()
@ -716,7 +717,7 @@ class CoincheckDataApi(vncoincheck.DataApi):
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def onTrades(self, data): def onTrades(self, data):
"""实时成交推送""" """实时成交推送"""
print data print(data)
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def onOrderbooks(self, data): def onOrderbooks(self, data):

View File

@ -1,7 +1,8 @@
# encoding: UTF-8 # encoding: UTF-8
from __future__ import absolute_import
from vnpy.trader import vtConstant from vnpy.trader import vtConstant
from korbitGateway import korbitGateway from .korbitGateway import korbitGateway
gatewayClass = korbitGateway gatewayClass = korbitGateway
gatewayName = 'KORBIT' gatewayName = 'KORBIT'

View File

@ -3,6 +3,7 @@
''' '''
vn.coincheck的gateway接入 vn.coincheck的gateway接入
''' '''
from __future__ import print_function
import os import os
import json import json
from datetime import datetime from datetime import datetime
@ -255,13 +256,13 @@ class KorbitTradeApi(vnkorbit.Korbit_TradeApi):
#-------------------------------------------------------------------- #--------------------------------------------------------------------
def onError(self, method ,data): def onError(self, method ,data):
print method , data print(method , data)
#-------------------------------------------------------------------- #--------------------------------------------------------------------
def on_buy_currency(self, data , req, reqID): def on_buy_currency(self, data , req, reqID):
if data["status"] != "success": if data["status"] != "success":
print "Error in on_buy_currency" print("Error in on_buy_currency")
print data print(data)
else: else:
localID = self.reqLocalDict[reqID] localID = self.reqLocalDict[reqID]
systemID = str(data['orderId']) systemID = str(data['orderId'])
@ -286,7 +287,7 @@ class KorbitTradeApi(vnkorbit.Korbit_TradeApi):
def on_sell_currency(self, data , req, reqID): def on_sell_currency(self, data , req, reqID):
"""卖出回调""" """卖出回调"""
if data["status"] != "success": if data["status"] != "success":
print "Error in on_sell_currency" print("Error in on_sell_currency")
else: else:
localID = self.reqLocalDict[reqID] localID = self.reqLocalDict[reqID]
systemID = str(data['orderId']) systemID = str(data['orderId'])
@ -306,7 +307,7 @@ class KorbitTradeApi(vnkorbit.Korbit_TradeApi):
self.tradedVolumeDict[localID] = 0.0 self.tradedVolumeDict[localID] = 0.0
self.gateway.onOrder(order) self.gateway.onOrder(order)
print "what" print("what")
#-------------------------------------------------------------------- #--------------------------------------------------------------------
def on_list_exchange_orders(self, data , req, reqID): def on_list_exchange_orders(self, data , req, reqID):

View File

@ -1,7 +1,8 @@
# encoding: UTF-8 # encoding: UTF-8
from __future__ import absolute_import
from vnpy.trader import vtConstant from vnpy.trader import vtConstant
from okexGateway import okexGateway from .okexGateway import okexGateway
gatewayClass = okexGateway gatewayClass = okexGateway
gatewayName = 'OKEX' gatewayName = 'OKEX'

View File

@ -6,6 +6,7 @@ vnpy.api.okex的gateway接入
注意 注意
1. 目前仅支持USD现货交易 1. 目前仅支持USD现货交易
''' '''
from __future__ import print_function
import os import os
import json import json
@ -232,7 +233,7 @@ class SpotApi(OkexSpotApi):
data = self.readData(evt)[0] data = self.readData(evt)[0]
try: try:
channel = data['channel'] channel = data['channel']
except Exception,ex: except Exception as ex:
channel = None channel = None
if channel == None: if channel == None:
return return
@ -310,7 +311,7 @@ class SpotApi(OkexSpotApi):
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def spotAllOrders(self): def spotAllOrders(self):
print spotAllOrders print(spotAllOrders)
for symbol in registerSymbolPairArray: for symbol in registerSymbolPairArray:
if symbol in okex_all_symbol_pairs: if symbol in okex_all_symbol_pairs:
self.spotOrderInfo(symbol, '-1') self.spotOrderInfo(symbol, '-1')
@ -453,8 +454,8 @@ class SpotApi(OkexSpotApi):
# print "ticker", tick.date, tick.time # print "ticker", tick.date, tick.time
# newtick = copy(tick) # newtick = copy(tick)
# self.gateway.onTick(newtick) # self.gateway.onTick(newtick)
except Exception,ex: except Exception as ex:
print "Error in onTicker ", channel print("Error in onTicker ", channel)
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def onDepth(self, data): def onDepth(self, data):
@ -464,7 +465,7 @@ class SpotApi(OkexSpotApi):
try: try:
channel = data['channel'] channel = data['channel']
symbol = self.channelSymbolMap[channel] symbol = self.channelSymbolMap[channel]
except Exception,ex: except Exception as ex:
symbol = None symbol = None
if symbol == None: if symbol == None:
@ -789,7 +790,7 @@ nel': u'ok_sub_spot_etc_usdt_order'}
def onSpotOrderInfo(self, data): def onSpotOrderInfo(self, data):
"""委托信息查询回调""" """委托信息查询回调"""
if "error_code" in data.keys(): if "error_code" in data.keys():
print data print(data)
return return
rawData = data['data'] rawData = data['data']
for d in rawData['orders']: for d in rawData['orders']:
@ -839,7 +840,7 @@ nel': u'ok_sub_spot_etc_usdt_order'}
def onSpotOrder(self, data): def onSpotOrder(self, data):
rawData = data['data'] rawData = data['data']
if 'error_code' in rawData.keys(): if 'error_code' in rawData.keys():
print data print(data)
return return
orderId = str(rawData['order_id']) orderId = str(rawData['order_id'])

View File

@ -1,7 +1,8 @@
# encoding: UTF-8 # encoding: UTF-8
from __future__ import absolute_import
from vnpy.trader import vtConstant from vnpy.trader import vtConstant
from zbGateway import zbGateway from .zbGateway import zbGateway
gatewayClass = zbGateway gatewayClass = zbGateway
gatewayName = 'ZB' gatewayName = 'ZB'

View File

@ -3,6 +3,7 @@
''' '''
vn.zb的gateway接入 vn.zb的gateway接入
''' '''
from __future__ import print_function
import os import os
import json import json
from datetime import datetime from datetime import datetime
@ -224,7 +225,7 @@ class ZB_API_Spot(ZB_Sub_Spot_Api):
data = self.readData(evt) data = self.readData(evt)
try: try:
channel = data['channel'] channel = data['channel']
except Exception,ex: except Exception as ex:
channel = None channel = None
if channel == None: if channel == None:
return return
@ -379,8 +380,8 @@ class ZB_API_Spot(ZB_Sub_Spot_Api):
# print "ticker", tick.date , tick.time # print "ticker", tick.date , tick.time
# newtick = copy(tick) # newtick = copy(tick)
# self.gateway.onTick(newtick) # self.gateway.onTick(newtick)
except Exception,ex: except Exception as ex:
print "Error in onTicker " , channel print("Error in onTicker " , channel)
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def onDepth(self, data): def onDepth(self, data):
@ -388,7 +389,7 @@ class ZB_API_Spot(ZB_Sub_Spot_Api):
try: try:
channel = data['channel'] channel = data['channel']
symbol = self.channelSymbolMap[channel] symbol = self.channelSymbolMap[channel]
except Exception,ex: except Exception as ex:
symbol = None symbol = None
if symbol == None: if symbol == None:
@ -605,7 +606,7 @@ class ZB_API_Spot(ZB_Sub_Spot_Api):
# 现在的处理方式是, 先缓存这里的信息,等到出现了 localID再来处理这一段 # 现在的处理方式是, 先缓存这里的信息,等到出现了 localID再来处理这一段
localNo = self.orderIdDict.get(orderId , None) localNo = self.orderIdDict.get(orderId , None)
if localNo == None: if localNo == None:
print "Error , localNo is none !" + str(localNo) print("Error , localNo is none !" + str(localNo))
return return
# 委托信息 # 委托信息
@ -812,8 +813,8 @@ class ZB_API_Spot(ZB_Sub_Spot_Api):
rawData = json.loads(rawData) rawData = json.loads(rawData)
coins = rawData["coins"] coins = rawData["coins"]
except Exception,ex: except Exception as ex:
print ex print(ex)
for coin in coins: for coin in coins:
symbol = coin["cnName"].lower() symbol = coin["cnName"].lower()

View File

@ -184,8 +184,8 @@ class StSpread(object):
askok = True askok = True
for k in self.code.co_names : for k in self.code.co_names :
bidok = bidok and legbidglobal.has_key(k) bidok = bidok and k in legbidglobal
askok = askok and legaskglobal.has_key(k) askok = askok and k in legaskglobal
if bidok and askok : if bidok and askok :
self.bidPrice = eval(self.code,legbidglobal) self.bidPrice = eval(self.code,legbidglobal)