Skip to content

Instantly share code, notes, and snippets.

from pages.floor_price.view import app, layout
from pages.floor_price.controller import *
app.layout = layout
if __name__ == '__main__':
app.run_server(port = 7000, debug=False)
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 :
from pages.floor_price.view import app
from dash.dependencies import Input, Output
from pages.floor_price.model import plot_nft_hist, plot_nft_markets, send_email
@app.callback(
Output(component_id = 'plot', component_property = 'figure'),
Input(component_id = 'MODE', component_property= 'value'),
Input(component_id = 'NFT_ID', component_property= 'value'),
Input(component_id = 'DURATION', component_property= 'value'),
Input(component_id = 'WINDOW_SIZE', component_property= 'value'),
import dash
from dash import html
from components.dropdown import *
from components.radioitems import *
from dash import dcc
APP_TITLE = "NFT Floor Price Tracker"
app = dash.Dash()
layout = html.Div(id = 'parent',
from dash import dcc
def duration_radiobutton():
radio = dcc.RadioItems(id = 'DURATION',
options = ['7', '14', '30', '60', '90', '180', '270', '365'],
value = '30',
inline = True,
)
return radio
def nft_dropdown():
dropdown = dcc.Dropdown(id = 'NFT_ID',
options = [
{'label': 'bitcoin-frogs', 'value':'bitcoin-frogs' },
{'label': 'mutant-ape-yacht-club', 'value':'mutant-ape-yacht-club'},
{'label': 'mad-lads', 'value':'mad-lads'},
{'label': 'cryptopunks', 'value': 'cryptopunks'},
{'label': 'the-crop-collective', 'value': 'the-crop-collective'}
],
value = 'pudgy-penguins')
def get_nft_floor_prices(order_by, per_page):
assert per_page <= 250, "Number of entries per page should be less than 250"
nft_params = {
"order": order_by,
"per_page": per_page,
"page": 1
}
def get_nft_current_data(index, df_nft, use_demo = use_demo,
PUB_URL = PUB_URL):
nft_url = f"/nfts/{df_nft.id[index]}"
nft_current_response = get_response(nft_url,
use_demo,
nft_params,
PUB_URL)
new_data = dict(id = nft_current_response["id"],
def get_demo_key():
f = open("/home/vikas/Documents/CG_demo_key.json")
key_dict = json.load(f)
return key_dict["key"]
import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
def send_price_alert(to_email, subject, body):
# Replace with your Gmail email address
sender_email = 'nftdemoapp@gmail.com'
# Replace with your Gmail app password