Skip to content

Instantly share code, notes, and snippets.

View manuelinfosec's full-sized avatar
:octocat:
~ resolving merge conflicts

Manuel manuelinfosec

:octocat:
~ resolving merge conflicts
View GitHub Profile
def median(data: list, days: int = 14) -> float:
data = sorted(data[-days:])
length = len(data)
half = int(length / 2)
if length % 2 == 0:
new = data[half-1:half+1]
return round(sum(new) / len(new),2)
else:
return data[half]
def mean(data: list, days: int = 14) -> float:
return round(sum(data[-days:]) / len(data[-days:]),2)
series = df['Close'].to_list()
mean_price = mean(series)
print(f"${mean_price}")
# Outputs: $8851.92
def mean(series: pd.Series, days: int = 14) -> float:
return round(series.iloc[-days:].mean(),2)
series = df['Close']
mean_price = mean(series)
print(f"${mean_price}")
# Outputs: $8851.92
def mean(series: pd.Series, days: int = 14) -> float:
return round(series.iloc[-days:].mean(),2)
def mean(data: list, days: int = 14) -> float:
return round(sum(data[-days:]) / len(data[-days:]),2)
df = pd.read_csv("btcusdt_jan_2020.csv")
df
# Outputs:
# <DataFrame with 31 OHLC prices from 1st of January, 2020>
import numpy as np
import pandas as pd
from prettytable import PrettyTable
@manuelinfosec
manuelinfosec / maths_art.py
Last active August 2, 2022 12:02
Make sure numpy and matplotlib is installed through pip or conda
import math
import numpy as np
from matplotlib import pyplot as plt
t = np.linspace(0,39 * math.pi/2, 1000)
x = t * np.cos(t) ** 3
y = 9 * t * np.sqrt(abs(np.cos(t))) + t * np.sin(0.2 * t) * np.cos(4 * t)
plt.plot(x, y, c = "green")
data_df.iloc[:, 1:5] = data_df.iloc[:, 1:5].astype(float).round(decimals=2)
data_df['OpenTime'] = open_times
data_df['CloseTime'] = close_times