line 41 print(f"Selling {qty} {coin_name.upper()}") ^ SyntaxError: invalid syntax
from binance.client import Client from binance.exceptions import BinanceAPIException import json import sys import time import math api_key = '--------------------------------------' api_secret = '----------------------------' client = Client(api_key, api_secret) amount = sys.argv[1] coin_name = sys.argv[2] SELL_DELAY = 4 symbol_info = client.get_symbol_info(coin_name.upper() + 'BNB') def place_order(coin_symbol, amnt): order = None try: order = client.order_market_buy( symbol=coin_symbol, quoteOrderQty=amnt) except BinanceAPIException as e: print(e.status_code) print(e.message) return order def sell_order(): sell = None try: balance = client.get_asset_balance(asset=coin_name.upper())['free'] qty = float(balance)*0.9995 step_size = symbol_info['filters'][2]['stepSize'] precision = int(round(-math.log(float(step_size), 10), 0)) qty = float(round(qty, precision)) print(f"Selling {qty} {coin_name.upper()}") sell = client.order_market_sell( symbol=coin_name.upper() + 'BNB', quantity=qty) except BinanceAPIException as e: print(e.status_code) print(e.message) return sell def main(): order = place_order(coin_name.upper() + 'BNB', amount) if order is not None: order_time_raw = str(order['transactTime']) order_time = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(int(order_time_raw[0:10]))) print("----------------------------------------------------------------") print("\nYou purchased {0} for Amount {1}\n".format(coin_name.upper(), amount)) print("----------------------------------------------------------------") print("Order Details:\n") print(f"Symbol: {order['symbol']}") print(f"Status: {order['status']}") print(f"Executed Quantity: {order['executedQty']}") print(f"Original Quantity: {order['fills'][0]['qty']}") print(f"Symbol Price: {order['fills'][0]['price']}") print(f"BNB Spent: {order['cummulativeQuoteQty']}") print(f"Executed at: {order_time}") print('Waiting For 5 Seconds\n') time.sleep(SELL_DELAY) print('Selling Now\n') sell = sell_order() if sell is not None: sell_time_raw = str(sell['transactTime']) sell_time = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(int(sell_time_raw[0:10]))) print("----------------------------------------------------------------") print("\nYou Sold {0} for Amount {1}\n".format(coin_name.upper(), amount)) print("----------------------------------------------------------------") print("Sale Details:\n") print(f"Symbol: {sell['symbol']}") print(f"Status: {sell['status']}") print(f"Executed Quantity: {sell['executedQty']}") print(f"Original Quantity: {sell['fills'][0]['qty']}") print(f"Symbol Price: {sell['fills'][0]['price']}") print(f"BNB Earned: {sell['cummulativeQuoteQty']}") print(f"Executed at: {sell_time}") print("\n----------------------------------------------------------------") print("[+] Happy Trading [+]") print("----------------------------------------------------------------") if __name__ == "__main__": main()
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)