commit
c6d9541441
@ -1,3 +1,4 @@
|
||||
# encoding: UTF-8
|
||||
|
||||
from vncoincheck import TradeApi, DataApi
|
||||
from __future__ import absolute_import
|
||||
from .vncoincheck import TradeApi, DataApi
|
@ -1,6 +1,7 @@
|
||||
# encoding: utf-8
|
||||
|
||||
from vncoincheck import *
|
||||
from __future__ import absolute_import
|
||||
from .vncoincheck import *
|
||||
|
||||
def testTrade():
|
||||
"""测试交易"""
|
||||
|
@ -1,6 +1,7 @@
|
||||
# encoding: utf-8
|
||||
|
||||
from __future__ import print_function
|
||||
from coincheck import order,market,account
|
||||
|
||||
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))
|
@ -1,6 +1,8 @@
|
||||
# encoding: utf-8
|
||||
|
||||
from vncoincheck import *
|
||||
from __future__ import print_function
|
||||
from __future__ import absolute_import
|
||||
from .vncoincheck import *
|
||||
|
||||
import socket
|
||||
import json
|
||||
@ -10,7 +12,7 @@ from websocket import create_connection
|
||||
ws = None
|
||||
def open():
|
||||
global ws
|
||||
print "open"
|
||||
print("open")
|
||||
ws.send( json.dumps({"type": "subscribe", "channel": "btc_jpy-trades"}))
|
||||
|
||||
def testWebsocket():
|
||||
@ -20,7 +22,7 @@ def testWebsocket():
|
||||
ws = create_connection("wss://ws-api.coincheck.com/", on_open=open)
|
||||
if ws.connected:
|
||||
|
||||
print ws.recv()
|
||||
print(ws.recv())
|
||||
|
||||
sleep(5)
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
# encoding: utf-8
|
||||
|
||||
from vncoincheck import *
|
||||
from __future__ import absolute_import
|
||||
from .vncoincheck import *
|
||||
|
||||
def test():
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
# encoding: utf-8
|
||||
|
||||
from __future__ import print_function
|
||||
import urllib
|
||||
import hashlib
|
||||
|
||||
@ -108,7 +109,7 @@ class TradeApi(object):
|
||||
if r != None and r.status_code == 200:
|
||||
data = r.json()
|
||||
if data['success'] == 0:
|
||||
print "error in coincheck %s" % method
|
||||
print("error in coincheck %s" % method)
|
||||
return data
|
||||
else:
|
||||
return data
|
||||
@ -116,7 +117,7 @@ class TradeApi(object):
|
||||
try:
|
||||
data = json.loads(r.text)
|
||||
return data
|
||||
except Exception,ex:
|
||||
except Exception as ex:
|
||||
return None
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
@ -138,12 +139,12 @@ class TradeApi(object):
|
||||
# 请求成功
|
||||
if data != None :
|
||||
if self.DEBUG:
|
||||
print callback.__name__
|
||||
print(callback.__name__)
|
||||
callback(data, req, reqID)
|
||||
|
||||
self.reqQueue.pop(0)
|
||||
sleep(0.1)
|
||||
except Exception,ex:
|
||||
except Exception as ex:
|
||||
pass
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
@ -205,11 +206,11 @@ class TradeApi(object):
|
||||
return self.sendRequest( self.API_balance , FUNCTIONCODE_GET_BALANCE_COINCHECK , self.onGet_balance , None)
|
||||
|
||||
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)
|
||||
|
||||
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)
|
||||
|
||||
def list_orders(self):
|
||||
@ -225,19 +226,19 @@ class TradeApi(object):
|
||||
## 回调函数
|
||||
####################################################
|
||||
def onGet_info(self, data, req, reqID):
|
||||
print data
|
||||
print(data)
|
||||
def onGet_balance(self, data, req, reqID):
|
||||
print data
|
||||
print(data)
|
||||
def onBuy_btc(self, data, req, reqID):
|
||||
print data
|
||||
print(data)
|
||||
def onSell_btc(self, data, req, reqID):
|
||||
print data
|
||||
print(data)
|
||||
def onList_order(self, data, req, reqID):
|
||||
print data
|
||||
print(data)
|
||||
def onCancel_orders(self, data, req, reqID):
|
||||
print data
|
||||
print(data)
|
||||
def onHistory_orders(self, data, req, reqID):
|
||||
print data
|
||||
print(data)
|
||||
|
||||
class DataApiSocket(object):
|
||||
"""基于websocket的API对象"""
|
||||
@ -257,24 +258,24 @@ class DataApiSocket(object):
|
||||
#----------------------------------------------------------------------
|
||||
def onMessage(self, ws, evt):
|
||||
"""信息推送"""
|
||||
print 'onMessage'
|
||||
print evt
|
||||
print('onMessage')
|
||||
print(evt)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def onError(self, ws, evt):
|
||||
"""错误推送"""
|
||||
print 'onError'
|
||||
print evt
|
||||
print('onError')
|
||||
print(evt)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def onClose(self, ws):
|
||||
"""接口断开"""
|
||||
print 'onClose'
|
||||
print('onClose')
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def onOpen(self, ws):
|
||||
"""接口打开"""
|
||||
print "onOpen"
|
||||
print("onOpen")
|
||||
self.sendOrderbookRequest()
|
||||
self.sendTradesRequest()
|
||||
|
||||
@ -415,10 +416,10 @@ class DataApi(object):
|
||||
if r.status_code == 200:
|
||||
data = r.json()
|
||||
if self.DEBUG:
|
||||
print callback.__name__
|
||||
print(callback.__name__)
|
||||
callback(data)
|
||||
except Exception, e:
|
||||
print e
|
||||
except Exception as e:
|
||||
print(e)
|
||||
sleep(self.taskInterval)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
@ -445,16 +446,16 @@ class DataApi(object):
|
||||
#----------------------------------------------------------------------
|
||||
def onTick(self, data):
|
||||
"""实时成交推送"""
|
||||
print data
|
||||
print(data)
|
||||
#----------------------------------------------------------------------
|
||||
def onTrades(self, data):
|
||||
"""实时成交推送"""
|
||||
print data
|
||||
print(data)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def onOrderbooks(self, data):
|
||||
"""实时成交推送"""
|
||||
print data
|
||||
print(data)
|
||||
|
||||
if __name__ == '__main__':
|
||||
pass
|
||||
|
@ -1,3 +1,4 @@
|
||||
# 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
|
@ -1,6 +1,8 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import print_function
|
||||
from __future__ import absolute_import
|
||||
import time
|
||||
from public_api import PublicAPI
|
||||
from .public_api import PublicAPI
|
||||
|
||||
|
||||
class PrivateAPI(PublicAPI):
|
||||
@ -105,7 +107,7 @@ class PrivateAPI(PublicAPI):
|
||||
'offset': offset,
|
||||
'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)
|
||||
|
||||
def view_transfers(self, offset=0, limit=10, currency="btc"):
|
||||
|
@ -1,5 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import print_function
|
||||
import requests
|
||||
import json
|
||||
import logging
|
||||
@ -53,9 +54,9 @@ class PublicAPI:
|
||||
return self.request_get("constants")
|
||||
|
||||
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)
|
||||
print response
|
||||
print(response)
|
||||
try:
|
||||
return response.json()
|
||||
except json.decoder.JSONDecodeError as e:
|
||||
@ -63,9 +64,9 @@ class PublicAPI:
|
||||
return response.text
|
||||
|
||||
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)
|
||||
print response
|
||||
print(response)
|
||||
try:
|
||||
return response.json()
|
||||
except json.decoder.JSONDecodeError as e:
|
||||
|
@ -1,10 +1,12 @@
|
||||
# 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')
|
||||
|
||||
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")
|
||||
#api.limit_bid_order(coin_amount = 0.01 , price = 1000 , currency_pair="btc_krw")
|
||||
|
@ -1,6 +1,7 @@
|
||||
# encoding: UTF-8
|
||||
|
||||
from vnkorbit import Korbit_TradeApi , Korbit_DataApi
|
||||
from __future__ import absolute_import
|
||||
from .vnkorbit import Korbit_TradeApi , Korbit_DataApi
|
||||
|
||||
apiKey = 'FssV9Jw0aZVCOYbu9YlqVNc2Rhgmh1QpruNgSVhvVmFP1iw1aPfc3APbfz0ZM'
|
||||
secretKey = 'lSMc1TT2AZYX5pyEm01SFqx7PgMjNB18eXWpi8DQKHf0rcYhLiaiRVzJwaVZR'
|
||||
|
@ -1,5 +1,6 @@
|
||||
# encoding: utf-8
|
||||
|
||||
from __future__ import print_function
|
||||
import urllib
|
||||
import hashlib
|
||||
|
||||
@ -63,7 +64,7 @@ class Korbit_TradeApi(object):
|
||||
try:
|
||||
return response.json()
|
||||
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
|
||||
|
||||
'''
|
||||
@ -170,10 +171,10 @@ class Korbit_TradeApi(object):
|
||||
else:
|
||||
try:
|
||||
data = json.loads(r.text)
|
||||
print "Error in r , " , data
|
||||
print("Error in r , " , data)
|
||||
return data
|
||||
except Exception,ex:
|
||||
print ex
|
||||
except Exception as ex:
|
||||
print(ex)
|
||||
return None
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
@ -194,13 +195,13 @@ class Korbit_TradeApi(object):
|
||||
# 请求成功
|
||||
if data != None :
|
||||
if self.DEBUG:
|
||||
print callback.__name__
|
||||
print(callback.__name__)
|
||||
callback(data, req, reqID)
|
||||
|
||||
sleep(0.1)
|
||||
|
||||
except Exception,ex:
|
||||
print ex
|
||||
except Exception as ex:
|
||||
print(ex)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
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):
|
||||
print data
|
||||
print(data)
|
||||
#----------------------------------------------------------------------
|
||||
def on_sell_currency(self, data , req, reqID):
|
||||
print data
|
||||
print(data)
|
||||
#----------------------------------------------------------------------
|
||||
def on_list_exchange_orders(self, data , req, reqID):
|
||||
print data
|
||||
print(data)
|
||||
#----------------------------------------------------------------------
|
||||
def onCancelOrders(self, data , req, reqID):
|
||||
print data
|
||||
print(data)
|
||||
#----------------------------------------------------------------------
|
||||
def onBalances(self, data , req, reqID):
|
||||
print data
|
||||
print(data)
|
||||
|
||||
class Korbit_DataApi(object):
|
||||
|
||||
@ -334,10 +335,10 @@ class Korbit_DataApi(object):
|
||||
data = r.json()
|
||||
data["symbol"] = symbol
|
||||
if self.DEBUG:
|
||||
print callback.__name__
|
||||
print(callback.__name__)
|
||||
callback(data)
|
||||
except Exception, e:
|
||||
print "Korbit_DataApi" , e
|
||||
except Exception as e:
|
||||
print("Korbit_DataApi" , e)
|
||||
sleep(self.taskInterval)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
@ -365,13 +366,13 @@ class Korbit_DataApi(object):
|
||||
#----------------------------------------------------------------------
|
||||
def onTick(self, data):
|
||||
"""实时成交推送"""
|
||||
print data
|
||||
print(data)
|
||||
#----------------------------------------------------------------------
|
||||
def onTrades(self, data):
|
||||
"""实时成交推送"""
|
||||
print data
|
||||
print(data)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def onOrderbooks(self, data):
|
||||
"""实时成交推送"""
|
||||
print data
|
||||
print(data)
|
||||
|
@ -1,3 +1,4 @@
|
||||
# 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
|
@ -1,6 +1,7 @@
|
||||
# encoding: UTF-8
|
||||
|
||||
from vnokex import *
|
||||
from __future__ import absolute_import
|
||||
from .vnokex import *
|
||||
|
||||
# 在OkCoin网站申请这两个Key,分别对应用户名和密码
|
||||
apiKey = '你的accessKey'
|
||||
|
@ -1,5 +1,6 @@
|
||||
# encoding: UTF-8
|
||||
|
||||
from __future__ import print_function
|
||||
import hashlib
|
||||
import zlib
|
||||
import json
|
||||
@ -129,23 +130,23 @@ class OkexApi(object):
|
||||
#----------------------------------------------------------------------
|
||||
def onMessage(self, ws, evt):
|
||||
"""信息推送"""
|
||||
print evt
|
||||
print(evt)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def onError(self, ws, evt):
|
||||
"""错误推送"""
|
||||
print 'onError'
|
||||
print evt
|
||||
print('onError')
|
||||
print(evt)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def onClose(self, ws):
|
||||
"""接口断开"""
|
||||
print 'onClose'
|
||||
print('onClose')
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def onOpen(self, ws):
|
||||
"""接口打开"""
|
||||
print 'onOpen'
|
||||
print('onOpen')
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def generateSign(self, params):
|
||||
|
@ -1,3 +1,4 @@
|
||||
# encoding: UTF-8
|
||||
|
||||
from vnzaif import TradeApi, DataApi
|
||||
from __future__ import absolute_import
|
||||
from .vnzaif import TradeApi, DataApi
|
@ -1,6 +1,7 @@
|
||||
# encoding: utf-8
|
||||
|
||||
from vnzaif import *
|
||||
from __future__ import absolute_import
|
||||
from .vnzaif import *
|
||||
|
||||
def testTrade():
|
||||
"""测试交易"""
|
||||
|
@ -1,5 +1,6 @@
|
||||
# encoding: utf-8
|
||||
|
||||
from __future__ import print_function
|
||||
import urllib
|
||||
import hashlib
|
||||
|
||||
@ -175,11 +176,11 @@ class TradeApi(object):
|
||||
try:
|
||||
data = r.json()
|
||||
if data['success'] == 0:
|
||||
print "error in vnzaif %s" % method
|
||||
print("error in vnzaif %s" % method)
|
||||
return data
|
||||
else:
|
||||
return data
|
||||
except Exception,ex:
|
||||
except Exception as ex:
|
||||
return None
|
||||
else:
|
||||
return None
|
||||
@ -218,7 +219,7 @@ class TradeApi(object):
|
||||
# 请求成功
|
||||
else:
|
||||
if self.DEBUG:
|
||||
print callback.__name__
|
||||
print(callback.__name__)
|
||||
callback(data, req, reqID)
|
||||
|
||||
except Empty:
|
||||
@ -344,29 +345,29 @@ class TradeApi(object):
|
||||
print data
|
||||
'''
|
||||
def onTrade(self, data, req, reqID):
|
||||
print data
|
||||
print(data)
|
||||
|
||||
def onCancelOrder(self, data, req, reqID):
|
||||
print data
|
||||
print(data)
|
||||
|
||||
def onWithdraw(self, data, req, reqID):
|
||||
print data
|
||||
print(data)
|
||||
|
||||
def onDepositHistory(self, data, req, reqID):
|
||||
print data
|
||||
print(data)
|
||||
|
||||
def onWithdrawHistory(self, data, req, reqID):
|
||||
print data
|
||||
print(data)
|
||||
|
||||
def onTradeHistory(self, data, req, reqID):
|
||||
print data
|
||||
print(data)
|
||||
|
||||
def onActiveOrders(self, data, req, reqID):
|
||||
print data
|
||||
print(data)
|
||||
|
||||
def onGet_info2(self, data, req, reqID):
|
||||
"""用户信息"""
|
||||
print data
|
||||
print(data)
|
||||
|
||||
|
||||
|
||||
@ -435,13 +436,13 @@ class DataApi(object):
|
||||
if r.status_code == 200:
|
||||
data = r.json()
|
||||
if self.DEBUG:
|
||||
print callback.__name__
|
||||
print(callback.__name__)
|
||||
|
||||
data = {"return_symbol": (url.split('/'))[-1].split('_')[0] , "data":data}
|
||||
#data["return_symbol"] =
|
||||
callback(data)
|
||||
except Exception, e:
|
||||
print e
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
sleep(self.taskInterval)
|
||||
|
||||
@ -483,18 +484,18 @@ class DataApi(object):
|
||||
#----------------------------------------------------------------------
|
||||
def onTick(self, data):
|
||||
"""实时成交推送"""
|
||||
print data
|
||||
print(data)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def onLast(self, data):
|
||||
"""实时深度推送"""
|
||||
print data
|
||||
print(data)
|
||||
#----------------------------------------------------------------------
|
||||
def onTrades(self, data):
|
||||
"""实时深度推送"""
|
||||
print data
|
||||
print(data)
|
||||
#----------------------------------------------------------------------
|
||||
def onDepth(self, data):
|
||||
"""实时深度推送"""
|
||||
print data
|
||||
print(data)
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
# 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
|
@ -1,6 +1,7 @@
|
||||
# encoding: UTF-8
|
||||
|
||||
from vnzb import *
|
||||
from __future__ import absolute_import
|
||||
from .vnzb import *
|
||||
|
||||
# 在OkCoin网站申请这两个Key,分别对应用户名和密码
|
||||
apiKey = '你的apiKey'
|
||||
|
@ -1,15 +1,16 @@
|
||||
# encoding: UTF-8
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import hashlib
|
||||
import zlib
|
||||
import json
|
||||
from time import sleep
|
||||
import sha
|
||||
import struct
|
||||
from threading import Thread
|
||||
|
||||
import websocket
|
||||
import urllib2, hashlib,struct,sha,time
|
||||
|
||||
from six import xrange
|
||||
|
||||
import websocket
|
||||
|
||||
# OKEX网站
|
||||
zb_usd_url = "wss://api.zb.com:9999/websocket"
|
||||
@ -88,23 +89,23 @@ class ZB_Sub_Spot_Api(object):
|
||||
#----------------------------------------------------------------------
|
||||
def onMessage(self, ws, evt):
|
||||
"""信息推送"""
|
||||
print evt
|
||||
print(evt)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def onError(self, ws, evt):
|
||||
"""错误推送"""
|
||||
print 'onError'
|
||||
print evt
|
||||
print('onError')
|
||||
print(evt)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def onClose(self, ws):
|
||||
"""接口断开"""
|
||||
print 'onClose'
|
||||
print('onClose')
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def onOpen(self, ws):
|
||||
"""接口打开"""
|
||||
print 'onOpen'
|
||||
print('onOpen')
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def subscribeSpotTicker(self, symbol_pair):
|
||||
@ -210,7 +211,7 @@ class ZB_Sub_Spot_Api(object):
|
||||
|
||||
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)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
@ -265,4 +266,4 @@ class ZB_Sub_Spot_Api(object):
|
||||
|
||||
channel = symbol_pair.lower() + "_getordersignoretradetype"
|
||||
|
||||
self.sendTradingRequest(channel, params)
|
||||
self.sendTradingRequest(channel, params)
|
||||
|
@ -1,7 +1,8 @@
|
||||
# encoding: UTF-8
|
||||
|
||||
from __future__ import absolute_import
|
||||
from vnpy.trader import vtConstant
|
||||
from coincheckGateway import CoincheckGateway, CoincheckTradeApi , CoincheckSocketDataApi
|
||||
from .coincheckGateway import CoincheckGateway, CoincheckTradeApi , CoincheckSocketDataApi
|
||||
|
||||
gatewayClass = CoincheckGateway
|
||||
gatewayName = 'COINCHECK'
|
||||
|
@ -3,6 +3,7 @@
|
||||
'''
|
||||
vn.coincheck的gateway接入
|
||||
'''
|
||||
from __future__ import print_function
|
||||
import os
|
||||
import json
|
||||
from datetime import datetime
|
||||
@ -146,7 +147,7 @@ class CoincheckGateway(VtGateway):
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def onListOrder(self, data):
|
||||
print data
|
||||
print(data)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def setQryEnabled(self, qryEnabled):
|
||||
@ -181,7 +182,7 @@ class CoincheckTradeApi(vncoincheck.TradeApi):
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def onError(self, method ,data):
|
||||
print method , data
|
||||
print(method , data)
|
||||
#
|
||||
'''
|
||||
"return" :
|
||||
@ -191,7 +192,7 @@ ty_status': u'identity_verified', u'id': 1007549}
|
||||
'''
|
||||
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
|
||||
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):
|
||||
if data["success"] == 0:
|
||||
print "Error in onGet_balance"
|
||||
print data
|
||||
print("Error in onGet_balance")
|
||||
print(data)
|
||||
else:
|
||||
account = VtAccountData()
|
||||
account.gatewayName = self.gatewayName
|
||||
@ -308,8 +309,8 @@ u'id': 324141928}
|
||||
# print "onBuy_btc"
|
||||
# print data
|
||||
if data["success"] == 0:
|
||||
print "Error in onBuy_btc"
|
||||
print data
|
||||
print("Error in onBuy_btc")
|
||||
print(data)
|
||||
else:
|
||||
localID = self.reqLocalDict[reqID]
|
||||
systemID = data['id']
|
||||
@ -335,7 +336,7 @@ u'id': 324141928}
|
||||
# print data
|
||||
"""卖出回调"""
|
||||
if data["success"] == 0:
|
||||
print "Error in onSell_btc"
|
||||
print("Error in onSell_btc")
|
||||
else:
|
||||
localID = self.reqLocalDict[reqID]
|
||||
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)
|
||||
|
||||
def onHistory_orders(self, data, req, reqID):
|
||||
print data
|
||||
print(data)
|
||||
|
||||
def cancel(self, req):
|
||||
localID = req.orderID
|
||||
@ -594,7 +595,7 @@ class CoincheckSocketDataApi(vncoincheck.DataApiSocket):
|
||||
tick.bidPrice3, tick.bidVolume3 = bids[2]
|
||||
tick.bidPrice4, tick.bidVolume4 = bids[3]
|
||||
tick.bidPrice5, tick.bidVolume5 = bids[4]
|
||||
except Exception,ex:
|
||||
except Exception as ex:
|
||||
pass
|
||||
|
||||
try:
|
||||
@ -603,7 +604,7 @@ class CoincheckSocketDataApi(vncoincheck.DataApiSocket):
|
||||
tick.askPrice3, tick.askVolume3 = asks[2]
|
||||
tick.askPrice4, tick.askVolume4 = asks[3]
|
||||
tick.askPrice5, tick.askVolume5 = asks[4]
|
||||
except Exception,ex:
|
||||
except Exception as ex:
|
||||
pass
|
||||
|
||||
now = datetime.now()
|
||||
@ -716,7 +717,7 @@ class CoincheckDataApi(vncoincheck.DataApi):
|
||||
#----------------------------------------------------------------------
|
||||
def onTrades(self, data):
|
||||
"""实时成交推送"""
|
||||
print data
|
||||
print(data)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def onOrderbooks(self, data):
|
||||
|
@ -1,7 +1,8 @@
|
||||
# encoding: UTF-8
|
||||
|
||||
from __future__ import absolute_import
|
||||
from vnpy.trader import vtConstant
|
||||
from korbitGateway import korbitGateway
|
||||
from .korbitGateway import korbitGateway
|
||||
|
||||
gatewayClass = korbitGateway
|
||||
gatewayName = 'KORBIT'
|
||||
|
@ -3,6 +3,7 @@
|
||||
'''
|
||||
vn.coincheck的gateway接入
|
||||
'''
|
||||
from __future__ import print_function
|
||||
import os
|
||||
import json
|
||||
from datetime import datetime
|
||||
@ -255,13 +256,13 @@ class KorbitTradeApi(vnkorbit.Korbit_TradeApi):
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
def onError(self, method ,data):
|
||||
print method , data
|
||||
print(method , data)
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
def on_buy_currency(self, data , req, reqID):
|
||||
if data["status"] != "success":
|
||||
print "Error in on_buy_currency"
|
||||
print data
|
||||
print("Error in on_buy_currency")
|
||||
print(data)
|
||||
else:
|
||||
localID = self.reqLocalDict[reqID]
|
||||
systemID = str(data['orderId'])
|
||||
@ -286,7 +287,7 @@ class KorbitTradeApi(vnkorbit.Korbit_TradeApi):
|
||||
def on_sell_currency(self, data , req, reqID):
|
||||
"""卖出回调"""
|
||||
if data["status"] != "success":
|
||||
print "Error in on_sell_currency"
|
||||
print("Error in on_sell_currency")
|
||||
else:
|
||||
localID = self.reqLocalDict[reqID]
|
||||
systemID = str(data['orderId'])
|
||||
@ -306,7 +307,7 @@ class KorbitTradeApi(vnkorbit.Korbit_TradeApi):
|
||||
self.tradedVolumeDict[localID] = 0.0
|
||||
self.gateway.onOrder(order)
|
||||
|
||||
print "what"
|
||||
print("what")
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
def on_list_exchange_orders(self, data , req, reqID):
|
||||
|
@ -1,7 +1,8 @@
|
||||
# encoding: UTF-8
|
||||
|
||||
from __future__ import absolute_import
|
||||
from vnpy.trader import vtConstant
|
||||
from okexGateway import okexGateway
|
||||
from .okexGateway import okexGateway
|
||||
|
||||
gatewayClass = okexGateway
|
||||
gatewayName = 'OKEX'
|
||||
|
@ -6,6 +6,7 @@ vnpy.api.okex的gateway接入
|
||||
注意:
|
||||
1. 目前仅支持USD现货交易
|
||||
'''
|
||||
from __future__ import print_function
|
||||
|
||||
import os
|
||||
import json
|
||||
@ -232,7 +233,7 @@ class SpotApi(OkexSpotApi):
|
||||
data = self.readData(evt)[0]
|
||||
try:
|
||||
channel = data['channel']
|
||||
except Exception,ex:
|
||||
except Exception as ex:
|
||||
channel = None
|
||||
if channel == None:
|
||||
return
|
||||
@ -310,7 +311,7 @@ class SpotApi(OkexSpotApi):
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def spotAllOrders(self):
|
||||
print spotAllOrders
|
||||
print(spotAllOrders)
|
||||
for symbol in registerSymbolPairArray:
|
||||
if symbol in okex_all_symbol_pairs:
|
||||
self.spotOrderInfo(symbol, '-1')
|
||||
@ -453,8 +454,8 @@ class SpotApi(OkexSpotApi):
|
||||
# print "ticker", tick.date, tick.time
|
||||
# newtick = copy(tick)
|
||||
# self.gateway.onTick(newtick)
|
||||
except Exception,ex:
|
||||
print "Error in onTicker ", channel
|
||||
except Exception as ex:
|
||||
print("Error in onTicker ", channel)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def onDepth(self, data):
|
||||
@ -464,7 +465,7 @@ class SpotApi(OkexSpotApi):
|
||||
try:
|
||||
channel = data['channel']
|
||||
symbol = self.channelSymbolMap[channel]
|
||||
except Exception,ex:
|
||||
except Exception as ex:
|
||||
symbol = None
|
||||
|
||||
if symbol == None:
|
||||
@ -789,7 +790,7 @@ nel': u'ok_sub_spot_etc_usdt_order'}
|
||||
def onSpotOrderInfo(self, data):
|
||||
"""委托信息查询回调"""
|
||||
if "error_code" in data.keys():
|
||||
print data
|
||||
print(data)
|
||||
return
|
||||
rawData = data['data']
|
||||
for d in rawData['orders']:
|
||||
@ -839,7 +840,7 @@ nel': u'ok_sub_spot_etc_usdt_order'}
|
||||
def onSpotOrder(self, data):
|
||||
rawData = data['data']
|
||||
if 'error_code' in rawData.keys():
|
||||
print data
|
||||
print(data)
|
||||
return
|
||||
|
||||
orderId = str(rawData['order_id'])
|
||||
|
@ -1,7 +1,8 @@
|
||||
# encoding: UTF-8
|
||||
|
||||
from __future__ import absolute_import
|
||||
from vnpy.trader import vtConstant
|
||||
from zbGateway import zbGateway
|
||||
from .zbGateway import zbGateway
|
||||
|
||||
gatewayClass = zbGateway
|
||||
gatewayName = 'ZB'
|
||||
|
@ -3,6 +3,7 @@
|
||||
'''
|
||||
vn.zb的gateway接入
|
||||
'''
|
||||
from __future__ import print_function
|
||||
import os
|
||||
import json
|
||||
from datetime import datetime
|
||||
@ -224,7 +225,7 @@ class ZB_API_Spot(ZB_Sub_Spot_Api):
|
||||
data = self.readData(evt)
|
||||
try:
|
||||
channel = data['channel']
|
||||
except Exception,ex:
|
||||
except Exception as ex:
|
||||
channel = None
|
||||
if channel == None:
|
||||
return
|
||||
@ -379,8 +380,8 @@ class ZB_API_Spot(ZB_Sub_Spot_Api):
|
||||
# print "ticker", tick.date , tick.time
|
||||
# newtick = copy(tick)
|
||||
# self.gateway.onTick(newtick)
|
||||
except Exception,ex:
|
||||
print "Error in onTicker " , channel
|
||||
except Exception as ex:
|
||||
print("Error in onTicker " , channel)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def onDepth(self, data):
|
||||
@ -388,7 +389,7 @@ class ZB_API_Spot(ZB_Sub_Spot_Api):
|
||||
try:
|
||||
channel = data['channel']
|
||||
symbol = self.channelSymbolMap[channel]
|
||||
except Exception,ex:
|
||||
except Exception as ex:
|
||||
symbol = None
|
||||
|
||||
if symbol == None:
|
||||
@ -605,7 +606,7 @@ class ZB_API_Spot(ZB_Sub_Spot_Api):
|
||||
# 现在的处理方式是, 先缓存这里的信息,等到出现了 localID,再来处理这一段
|
||||
localNo = self.orderIdDict.get(orderId , None)
|
||||
if localNo == None:
|
||||
print "Error , localNo is none !" + str(localNo)
|
||||
print("Error , localNo is none !" + str(localNo))
|
||||
return
|
||||
|
||||
# 委托信息
|
||||
@ -812,8 +813,8 @@ class ZB_API_Spot(ZB_Sub_Spot_Api):
|
||||
rawData = json.loads(rawData)
|
||||
coins = rawData["coins"]
|
||||
|
||||
except Exception,ex:
|
||||
print ex
|
||||
except Exception as ex:
|
||||
print(ex)
|
||||
|
||||
for coin in coins:
|
||||
symbol = coin["cnName"].lower()
|
||||
|
@ -184,8 +184,8 @@ class StSpread(object):
|
||||
askok = True
|
||||
|
||||
for k in self.code.co_names :
|
||||
bidok = bidok and legbidglobal.has_key(k)
|
||||
askok = askok and legaskglobal.has_key(k)
|
||||
bidok = bidok and k in legbidglobal
|
||||
askok = askok and k in legaskglobal
|
||||
|
||||
if bidok and askok :
|
||||
self.bidPrice = eval(self.code,legbidglobal)
|
||||
|
Loading…
Reference in New Issue
Block a user