|
@@ -226,7 +226,7 @@ def buy(obj_name=None, amount=None, limit='', stop_loss='', expiry=None):
|
|
|
else:
|
|
|
limit = None
|
|
|
stop_loss = None
|
|
|
- if limit is not None and stop_loss == '':
|
|
|
+ if limit != '' and stop_loss == '':
|
|
|
stop_loss = yn_dialog('Is this a stop-loss limit?')
|
|
|
if limit is not None and \
|
|
|
float(limit) <= 0 and \
|
|
@@ -240,7 +240,7 @@ def buy(obj_name=None, amount=None, limit='', stop_loss='', expiry=None):
|
|
|
if expiry == '':
|
|
|
expiry = 43200
|
|
|
try:
|
|
|
- float(expiry)
|
|
|
+ expiry = float(expiry)
|
|
|
except ValueError:
|
|
|
print('Invalid expiration time.')
|
|
|
return
|
|
@@ -275,11 +275,23 @@ def sell(obj_name=None, amount=None, limit='', stop_loss='', expiry=None):
|
|
|
stop_loss = None
|
|
|
if limit != '' and stop_loss == '':
|
|
|
stop_loss = yn_dialog('Is this a stop-loss limit?')
|
|
|
+ if limit is not None and \
|
|
|
+ float(limit) <= 0 and \
|
|
|
+ input(input('Are you sure you want to use such a low limit (limit=' + str(
|
|
|
+ limit) + '? (type in "yes" or something else):') != 'yes'):
|
|
|
+ print('Order was not placed.')
|
|
|
+ return
|
|
|
|
|
|
if expiry is None:
|
|
|
expiry = input('Time until order expires (minutes, default 43200):')
|
|
|
if expiry == '':
|
|
|
expiry = 43200
|
|
|
+ try:
|
|
|
+ expiry = float(expiry)
|
|
|
+ except ValueError:
|
|
|
+ print('Invalid expiration time.')
|
|
|
+ return
|
|
|
+
|
|
|
fake_loading_bar('Loading Data', duration=1.3)
|
|
|
response = client_request('order', {"buy": False,
|
|
|
"session_id": connection.session_id,
|