8
8
from robin_stocks .robinhood .urls import *
9
9
10
10
@login_required
11
- def get_all_stock_orders (info = None ):
11
+ def get_all_stock_orders (info = None , account_number = None ):
12
12
"""Returns a list of all the orders that have been processed for the account.
13
13
14
14
:param info: Will filter the results to get a specific value.
@@ -17,13 +17,13 @@ def get_all_stock_orders(info=None):
17
17
a list of strings is returned where the strings are the value of the key that matches info.
18
18
19
19
"""
20
- url = orders_url ()
20
+ url = orders_url (account_number = account_number )
21
21
data = request_get (url , 'pagination' )
22
22
return (filter_data (data , info ))
23
23
24
24
25
25
@login_required
26
- def get_all_option_orders (info = None ):
26
+ def get_all_option_orders (info = None , account_number = None ):
27
27
"""Returns a list of all the option orders that have been processed for the account.
28
28
29
29
:param info: Will filter the results to get a specific value.
@@ -32,7 +32,7 @@ def get_all_option_orders(info=None):
32
32
a list of strings is returned where the strings are the value of the key that matches info.
33
33
34
34
"""
35
- url = option_orders_url ()
35
+ url = option_orders_url (account_number = account_number )
36
36
data = request_get (url , 'pagination' )
37
37
return (filter_data (data , info ))
38
38
@@ -242,13 +242,13 @@ def cancel_crypto_order(orderID):
242
242
243
243
244
244
@login_required
245
- def cancel_all_stock_orders ():
245
+ def cancel_all_stock_orders (account_number = None ):
246
246
"""Cancels all stock orders.
247
247
248
248
:returns: The list of orders that were cancelled.
249
249
250
250
"""
251
- url = orders_url ()
251
+ url = orders_url (account_number = account_number )
252
252
data = request_get (url , 'pagination' )
253
253
254
254
data = [item for item in data if item ['cancel' ] is not None ]
@@ -261,13 +261,13 @@ def cancel_all_stock_orders():
261
261
262
262
263
263
@login_required
264
- def cancel_all_option_orders ():
264
+ def cancel_all_option_orders (account_number = None ):
265
265
"""Cancels all option orders.
266
266
267
267
:returns: Returns the order information for the orders that were cancelled.
268
268
269
269
"""
270
- url = option_orders_url ()
270
+ url = option_orders_url (account_number = account_number )
271
271
data = request_get (url , 'pagination' )
272
272
273
273
data = [item for item in data if item ['cancel_url' ] is not None ]
@@ -768,7 +768,7 @@ def order_trailing_stop(symbol, quantity, side, trailAmount, trailType='percenta
768
768
else :
769
769
payload ['trailing_peg' ] = {'type' : 'percentage' , 'percentage' : str (percentage )}
770
770
771
- url = orders_url ()
771
+ url = orders_url (account_number = account_number )
772
772
data = request_post (url , payload , json = True , jsonify_data = jsonify )
773
773
774
774
return (data )
@@ -856,7 +856,8 @@ def order(symbol, quantity, side, limitPrice=None, stopPrice=None, account_numbe
856
856
}
857
857
# adjust market orders
858
858
if orderType == 'market' :
859
- del payload ['stop_price' ]
859
+ if trigger != "stop" :
860
+ del payload ['stop_price' ]
860
861
# if market_hours == 'regular_hours':
861
862
# del payload['extended_hours']
862
863
@@ -872,7 +873,7 @@ def order(symbol, quantity, side, limitPrice=None, stopPrice=None, account_numbe
872
873
payload ['type' ] = 'limit'
873
874
payload ['quantity' ]= int (payload ['quantity' ]) # round to integer instead of fractional
874
875
875
- url = orders_url ()
876
+ url = orders_url (account_number = account_number )
876
877
# print(payload)
877
878
data = request_post (url , payload , jsonify_data = jsonify )
878
879
@@ -1004,7 +1005,7 @@ def order_option_spread(direction, price, symbol, quantity, spread, account_numb
1004
1005
'ref_id' : str (uuid4 ()),
1005
1006
}
1006
1007
1007
- url = option_orders_url ()
1008
+ url = option_orders_url (account_number = account_number )
1008
1009
data = request_post (url , payload , json = True , jsonify_data = jsonify )
1009
1010
1010
1011
return (data )
@@ -1067,7 +1068,7 @@ def order_buy_option_limit(positionEffect, creditOrDebit, price, symbol, quantit
1067
1068
'ref_id' : str (uuid4 ()),
1068
1069
}
1069
1070
1070
- url = option_orders_url ()
1071
+ url = option_orders_url (account_number = account_number )
1071
1072
# print(payload)
1072
1073
data = request_post (url , payload , json = True , jsonify_data = jsonify )
1073
1074
@@ -1134,7 +1135,7 @@ def order_buy_option_stop_limit(positionEffect, creditOrDebit, limitPrice, stopP
1134
1135
'ref_id' : str (uuid4 ()),
1135
1136
}
1136
1137
1137
- url = option_orders_url ()
1138
+ url = option_orders_url (account_number = account_number )
1138
1139
data = request_post (url , payload , json = True , jsonify_data = jsonify )
1139
1140
1140
1141
return (data )
@@ -1199,7 +1200,7 @@ def order_sell_option_stop_limit(positionEffect, creditOrDebit, limitPrice, stop
1199
1200
'ref_id' : str (uuid4 ()),
1200
1201
}
1201
1202
1202
- url = option_orders_url ()
1203
+ url = option_orders_url (account_number = account_number )
1203
1204
data = request_post (url , payload , json = True , jsonify_data = jsonify )
1204
1205
1205
1206
return (data )
@@ -1262,7 +1263,7 @@ def order_sell_option_limit(positionEffect, creditOrDebit, price, symbol, quanti
1262
1263
'ref_id' : str (uuid4 ()),
1263
1264
}
1264
1265
1265
- url = option_orders_url ()
1266
+ url = option_orders_url (account_number = account_number )
1266
1267
data = request_post (url , payload , json = True , jsonify_data = jsonify )
1267
1268
1268
1269
return (data )
0 commit comments