add tools
This commit is contained in:
47
tools/cuire.py
Normal file
47
tools/cuire.py
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
import tkinter as tk
|
||||||
|
from tkinter import messagebox
|
||||||
|
|
||||||
|
class QuestionResponderApp:
|
||||||
|
def __init__(self, root):
|
||||||
|
self.root = root
|
||||||
|
self.root.title("Question Répondeur")
|
||||||
|
|
||||||
|
# Configurer la taille de la fenêtre
|
||||||
|
self.root.geometry("400x200")
|
||||||
|
self.root.resizable(False, False)
|
||||||
|
|
||||||
|
# Ajout d'un titre
|
||||||
|
self.title_label = tk.Label(
|
||||||
|
root, text="Posez votre question", font=("Helvetica", 16), pady=10
|
||||||
|
)
|
||||||
|
self.title_label.pack()
|
||||||
|
|
||||||
|
# Champ de saisie
|
||||||
|
self.input_box = tk.Entry(root, font=("Helvetica", 14), width=40)
|
||||||
|
self.input_box.pack(pady=10)
|
||||||
|
|
||||||
|
# Bouton pour poser la question
|
||||||
|
self.ask_button = tk.Button(
|
||||||
|
root, text="Poser la question", font=("Helvetica", 14), command=self.respond
|
||||||
|
)
|
||||||
|
self.ask_button.pack(pady=10)
|
||||||
|
|
||||||
|
# Bouton pour quitter
|
||||||
|
self.quit_button = tk.Button(
|
||||||
|
root, text="Quitter", font=("Helvetica", 12), command=root.quit
|
||||||
|
)
|
||||||
|
self.quit_button.pack(side="bottom", pady=10)
|
||||||
|
|
||||||
|
def respond(self):
|
||||||
|
question = self.input_box.get()
|
||||||
|
if question.strip(): # Si la question n'est pas vide
|
||||||
|
messagebox.showinfo("Réponse", "Va te faire cuire le cul.")
|
||||||
|
else:
|
||||||
|
messagebox.showwarning("Erreur", "Veuillez poser une question.")
|
||||||
|
|
||||||
|
# Lancer l'application
|
||||||
|
if __name__ == "__main__":
|
||||||
|
root = tk.Tk()
|
||||||
|
app = QuestionResponderApp(root)
|
||||||
|
root.mainloop()
|
||||||
|
|
||||||
67
tools/depth.py
Normal file
67
tools/depth.py
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
import requests
|
||||||
|
import pandas as pd
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
|
import argparse
|
||||||
|
|
||||||
|
# Initialisation du parser
|
||||||
|
parser = argparse.ArgumentParser(description='Programme qui accepte des paramètres.')
|
||||||
|
|
||||||
|
# Ajout d'arguments
|
||||||
|
parser.add_argument('--crypto', type=str, help='nom de la crypto (BTC)')
|
||||||
|
parser.add_argument('--nb', type=int, help='nombre d\'élément du cumul')
|
||||||
|
parser.add_argument('--horizon', type=int, help='nombre d\'élément à lire')
|
||||||
|
parser.add_argument('--verbose', action='store_true', help='Mode verbeux')
|
||||||
|
|
||||||
|
# Parsing des arguments
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
# Utilisation des arguments
|
||||||
|
print(f"Premier argument : {args.crypto}")
|
||||||
|
print(f"Deuxième argument : {args.nb}")
|
||||||
|
print(f"Troisième argument : {args.horizon}")
|
||||||
|
|
||||||
|
if args.verbose:
|
||||||
|
print("Mode verbeux activé")
|
||||||
|
|
||||||
|
# Fetch the API data
|
||||||
|
url = "https://api.binance.com/api/v3/depth?symbol=" + args.crypto + "USDT&limit=" + str(args.horizon)
|
||||||
|
response = requests.get(url)
|
||||||
|
data = response.json()
|
||||||
|
|
||||||
|
# Extract bids and asks
|
||||||
|
bids = data['bids']
|
||||||
|
asks = data['asks']
|
||||||
|
|
||||||
|
# Prepare data for plotting
|
||||||
|
bid_amounts = [float(bid[0]) for bid in bids]
|
||||||
|
bid_volumes = [float(bid[1]) for bid in bids]
|
||||||
|
|
||||||
|
ask_amounts = [float(ask[0]) for ask in asks]
|
||||||
|
ask_volumes = [float(ask[1]) for ask in asks]
|
||||||
|
|
||||||
|
# Convert to pandas DataFrame to apply moving average
|
||||||
|
bid_df = pd.DataFrame({'amount': bid_amounts, 'volume': bid_volumes})
|
||||||
|
ask_df = pd.DataFrame({'amount': ask_amounts, 'volume': ask_volumes})
|
||||||
|
|
||||||
|
# Apply a rolling window to calculate a n-value simple moving average (SMA)
|
||||||
|
bid_df['volume_sma'] = bid_df['volume'].rolling(window=args.nb).mean()
|
||||||
|
ask_df['volume_sma'] = ask_df['volume'].rolling(window=args.nb).mean()
|
||||||
|
|
||||||
|
# Plot the data
|
||||||
|
plt.figure(figsize=(10, 6))
|
||||||
|
|
||||||
|
# Plot raw bids and asks
|
||||||
|
#plt.plot(bid_df['amount'], bid_df['volume'], label='Bids (Raw)', color='green', alpha=0.3)
|
||||||
|
#plt.plot(ask_df['amount'], ask_df['volume'], label='Asks (Raw)', color='red', alpha=0.3)
|
||||||
|
|
||||||
|
# Plot the moving average
|
||||||
|
plt.plot(bid_df['amount'], bid_df['volume_sma'], label='Bids (SMA)', color='darkgreen')
|
||||||
|
plt.plot(ask_df['amount'], ask_df['volume_sma'], label='Asks (SMA)', color='darkred')
|
||||||
|
|
||||||
|
plt.title(f"Order Book Depth: {args.crypto}/USDT (with n-value SMA)")
|
||||||
|
plt.xlabel('Price (USDT)')
|
||||||
|
plt.ylabel(f"Volume ({args.crypto})")
|
||||||
|
plt.legend()
|
||||||
|
plt.grid(True)
|
||||||
|
plt.show()
|
||||||
|
|
||||||
17
tools/sma5.py
Normal file
17
tools/sma5.py
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import pandas as pd
|
||||||
|
import yfinance as yf
|
||||||
|
|
||||||
|
# Télécharger les données historiques de Bitcoin
|
||||||
|
data = yf.download('BTC-USD', start='2021-07-20', end='2022-06-27', interval='1d')
|
||||||
|
|
||||||
|
# Calculer la SMA5
|
||||||
|
data['SMA5'] = data['Close'].rolling(window=5).mean()
|
||||||
|
|
||||||
|
# Calculer la pente (différence quotidienne de la SMA5)
|
||||||
|
data['SMA5_slope'] = data['SMA5'].diff()
|
||||||
|
|
||||||
|
# Calculer la pente moyenne sur la période
|
||||||
|
average_slope = data['SMA5_slope'].mean()
|
||||||
|
|
||||||
|
print(f"Pente moyenne de la SMA5 journalière : {average_slope:.6f}")
|
||||||
|
|
||||||
Reference in New Issue
Block a user