Python code for calculating how far are we away from our take profit price for $LEO

in voilk •  2 months ago

    It is said to be the bull season for crypto and some of us need to take profit!We are not always good with remembering how far the take profit price is just by looking at the current price, especially when we have multiple assets to watch for.So I have wrote this little Python script to tell us how far are we away from our target price in terms of percentage. What you can see above is that with the current LEO price of .22 HIVE, if I intend to sell my LEO at 1 HIVE, we are looking at an increase of 342.48%.The code reproduced here in case you like to try it.
    import requests
    import json
    token_symbol = "LEO"
    response = requests.get(f"https://accounts.hive-engine.com/marketHistory?symbol={token_symbol}")
    market_history = response.json()
    latest_price = float(market_history[0]["closePrice"])
    sell_price = 1
    required_increase = ((sell_price - latest_price) / latest_price) * 100
    print(f"The current price of {token_symbol} is {latest_price:.8f} HIVE")
    print(f"To reach the sell price of {sell_price:.8f} HIVE, you need an increase of {required_increase:.2f}%")

    Posted Using InLeo Alpha

      Authors get paid when people like you upvote their post.
      If you enjoyed what you read here, create your account today and start earning FREE VOILK!