Fix docstring, comment typos

This commit is contained in:
JOlson
2020-05-09 16:37:38 +12:00
committed by Jacob Plaster
parent 51803c87c9
commit 427e99710e
17 changed files with 52 additions and 43 deletions

View File

@@ -37,6 +37,8 @@ class DepositAddress:
return DepositAddress(method, currency, address)
def __str__(self):
''' Allow us to print the Transfer object in a pretty format '''
"""
Allow us to print the Transfer object in a pretty format
"""
text = "DepositAddress <{} method={} currency={}>"
return text.format(self.address, self.method, self.currency)

View File

@@ -114,6 +114,8 @@ class Notification:
return basic
def __str__(self):
''' Allow us to print the Notification object in a pretty format '''
"""
Allow us to print the Notification object in a pretty format
"""
text = "Notification <'{}' ({}) - {} notify_info={}>"
return text.format(self.notify_type, self.status, self.text, self.notify_info)

View File

@@ -209,7 +209,7 @@ class Order:
"""
Check if the order is still open
@return bool: Ture if order open else False
@return bool: True if order open else False
"""
return self.is_open_bool
@@ -230,7 +230,9 @@ class Order:
return self.is_confirmed_bool
def __str__(self):
''' Allow us to print the Order object in a pretty format '''
"""
Allow us to print the Order object in a pretty format
"""
text = "Order <'{}' amount_orig={} amount_filled={} mts_create={} status='{}' id={}>"
return text.format(self.symbol, self.amount_orig, self.amount_filled,
self.mts_create, self.status, self.id)

View File

@@ -100,7 +100,9 @@ class Position:
lev, pid, mtsc, mtsu, ptype, coll, coll_min, meta)
def __str__(self):
''' Allow us to print the Trade object in a pretty format '''
"""
Allow us to print the Trade object in a pretty format
"""
text = "Position '{}' {} x {} <status='{}' pl={}>"
return text.format(self.symbol, self.base_price, self.amount,
self.status, self.profit_loss)

View File

@@ -18,7 +18,7 @@ class Subscription:
"""
Object used to represent an individual subscription to the websocket.
This class also exposes certain functions which helps to manage the subscription
such as unsibscribe and subscribe.
such as unsubscribe and subscribe.
"""
def __init__(self, socket, channel_name, symbol, key=None, timeframe=None, **kwargs):
@@ -49,7 +49,7 @@ class Subscription:
async def unsubscribe(self):
"""
Send an unsubscription request to the bitfinex socket
Send an un-subscription request to the bitfinex socket
"""
if not self.is_subscribed():
raise Exception("Subscription is not subscribed to websocket")

View File

@@ -47,7 +47,9 @@ class Transfer:
return Transfer(mts, wallet_from, wallet_to, currency_from, currency_to, amount)
def __str__(self):
''' Allow us to print the Transfer object in a pretty format '''
"""
Allow us to print the Transfer object in a pretty format
"""
text = "Transfer <{} from {} ({}) to {} ({}) mts={}>"
return text.format(self.amount, self.wallet_from, self.currency_from,
self.wallet_to, self.currency_to, self.mts)

View File

@@ -45,7 +45,9 @@ class Withdraw:
return Withdraw(w_id, method, wallet, amount)
def __str__(self):
''' Allow us to print the Withdraw object in a pretty format '''
"""
Allow us to print the Withdraw object in a pretty format
"""
text = "Withdraw <id={} from {} ({}) amount={} fee={}>"
return text.format(self.id, self.wallet, self.method, self.amount,
self.fee)

View File

