This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def mean(series: pd.Series, days: int = 14) -> float: | |
| return round(series.iloc[-days:].mean(),2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def mean(data: list, days: int = 14) -> float: | |
| return round(sum(data[-days:]) / len(data[-days:]),2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| df = pd.read_csv("btcusdt_jan_2020.csv") | |
| df | |
| # Outputs: | |
| # <DataFrame with 31 OHLC prices from 1st of January, 2020> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| import pandas as pd | |
| from prettytable import PrettyTable |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| data_df.iloc[:, 1:5] = data_df.iloc[:, 1:5].astype(float).round(decimals=2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| data_df['OpenTime'] = open_times | |
| data_df['CloseTime'] = close_times |