|
@@ -113,7 +113,7 @@ def yn_dialog(msg):
|
|
return False
|
|
return False
|
|
|
|
|
|
|
|
|
|
-def buy(amount=None, object_name=None, limit='', stop_loss=''):
|
|
|
|
|
|
+def buy(amount=None, object_name=None, limit='', stop_loss='', time_until_expiration=None):
|
|
if object_name is None: # TODO list some available objects
|
|
if object_name is None: # TODO list some available objects
|
|
object_name = input('Name of object to buy: ')
|
|
object_name = input('Name of object to buy: ')
|
|
if amount is None:
|
|
if amount is None:
|
|
@@ -123,12 +123,17 @@ def buy(amount=None, object_name=None, limit='', stop_loss=''):
|
|
if set_limit:
|
|
if set_limit:
|
|
limit = input('Limit: ')
|
|
limit = input('Limit: ')
|
|
stop_loss = yn_dialog('Is this a stop-loss limit?')
|
|
stop_loss = yn_dialog('Is this a stop-loss limit?')
|
|
|
|
+ if time_until_expiration is None:
|
|
|
|
+ time_until_expiration = input('Time until order expires (minutes, default 60):')
|
|
|
|
+ if time_until_expiration == '':
|
|
|
|
+ time_until_expiration = 60
|
|
response = client_request('order', {"buy": True,
|
|
response = client_request('order', {"buy": True,
|
|
"session_id": connection.session_id,
|
|
"session_id": connection.session_id,
|
|
"amount": amount,
|
|
"amount": amount,
|
|
"ownable": object_name,
|
|
"ownable": object_name,
|
|
"limit": limit,
|
|
"limit": limit,
|
|
- "stop_loss": stop_loss})
|
|
|
|
|
|
+ "stop_loss": stop_loss,
|
|
|
|
+ "time_until_expiration": time_until_expiration})
|
|
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:
|
|
else:
|
|
@@ -136,7 +141,7 @@ def buy(amount=None, object_name=None, limit='', stop_loss=''):
|
|
'to see if the order has been executed already.')
|
|
'to see if the order has been executed already.')
|
|
|
|
|
|
|
|
|
|
-def sell(amount=None, object_name=None, limit='', stop_loss=''):
|
|
|
|
|
|
+def sell(amount=None, object_name=None, limit='', stop_loss='', time_until_expiration=None):
|
|
if object_name is None: # TODO list some available objects
|
|
if object_name is None: # TODO list some available objects
|
|
object_name = input('Name of object to sell: ')
|
|
object_name = input('Name of object to sell: ')
|
|
if amount is None:
|
|
if amount is None:
|
|
@@ -146,12 +151,17 @@ def sell(amount=None, object_name=None, limit='', stop_loss=''):
|
|
if set_limit:
|
|
if set_limit:
|
|
limit = input('Limit: ')
|
|
limit = input('Limit: ')
|
|
stop_loss = yn_dialog('Is this a stop-loss limit?')
|
|
stop_loss = yn_dialog('Is this a stop-loss limit?')
|
|
|
|
+ if time_until_expiration is None:
|
|
|
|
+ time_until_expiration = input('Time until order expires (minutes, default 60):')
|
|
|
|
+ if time_until_expiration == '':
|
|
|
|
+ time_until_expiration = 60
|
|
response = client_request('order', {"buy": False,
|
|
response = client_request('order', {"buy": False,
|
|
"session_id": connection.session_id,
|
|
"session_id": connection.session_id,
|
|
"amount": amount,
|
|
"amount": amount,
|
|
"ownable": object_name,
|
|
"ownable": object_name,
|
|
"limit": limit,
|
|
"limit": limit,
|
|
- "stop_loss": stop_loss})
|
|
|
|
|
|
+ "stop_loss": stop_loss,
|
|
|
|
+ "time_until_expiration": time_until_expiration})
|
|
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:
|
|
else:
|
|
@@ -164,7 +174,7 @@ def orders():
|
|
success = 'data' in response
|
|
success = 'data' in response
|
|
if success:
|
|
if success:
|
|
print(tabulate(response['data'],
|
|
print(tabulate(response['data'],
|
|
- headers=['Buy?', 'Name', 'Amount', 'Limit', 'Stop Loss?', 'Orig. Order Size'],
|
|
|
|
|
|
+ headers=['Buy?', 'Name', 'Amount', 'Limit', 'Stop Loss?', 'Orig. Order Size', 'Expires'],
|
|
tablefmt="pipe"))
|
|
tablefmt="pipe"))
|
|
else:
|
|
else:
|
|
if 'error_message' in response:
|
|
if 'error_message' in response:
|