|
@@ -131,6 +131,32 @@ def buy(amount=None, object_name=None, limit='', stop_loss=''):
|
|
"stop_loss": stop_loss})
|
|
"stop_loss": stop_loss})
|
|
if 'error_message' in response:
|
|
if 'error_message' in response:
|
|
print('Order placement failed with message:', response['error_message'])
|
|
print('Order placement failed with message:', response['error_message'])
|
|
|
|
+ else:
|
|
|
|
+ print('You might want to use the `transactions` or `depot` commands',
|
|
|
|
+ 'to see if the order has been executed already.')
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+def sell(amount=None, object_name=None, limit='', stop_loss=''):
|
|
|
|
+ if object_name is None: # TODO list some available objects
|
|
|
|
+ object_name = input('Name of object to sell: ')
|
|
|
|
+ if amount is None:
|
|
|
|
+ amount = input('Amount: ')
|
|
|
|
+ if limit != '':
|
|
|
|
+ set_limit = yn_dialog('Do you want to place a limit?')
|
|
|
|
+ if set_limit:
|
|
|
|
+ limit = input('Limit: ')
|
|
|
|
+ stop_loss = yn_dialog('Is this a stop-loss limit?')
|
|
|
|
+ response = client_request('order', {"buy": False,
|
|
|
|
+ "session_id": connection.session_id,
|
|
|
|
+ "amount": amount,
|
|
|
|
+ "ownable": object_name,
|
|
|
|
+ "limit": limit,
|
|
|
|
+ "stop_loss": stop_loss})
|
|
|
|
+ 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',
|
|
|
|
+ 'to see if the order has been executed already.')
|
|
|
|
|
|
|
|
|
|
def orders():
|
|
def orders():
|
|
@@ -159,3 +185,19 @@ def news():
|
|
print('Order access failed with message:', response['error_message'])
|
|
print('Order access failed with message:', response['error_message'])
|
|
else:
|
|
else:
|
|
print('Order access failed.')
|
|
print('Order access failed.')
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+def transactions(object_name=None):
|
|
|
|
+ if object_name is None: # TODO list some available objects
|
|
|
|
+ object_name = input('Name of object to check: ')
|
|
|
|
+ response = client_request('transactions', {"session_id": connection.session_id, "ownable": object_name})
|
|
|
|
+ success = 'data' in response
|
|
|
|
+ if success:
|
|
|
|
+ print(tabulate(response['data'],
|
|
|
|
+ # TODO headers=['Date', 'Title'],
|
|
|
|
+ tablefmt="pipe"))
|
|
|
|
+ else:
|
|
|
|
+ if 'error_message' in response:
|
|
|
|
+ print('Transactions access failed with message:', response['error_message'])
|
|
|
|
+ else:
|
|
|
|
+ print('Transactions access failed.')
|