CCXT Take Profit and Stop Loss Error for a Pending Limit Order

78 Views Asked by At

I would like to edit a pending order for the inputs of take profit and stoploss (as far as I know it is not possible to perform placing order + take profit + stop loss together with a single command) but while editing I get 'float' object has no attribute 'upper' error. I am a bit new to Python and any help will be highly appreciated.

#-----------------------Get Order ID and Amount-------------------------
orders = exchange.fetchOpenOrders('LINKUSDT')
for order in orders:
    orderId = (order['id'])
print(orderId)
for order in orders:
    qty = float((order['amount']))
print(qty)
#------------------------------------------------------------
symbol = 'LINKUSDT'
order_id = orderId
order_type = 'limit'
side = 'sell'
amount = qty
price = 15.000
stop_loss = 15.100
take_profit = 14.920

exchange.edit_order(orderId, symbol, amount, order_type, {'stopLossPrice': stop_loss, 'takeProfitPrice': take_profit})

The output is:

line 47, in <module>
    exchange.edit_order(orderId, symbol, amount, order_type, {'stopLossPrice': stop_loss, 'takeProfitPrice': take_profit})
line 2222, in edit_order
    return self.create_order(symbol, *args)
line 2623, in create_order
    uppercaseType = type.upper()
AttributeError: 'float' object has no attribute 'upper'
1

There are 1 best solutions below

0
user16171413 On

The error shows the problem is from uppercaseType = type.upper() which is line 2623, in create_order file. The error message says AttributeError: 'float' object has no attribute 'upper'

Please note that the upper() method returns a string where all characters are in upper case. It's unclear how you intend to use this on float objects.

Also, as mentioned in the comments, type is a keyword in python and shouldn't be used as variable names.