|
@@ -125,12 +125,18 @@ def help():
|
|
print(' All arguments for all commands are optional!')
|
|
print(' All arguments for all commands are optional!')
|
|
|
|
|
|
|
|
|
|
|
|
+def _my_tabulate(data, **params):
|
|
|
|
+ if data == [] and 'headers' in params:
|
|
|
|
+ data = [(None for _ in params['headers'])]
|
|
|
|
+ return tabulate(data, **params)
|
|
|
|
+
|
|
|
|
+
|
|
def depot():
|
|
def depot():
|
|
fake_loading_bar('Loading data', duration=1.3)
|
|
fake_loading_bar('Loading data', duration=1.3)
|
|
response = client_request('depot', {"session_id": connection.session_id})
|
|
response = client_request('depot', {"session_id": connection.session_id})
|
|
success = 'data' in response and 'own_wealth' in response
|
|
success = 'data' in response and 'own_wealth' in response
|
|
if success:
|
|
if success:
|
|
- print(tabulate(response['data'], headers=['Object', 'Amount', 'Est. Value'], tablefmt="pipe"))
|
|
|
|
|
|
+ print(_my_tabulate(response['data'], headers=['Object', 'Amount', 'Est. Value'], tablefmt="pipe"))
|
|
print('This corresponds to a wealth of roughly', response['own_wealth'])
|
|
print('This corresponds to a wealth of roughly', response['own_wealth'])
|
|
else:
|
|
else:
|
|
if 'error_message' in response:
|
|
if 'error_message' in response:
|
|
@@ -144,7 +150,7 @@ def leaderboard():
|
|
response = client_request('leaderboard', {"session_id": connection.session_id})
|
|
response = client_request('leaderboard', {"session_id": connection.session_id})
|
|
success = 'data' in response
|
|
success = 'data' in response
|
|
if success:
|
|
if success:
|
|
- print(tabulate(response['data'], headers=['User', 'Wealth'], tablefmt="pipe"))
|
|
|
|
|
|
+ print(_my_tabulate(response['data'], headers=['User', 'Wealth'], tablefmt="pipe"))
|
|
else:
|
|
else:
|
|
if 'error_message' in response:
|
|
if 'error_message' in response:
|
|
print('Leaderboard access failed with message:', response['error_message'])
|
|
print('Leaderboard access failed with message:', response['error_message'])
|
|
@@ -248,9 +254,9 @@ def orders():
|
|
response = client_request('orders', {"session_id": connection.session_id})
|
|
response = client_request('orders', {"session_id": connection.session_id})
|
|
success = 'data' in response
|
|
success = 'data' in response
|
|
if success:
|
|
if success:
|
|
- print(tabulate(response['data'],
|
|
|
|
- headers=['Buy?', 'Name', 'Amount', 'Limit', 'Stop Loss?', 'Orig. Size', 'Expires', 'No.'],
|
|
|
|
- tablefmt="pipe"))
|
|
|
|
|
|
+ print(_my_tabulate(response['data'],
|
|
|
|
+ headers=['Buy?', 'Name', 'Amount', 'Limit', 'Stop Loss?', 'Orig. Size', 'Expires', 'No.'],
|
|
|
|
+ tablefmt="pipe"))
|
|
else:
|
|
else:
|
|
if 'error_message' in response:
|
|
if 'error_message' in response:
|
|
print('Order access failed with message:', response['error_message'])
|
|
print('Order access failed with message:', response['error_message'])
|
|
@@ -265,9 +271,9 @@ def orders_on(object_name=None):
|
|
response = client_request('orders_on', {"session_id": connection.session_id, "ownable": object_name})
|
|
response = client_request('orders_on', {"session_id": connection.session_id, "ownable": object_name})
|
|
success = 'data' in response
|
|
success = 'data' in response
|
|
if success:
|
|
if success:
|
|
- print(tabulate(response['data'],
|
|
|
|
- headers=['Buy?', 'Name', 'Amount', 'Limit', 'Stop Loss?', 'Expires', 'No.'],
|
|
|
|
- tablefmt="pipe"))
|
|
|
|
|
|
+ print(_my_tabulate(response['data'],
|
|
|
|
+ headers=['Buy?', 'Name', 'Amount', 'Limit', 'Stop Loss?', 'Expires', 'No.'],
|
|
|
|
+ tablefmt="pipe"))
|
|
else:
|
|
else:
|
|
if 'error_message' in response:
|
|
if 'error_message' in response:
|
|
print('Order access failed with message:', response['error_message'])
|
|
print('Order access failed with message:', response['error_message'])
|
|
@@ -287,7 +293,7 @@ def gift(username=None, amount=None, object_name=None):
|
|
{"session_id": connection.session_id,
|
|
{"session_id": connection.session_id,
|
|
"username": username,
|
|
"username": username,
|
|
"object_name": object_name,
|
|
"object_name": object_name,
|
|
- "amount":amount})
|
|
|
|
|
|
+ "amount": amount})
|
|
if 'error_message' in response:
|
|
if 'error_message' in response:
|
|
print('Order access failed with message:', response['error_message'])
|
|
print('Order access failed with message:', response['error_message'])
|
|
elif 'message' in response:
|
|
elif 'message' in response:
|
|
@@ -299,9 +305,9 @@ def news():
|
|
response = client_request('news', {"session_id": connection.session_id})
|
|
response = client_request('news', {"session_id": connection.session_id})
|
|
success = 'data' in response
|
|
success = 'data' in response
|
|
if success:
|
|
if success:
|
|
- print(tabulate(response['data'],
|
|
|
|
- headers=['Date', 'Title'],
|
|
|
|
- tablefmt="pipe"))
|
|
|
|
|
|
+ print(_my_tabulate(response['data'],
|
|
|
|
+ headers=['Date', 'Title'],
|
|
|
|
+ tablefmt="pipe"))
|
|
else:
|
|
else:
|
|
if 'error_message' in response:
|
|
if 'error_message' in response:
|
|
print('Order access failed with message:', response['error_message'])
|
|
print('Order access failed with message:', response['error_message'])
|
|
@@ -316,9 +322,9 @@ def transactions(object_name=None):
|
|
response = client_request('transactions', {"session_id": connection.session_id, "ownable": object_name})
|
|
response = client_request('transactions', {"session_id": connection.session_id, "ownable": object_name})
|
|
success = 'data' in response
|
|
success = 'data' in response
|
|
if success:
|
|
if success:
|
|
- print(tabulate(response['data'],
|
|
|
|
- headers=['Time', 'Volume', 'Price'],
|
|
|
|
- tablefmt="pipe"))
|
|
|
|
|
|
+ print(_my_tabulate(response['data'],
|
|
|
|
+ headers=['Time', 'Volume', 'Price'],
|
|
|
|
+ tablefmt="pipe"))
|
|
else:
|
|
else:
|
|
if 'error_message' in response:
|
|
if 'error_message' in response:
|
|
print('Transactions access failed with message:', response['error_message'])
|
|
print('Transactions access failed with message:', response['error_message'])
|