@@ -8,7 +8,7 @@ from .helpers import (create_stubbed_client, ws_publish_connection_init, ws_publ
async def test_ws_creates_new_socket():
client = create_stubbed_client()
client.ws.ws_capacity = 5
# publsh connection created message
# publish connection created message
await ws_publish_connection_init(client.ws)
# create a bunch of websocket subscriptions
for symbol in ['tXRPBTC', 'tLTCUSD']:
@@ -25,12 +25,12 @@ async def test_ws_creates_new_socket():
async def test_ws_uses_authenticated_socket():
client = create_stubbed_client()
client.ws.ws_capacity = 2
# publsh connection created message
# publish connection created message
await ws_publish_connection_init(client.ws)
# create a bunch of websocket subscriptions
for symbol in ['tXRPBTC', 'tLTCUSD', 'tETHBTC', 'tBTCUSD', 'tETHUSD', 'tLTCBTC']:
await client.ws.subscribe('candles', symbol, timeframe='1m')
# publsh connection created message on socket (0 by default)
# publish connection created message on socket (0 by default)
await ws_publish_connection_init(client.ws)
# send auth accepted (on socket by default)
await ws_publish_auth_accepted(client.ws)

View File

@@ -5,7 +5,7 @@ from .helpers import create_stubbed_client, ws_publish_connection_init, ws_publi
async def test_checksum_generation():
client = create_stubbed_client()
symbol = "tXRPBTC"
# publsh connection created message
# publish connection created message
await ws_publish_connection_init(client.ws)
# publish checksum flag accepted
await ws_publish_conf_accepted(client.ws, 131072)
@@ -37,7 +37,7 @@ async def test_checksum_generation():
async def test_checksum_really_samll_numbers_generation():
client = create_stubbed_client()
symbol = "tVETBTC"
# publsh connection created message
# publish connection created message
await ws_publish_connection_init(client.ws)
# publish checksum flag accepted
await ws_publish_conf_accepted(client.ws, 131072)

View File

@@ -7,7 +7,7 @@ from .helpers import (create_stubbed_client, ws_publish_auth_accepted, ws_publis
@pytest.mark.asyncio
async def test_submit_order():
client = create_stubbed_client()
# publsh connection created message
# publish connection created message
await ws_publish_connection_init(client.ws)
## send auth accepted
await ws_publish_auth_accepted(client.ws)
@@ -25,7 +25,7 @@ async def test_submit_order():
@pytest.mark.asyncio
async def test_submit_update_order():
client = create_stubbed_client()
# publsh connection created message
# publish connection created message
await ws_publish_connection_init(client.ws)
## send auth accepted
await ws_publish_auth_accepted(client.ws)
@@ -44,7 +44,7 @@ async def test_submit_update_order():
@pytest.mark.asyncio
async def test_submit_cancel_order():
client = create_stubbed_client()
# publsh connection created message
# publish connection created message
await ws_publish_connection_init(client.ws)
## send auth accepted
await ws_publish_auth_accepted(client.ws)
@@ -59,7 +59,7 @@ async def test_submit_cancel_order():
@pytest.mark.asyncio
async def test_events_on_new_order():
client = create_stubbed_client()
# publsh connection created message
# publish connection created message
await ws_publish_connection_init(client.ws)
## send auth accepted
await ws_publish_auth_accepted(client.ws)
@@ -94,7 +94,7 @@ async def test_events_on_new_order():
@pytest.mark.asyncio
async def test_events_on_cancel_order():
client = create_stubbed_client()
# publsh connection created message
# publish connection created message
await ws_publish_connection_init(client.ws)
## send auth accepted
await ws_publish_auth_accepted(client.ws)
@@ -114,7 +114,7 @@ async def test_events_on_cancel_order():
@pytest.mark.asyncio
async def test_closed_callback_on_submit_order_closed():
client = create_stubbed_client()
# publsh connection created message
# publish connection created message
await ws_publish_connection_init(client.ws)
## send auth accepted
await ws_publish_auth_accepted(client.ws)
@@ -131,7 +131,7 @@ async def test_closed_callback_on_submit_order_closed():
@pytest.mark.asyncio
async def test_confirmed_callback_on_submit_order_closed():
client = create_stubbed_client()
# publsh connection created message
# publish connection created message
await ws_publish_connection_init(client.ws)
## send auth accepted
await ws_publish_auth_accepted(client.ws)
@@ -147,7 +147,7 @@ async def test_confirmed_callback_on_submit_order_closed():
@pytest.mark.asyncio
async def test_confirmed_callback_on_submit_new_order():
client = create_stubbed_client()
# publsh connection created message
# publish connection created message
await ws_publish_connection_init(client.ws)
## send auth accepted
await ws_publish_auth_accepted(client.ws)
@@ -163,7 +163,7 @@ async def test_confirmed_callback_on_submit_new_order():
@pytest.mark.asyncio
async def test_confirmed_callback_on_submit_order_update():
client = create_stubbed_client()
# publsh connection created message
# publish connection created message
await ws_publish_connection_init(client.ws)
## send auth accepted
await ws_publish_auth_accepted(client.ws)
@@ -179,7 +179,7 @@ async def test_confirmed_callback_on_submit_order_update():
@pytest.mark.asyncio
async def test_confirmed_callback_on_submit_cancel_order():
client = create_stubbed_client()
# publsh connection created message
# publish connection created message
await ws_publish_connection_init(client.ws)
## send auth accepted
await ws_publish_auth_accepted(client.ws)
@@ -195,7 +195,7 @@ async def test_confirmed_callback_on_submit_cancel_order():
@pytest.mark.asyncio
async def test_confirmed_callback_on_submit_cancel_group_order():
client = create_stubbed_client()
# publsh connection created message
# publish connection created message
await ws_publish_connection_init(client.ws)
## send auth accepted
await ws_publish_auth_accepted(client.ws)

View File

@@ -7,7 +7,7 @@ from .helpers import (create_stubbed_client, ws_publish_connection_init, EventWa
async def test_submit_subscribe():
client = create_stubbed_client()
symb = 'tXRPBTC'
# publsh connection created message
# publish connection created message
await ws_publish_connection_init(client.ws)
# Create new subscription to orderbook
@@ -42,7 +42,7 @@ async def test_event_subscribe():
client = create_stubbed_client()
symb = 'tXRPBTC'
pair = 'XRPBTC'
# publsh connection created message
# publish connection created message
await ws_publish_connection_init(client.ws)
# create a new subscription
await client.ws.subscribe('trades', symb)
@@ -60,7 +60,7 @@ async def test_submit_unsubscribe():
client = create_stubbed_client()
symb = 'tXRPBTC'
pair = 'XRPBTC'
# publsh connection created message
# publish connection created message
await ws_publish_connection_init(client.ws)
# create new subscription to trades
await client.ws.subscribe('trades', symb)

View File

@@ -12,7 +12,7 @@ def generate_auth_payload(API_KEY, API_SECRET):
"""
Generate a signed payload
@return json Oject headers
@return json Object headers
"""
nonce = _gen_nonce()
authMsg, sig = _gen_signature(API_KEY, API_SECRET, nonce)

View File

@@ -37,7 +37,7 @@ def formatter_message(message, use_color = True):
def format_word(message, word, color_seq, bold=False, underline=False):
"""
Surround the fiven word with a sequence
Surround the given word with a sequence
"""
replacer = color_seq + word + RESET_SEQ
if underline:
@@ -47,9 +47,9 @@ def format_word(message, word, color_seq, bold=False, underline=False):
return message.replace(word, replacer)
class Formatter(logging.Formatter):
'''
"""
This Formatted simply colors in the levelname i.e 'INFO', 'DEBUG'
'''
"""
def __init__(self, msg, use_color = True):
logging.Formatter.__init__(self, msg)
self.use_color = use_color
@@ -66,10 +66,10 @@ class Formatter(logging.Formatter):
return logging.Formatter.format(self, record)
class CustomLogger(logging.Logger):
'''
"""
This adds extra logging functions such as logger.trade and also
sets the logger to use the custom formatter
'''
"""
FORMAT = "[$BOLD%(name)s$RESET] [%(levelname)s] %(message)s"
COLOR_FORMAT = formatter_message(FORMAT, True)
TRADE = 50

View File

@@ -596,7 +596,7 @@ class BfxWebsocket(GenericWebsocket):
Unsubscribe from the channel with the given chanId
# Attributes
@param onComplete: function called when the bitfinex websocket resoponds with
@param onComplete: function called when the bitfinex websocket responds with
a signal that confirms the subscription has been unsubscribed to
"""
return await self.subscriptionManager.unsubscribe(*args, **kwargs)

View File

@@ -81,7 +81,7 @@ class GenericWebsocket:
def run(self):
"""
Starte the websocket connection. This functions spawns the initial socket
Start the websocket connection. This functions spawns the initial socket
thread and connection.
"""
self._start_new_socket()

View File

@@ -55,9 +55,9 @@ class OrderManager:
self.bfxapi._emit('order_closed', order)
async def build_from_order_snapshot(self, raw_ws_data):
'''
"""
Rebuild the user orderbook based on an incoming snapshot
'''
"""
osData = raw_ws_data[2]
self.open_orders = {}
for raw_order in osData:
@@ -206,10 +206,7 @@ class OrderManager:
@param orderId: the id of the order that you want to update
@param onConfirm: function called when the bitfinex websocket receives signal that the
order
was confirmed
@param onClose: function called when the bitfinex websocket receives signal that the order
was closed due to being filled or cancelled
order was confirmed
"""
self._create_callback(orderId, onConfirm, self.pending_cancel_confirm_callbacks)
await self.bfxapi._send_auth_command('oc', {'id': orderId})

View File

@@ -146,7 +146,7 @@ class SubscriptionManager:
# unsubscribe first and call callback to subscribe
await self.unsubscribe(chan_id, re_sub)
else:
# already unsibscribed, so just subscribe
# already unsubscribed, so just subscribe
await sub.subscribe()
def channel_count(self):