* Titre de la page ... ... - mysql-connector-python - ssl - pandas - matplotlib - plotly from pyodide.http import open_url import mysql.connector import ssl import pandas as pd from datetime import datetime bot_name="helmi_bot" user_name="helmi" sql_password ="Magali_1984" #cnx = mysql.connector.connect(host="localhost", user="root", password=sql_password, port="3306", database="cryptos", auth_plugin="mysql_native_password") url_content = open_url("http://34.79.2.235/data_db.csv") data = pd.read_csv(url_content, index_col=False, names=["id","id2", "dates", "time", "user_name","bot_name", "actual_crypto_balence", "crypto_name","crypto_wallet"]) data["dates"] = pd.to_datetime(data["dates"], errors='coerce') # Creat new colom time with date data.drop(0, inplace=True) y = data["dates"].apply(lambda x : str(x)[:-9]) x = data["time"].apply(lambda x : str(x)[7:]) time_date=[] for i in range(len(data)): horraire = y.iloc[i] +" "+x.iloc[i] time_date.append(datetime.strptime(horraire, '%Y-%m-%d %H:%M:%S')) data["time_date"] = time_date helmi_data = data[data["bot_name"]=="helmi_bot"] data_1_20 = data[data["bot_name"]=="1_20_bot"] data_20_40 = data[data["bot_name"]=="20_40_bot"] data_40_60 = data[data["bot_name"]=="40_60_bot"] # Normalize wallet data data_1_20["crypto_wallet_scaled"] = data_1_20["crypto_wallet"].apply( lambda x: x/data_1_20["crypto_wallet"].mean()) data_20_40["crypto_wallet_scaled"] = data_20_40["crypto_wallet"].apply( lambda x: x/data_20_40["crypto_wallet"].mean()) data_40_60["crypto_wallet_scaled"] = data_40_60["crypto_wallet"].apply( lambda x: x/data_40_60["crypto_wallet"].mean()) helmi_data["crypto_wallet_scaled"] = helmi_data["crypto_wallet"].apply( lambda x: x/helmi_data["crypto_wallet"].mean())
import matplotlib.pyplot as plt fig, ax = plt.subplots(figsize=(20,7)) plt.plot(helmi_data["time_date"], helmi_data["crypto_wallet_scaled"], marker='o', linestyle='--', color='g', label='helmi') plt.plot(data_1_20["time_date"], data_1_20["crypto_wallet_scaled"], marker='d', linestyle='-', color='r', label='1_20_bot') plt.plot(data_20_40["time_date"], data_20_40["crypto_wallet_scaled"], marker='x', linestyle='-', color='b', label='20_40_bot') plt.plot(data_40_60["time_date"], data_40_60["crypto_wallet_scaled"], marker='x', linestyle='-', color='m', label='40_60_bot') plt.ylabel('Wallet (USDT)', size=20) plt.xlabel('Date',size=20) plt.title('Wallet evolution bot Cocotier mean normalized', size=40) #plt.xticks(rotation = 90) plt.legend(loc='best') fig import matplotlib.pyplot as plt fig, ax = plt.subplots(figsize=(20,7)) plt.plot(helmi_data["time_date"], helmi_data["crypto_wallet"], marker='o', linestyle='--', color='g', label='helmi') plt.plot(data_1_20["time_date"], data_1_20["crypto_wallet"], marker='d', linestyle='-', color='r', label='1_20_bot') plt.plot(data_20_40["time_date"], data_20_40["crypto_wallet"], marker='x', linestyle='-', color='b', label='20_40_bot') plt.plot(data_40_60["time_date"], data_40_60["crypto_wallet"], marker='x', linestyle='-', color='m', label='40_60_bot') plt.ylabel('Wallet (USDT)', size=20) plt.xlabel('Date',size=20) plt.title('Wallet evolution Bot Cocotier', size=40) #plt.xticks(rotation = 90) plt.legend(loc='best') fig