while(coin != "quit"):
if coin.upper() in coin_list:
cal = position_size(coin = "usdt", stop = Stoploss, pair = coin)
balance = cal[0]
price = cal[1]
decision = input("Do you want to buy ? (Y/N)")
if decision == "Y":
order_detail = buy_market(coin=coin.upper(), balance_to_buy=balance,
_entry_price=price)
print("Order placed successfully!")
print()
print("--------------------------")
print("Quantity :", order_detail[0])
print("Amount :", order_detail[1])
print("Status :", order_detail[2])
print("--------------------------")
else:
print("Order cancelled!")
coin = input("Enter coin name (enter 'quit' to stop program) :")
if (coin != "quit"):
if coin.upper() in coin_list :
avg_price = client.get_avg_price(symbol = coin.upper())
avg_price = round(float(avg_price["price"]),5)
print("average price is : ", str(avg_price))
Stop_loss = input("Enter your stop loss :")
Stop_loss = float(Stop_loss)
else :
print()
print("**************************")
print("** invalid coin **")
print("**************************")
and this is the error 👍
File "C:\Users\Rami_Alyazedi\AppData\Local\Programs\Python\Python310\lib\site-packages\binance\client.py", line 324, in _handle_response
raise BinanceAPIException(response, response.status_code, response.text)
binance.exceptions.BinanceAPIException: APIError(code=-1100): Illegal characters found in parameter 'quantity'; legal range is '^([0-9]{1,20})(.[0-9]{1,20})?$'.
I wrote a code that buy from Binance Market but i got an issue that i tried to solve it many time but i did not .
this is my code :
import binance.client from binance.client import Client import bot_ram
API keys from bot_ram file
x = bot_ram.Pkey y = bot_ram.Skey
client = Client(api_key=x , api_secret=y)
def positionsize(coin,stop,pair):
def buy_market(coin , balance_to_buy , _entry_price): qty = round(balance_to_buy/_entry_price,2) detail = client.order_limit_buy(symbol = coin , quantity= qty)
coin = input("Enter coin name (enter 'quit' to stop program) :") if (coin != "quit"): if coin.upper() in coin_list :
while(coin != "quit"): if coin.upper() in coin_list: cal = position_size(coin = "usdt", stop = Stoploss, pair = coin) balance = cal[0] price = cal[1] decision = input("Do you want to buy ? (Y/N)") if decision == "Y": order_detail = buy_market(coin=coin.upper(), balance_to_buy=balance, _entry_price=price)
and this is the error 👍 File "C:\Users\Rami_Alyazedi\AppData\Local\Programs\Python\Python310\lib\site-packages\binance\client.py", line 324, in _handle_response raise BinanceAPIException(response, response.status_code, response.text) binance.exceptions.BinanceAPIException: APIError(code=-1100): Illegal characters found in parameter 'quantity'; legal range is '^([0-9]{1,20})(.[0-9]{1,20})?$'.