Skip to content

Instantly share code, notes, and snippets.

@vnegi10
Created January 27, 2024 16:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vnegi10/05af3b2b3255d4f29139d39f6beb561a to your computer and use it in GitHub Desktop.
Save vnegi10/05af3b2b3255d4f29139d39f6beb561a to your computer and use it in GitHub Desktop.
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