|
@@ -1,5 +1,6 @@
|
|
import json
|
|
import json
|
|
from datetime import timedelta, datetime
|
|
from datetime import timedelta, datetime
|
|
|
|
+from math import ceil, floor
|
|
|
|
|
|
from bottle import request, response
|
|
from bottle import request, response
|
|
from passlib.hash import sha256_crypt
|
|
from passlib.hash import sha256_crypt
|
|
@@ -88,6 +89,9 @@ def order():
|
|
|
|
|
|
buy = request.json['buy']
|
|
buy = request.json['buy']
|
|
sell = not buy
|
|
sell = not buy
|
|
|
|
+ if not isinstance(buy, bool):
|
|
|
|
+ return bad_request('`buy` must be a boolean')
|
|
|
|
+
|
|
session_id = request.json['session_id']
|
|
session_id = request.json['session_id']
|
|
amount = request.json['amount']
|
|
amount = request.json['amount']
|
|
try:
|
|
try:
|
|
@@ -115,7 +119,7 @@ def order():
|
|
else:
|
|
else:
|
|
limit = float(request.json['limit'])
|
|
limit = float(request.json['limit'])
|
|
except ValueError: # for example when float fails
|
|
except ValueError: # for example when float fails
|
|
- limit = None
|
|
|
|
|
|
+ return bad_request('Invalid limit.')
|
|
except KeyError: # for example when limit was not specified
|
|
except KeyError: # for example when limit was not specified
|
|
limit = None
|
|
limit = None
|
|
|
|
|