[Mod] flake8 code quality improve

This commit is contained in:
vn.py 2019-09-11 20:59:49 +08:00
parent 27099ebb7a
commit 9dd329e4d5

View File

@ -8,15 +8,12 @@ import hmac
import sys import sys
import time import time
import re import re
import hmac
import hashlib
from copy import copy from copy import copy
from datetime import datetime, timedelta from datetime import datetime, timedelta
from urllib.parse import urlencode from urllib.parse import urlencode
from vnpy.api.rest import Request, RestClient from vnpy.api.rest import Request, RestClient
from vnpy.api.websocket import WebsocketClient from vnpy.api.websocket import WebsocketClient
from vnpy.event import Event from vnpy.event import Event
from urllib import parse
from time import sleep from time import sleep
from vnpy.trader.constant import ( from vnpy.trader.constant import (
@ -175,7 +172,6 @@ class BitstampGateway(BaseGateway):
data = self.rest_api_v1.get_callback_data(i) data = self.rest_api_v1.get_callback_data(i)
self.rest_api.update_trade(i, data) self.rest_api.update_trade(i, data)
def query_account(self): def query_account(self):
"""""" """"""
self.rest_api.query_account_balance() self.rest_api.query_account_balance()
@ -294,11 +290,11 @@ class BitstampRestApiV1(RestClient):
# Sign # Sign
# nonce = str(int(round(time.time() * 1000000))) # nonce = str(int(round(time.time() * 1000000)))
if request.params: # if request.params:
query = urlencode(request.params) # query = urlencode(request.params)
path = request.path + "?" + query # path = request.path + "?" + query
else: # else:
path = request.path # path = request.path
if request.data: if request.data:
request.data = urlencode(request.data) request.data = urlencode(request.data)
@ -414,7 +410,7 @@ class BitstampHistoryApi(RestClient):
print(f"History {req}") print(f"History {req}")
history = [] history = []
limit = 1000 # limit = 1000
step = int(INTERVAL_VT2BITSTAMP[req.interval]) step = int(INTERVAL_VT2BITSTAMP[req.interval])
symbol = SYMBOL_BITSTAMP2VT[req.symbol] symbol = SYMBOL_BITSTAMP2VT[req.symbol]
base, quote = symbol.split("/") base, quote = symbol.split("/")
@ -607,11 +603,11 @@ class BitstampRestApi(RestClient):
# Sign # Sign
# nonce = str(int(round(time.time() * 1000000))) # nonce = str(int(round(time.time() * 1000000)))
if request.params: # if request.params:
query = urlencode(request.params) # query = urlencode(request.params)
path = request.path + "?" + query # path = request.path + "?" + query
else: # else:
path = request.path # path = request.path
if request.data: if request.data:
request.data = urlencode(request.data) request.data = urlencode(request.data)
@ -660,8 +656,6 @@ class BitstampRestApi(RestClient):
self.on_trade(data) self.on_trade(data)
def on_trade(self, data): def on_trade(self, data):
"""""" """"""
# self.trade_id += 1 # self.trade_id += 1
@ -669,10 +663,10 @@ class BitstampRestApi(RestClient):
for d in data: for d in data:
if int(d["type"]) == 2: # 交易记录 if int(d["type"]) == 2: # 交易记录
btc = d["btc"] btc = d["btc"]
usd = d["usd"] # usd = d["usd"]
btcusd = d["btc_usd"] btcusd = d["btc_usd"]
tradetime = d["datetime"] tradetime = d["datetime"]
fee = d["fee"] # fee = d["fee"]
tradeid = d["id"] tradeid = d["id"]
orderid = d["order_id"] orderid = d["order_id"]
@ -720,7 +714,7 @@ class BitstampRestApi(RestClient):
if status == "Finished": if status == "Finished":
btc_volume = sum(float(x["btc"]) for x in data["transactions"]) btc_volume = sum(float(x["btc"]) for x in data["transactions"])
usd_volume = sum(float(x["usd"]) for x in data["transactions"]) # usd_volume = sum(float(x["usd"]) for x in data["transactions"])
if btc_volume == order.volume: if btc_volume == order.volume:
order.status = Status.ALLTRADED order.status = Status.ALLTRADED
@ -745,7 +739,6 @@ class BitstampRestApi(RestClient):
"""更新线上交易记录""" """更新线上交易记录"""
self.user_transactions() self.user_transactions()
def open_orders(self, symbol="all"): def open_orders(self, symbol="all"):
""" """
id Transaction ID. id Transaction ID.