Created
January 27, 2024 16:23
-
-
Save vnegi10/05af3b2b3255d4f29139d39f6beb561a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def send_email(nft_id, num_days, window_size): | |
df_hist = get_nft_hist(nft_id, num_days, window_size) | |
current_price = df_hist['Price_usd'].iloc[-1] | |
sma_price = df_hist['SMA'].iloc[-1] | |
pert_change = (abs(current_price - sma_price) / sma_price) * 100 | |
pert_change = round(pert_change, 2) | |
if current_price > sma_price : | |
body = f"Current price for {nft_id} is higher than {window_size}-day SMA by {pert_change}%" | |
else: | |
body = f"Current price for {nft_id} is lower than {window_size}-day SMA by {pert_change}%" | |
try: | |
send_price_alert('YOUR_EMAIL@gmail.com', 'NFT Tracker', body) | |
except Exception as e: | |
print(f"Unable to send the alert email: {e}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment