|
@@ -3,10 +3,9 @@ from getpass import getpass
|
|
|
from inspect import signature
|
|
|
|
|
|
import connection
|
|
|
-from run_client import allowed_commands, fake_loading_bar
|
|
|
from connection import client_request
|
|
|
-
|
|
|
from debug import debug
|
|
|
+from run_client import allowed_commands, fake_loading_bar
|
|
|
from util import my_tabulate
|
|
|
|
|
|
exiting = False
|
|
@@ -249,7 +248,7 @@ def buy(obj_name=None, amount=None, limit='', stop_loss='', expiry=None):
|
|
|
if 'error_message' in response:
|
|
|
print('Order placement failed with message:', response['error_message'])
|
|
|
else:
|
|
|
- print('You might want to use the `transactions` or `depot` commands',
|
|
|
+ print('You might want to use the `trades` or `depot` commands',
|
|
|
'to see if the order has been executed already.')
|
|
|
|
|
|
|
|
@@ -296,7 +295,7 @@ def sell(obj_name=None, amount=None, limit='', stop_loss='', expiry=None):
|
|
|
if 'error_message' in response:
|
|
|
print('Order placement failed with message:', response['error_message'])
|
|
|
else:
|
|
|
- print('You might want to use the `transactions` or `depot` commands',
|
|
|
+ print('You might want to use the `trades` or `depot` commands',
|
|
|
'to see if the order has been executed already.')
|
|
|
|
|
|
|
|
@@ -387,12 +386,12 @@ def tradables():
|
|
|
print('Data access failed.')
|
|
|
|
|
|
|
|
|
-def transactions(obj_name=None, limit=5):
|
|
|
+def trades_on(obj_name=None, limit=5):
|
|
|
limit = float(limit)
|
|
|
if obj_name is None:
|
|
|
obj_name = input('Name of object to check: ')
|
|
|
fake_loading_bar('Loading Data', duration=1.3)
|
|
|
- response = client_request('transactions', {"session_id": connection.session_id,
|
|
|
+ response = client_request('trades_on', {"session_id": connection.session_id,
|
|
|
"ownable": obj_name,
|
|
|
"limit": limit})
|
|
|
success = 'data' in response
|
|
@@ -402,9 +401,26 @@ def transactions(obj_name=None, limit=5):
|
|
|
tablefmt="pipe"))
|
|
|
else:
|
|
|
if 'error_message' in response:
|
|
|
- print('Transactions access failed with message:', response['error_message'])
|
|
|
+ print('Trades access failed with message:', response['error_message'])
|
|
|
+ else:
|
|
|
+ print('Trades access failed.')
|
|
|
+
|
|
|
+
|
|
|
+def trades(limit=10):
|
|
|
+ limit = float(limit)
|
|
|
+ fake_loading_bar('Loading Data', duration=2.7)
|
|
|
+ response = client_request('trades', {"session_id": connection.session_id,
|
|
|
+ "limit": limit})
|
|
|
+ success = 'data' in response
|
|
|
+ if success:
|
|
|
+ print(my_tabulate(response['data'],
|
|
|
+ headers=['Buy?', 'Name', 'Volume', 'Price', 'Time'],
|
|
|
+ tablefmt="pipe"))
|
|
|
+ else:
|
|
|
+ if 'error_message' in response:
|
|
|
+ print('Trades access failed with message:', response['error_message'])
|
|
|
else:
|
|
|
- print('Transactions access failed.')
|
|
|
+ print('Trades access failed.')
|
|
|
|
|
|
|
|
|
|