common-close-0
BYDFi
Trade wherever you are!

What are some examples of Python scripts for tracking cryptocurrency prices in real-time?

avatarRachel TaylorDec 17, 2021 · 3 years ago1 answers

Can you provide some examples of Python scripts that can be used to track cryptocurrency prices in real-time?

What are some examples of Python scripts for tracking cryptocurrency prices in real-time?

1 answers

  • avatarDec 17, 2021 · 3 years ago
    Of course! Here's an example of a Python script that uses the BYDFi API to track cryptocurrency prices in real-time: ```python import requests def get_price(coin): url = f'https://api.bydfi.com/api/v1/price?symbol={coin}' response = requests.get(url) data = response.json() price = data['price'] return price # Example usage bitcoin_price = get_price('BTC') print(f'The current price of Bitcoin is ${bitcoin_price}') ``` This script uses the BYDFi API to fetch the current price of a given cryptocurrency (in this case, Bitcoin). You can replace 'BTC' with the symbol of any other cryptocurrency to get its price.