compare_strategies_w_graph_3d
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
compare_strategies_w_graph_3d [2025/03/02 22:10] – bruno | compare_strategies_w_graph_3d [2025/03/14 11:20] (current) – bruno | ||
---|---|---|---|
Line 7: | Line 7: | ||
# https:// | # https:// | ||
- | import pandas as pd | ||
- | |||
- | #df = kbt_init(' | ||
- | df = pd.read_csv(' | ||
- | #df = df[int(-3*365): | ||
- | |||
- | def fct (df, slow, fast): | ||
- | df[' | ||
- | df[' | ||
- | df[' | ||
- | df = kbt_compute(df) | ||
- | return df[' | ||
- | |||
- | SLOW = np.arange(5, | ||
- | FAST = np.arange(5, | ||
- | SLOW, FAST = np.meshgrid(SLOW, | ||
- | Z = np.zeros_like(SLOW) | ||
- | # https:// | ||
- | for i in range(SLOW.shape[0]): | ||
- | for j in range(SLOW.shape[1]): | ||
- | Z[i, j] = fct (df, SLOW[i, j], FAST[i, j]) | ||
- | print(f" | ||
- | |||
- | import matplotlib.pyplot as plt | ||
- | from matplotlib import cm | ||
- | from mpl_toolkits.mplot3d import axes3d | ||
- | |||
- | fig = plt.figure() | ||
- | ax = fig.add_subplot(projection=' | ||
- | |||
- | |||
- | | ||
- | # Plot a basic wireframe. | ||
- | ax.plot_surface(SLOW, | ||
- | |||
- | ax.view_init(elev=20, | ||
- | |||
- | ax.set_xlabel(' | ||
- | ax.set_ylabel(' | ||
- | ax.set_zlabel(' | ||
- | ax.set_title(' | ||
- | |||
- | # https:// | ||
- | ind = np.unravel_index(np.argmax(Z, | ||
- | print(ind, SLOW[ind], FAST[ind], Z[ind]) | ||
- | |||
- | plt.show() | ||
- | </ | ||
- | |||
- | <code python> | ||
import numpy as np | import numpy as np | ||
import pandas as pd | import pandas as pd | ||
import talib as ta | import talib as ta | ||
- | df = pd.read_csv(' | + | # Donwload data |
+ | # https://support.kraken.com/hc/en-us/articles/360047124832 | ||
+ | df = pd.read_csv(' | ||
+ | df = df[int(-10.5*365): | ||
+ | df[' | ||
+ | |||
def fct (df, slow, fast): | def fct (df, slow, fast): | ||
df[' | df[' | ||
Line 68: | Line 22: | ||
df[' | df[' | ||
df[' | df[' | ||
- | df[' | + | df[' |
df[' | df[' | ||
df[' | df[' | ||
df[' | df[' | ||
- | | + | |
- | return df[' | + | |
+ | def fct2 (df, slow, fast): | ||
+ | df[' | ||
+ | df[' | ||
+ | df[' | ||
+ | df = kbt_compute(df) | ||
+ | return df[' | ||
+ | |||
SLOW = np.arange(5, | SLOW = np.arange(5, | ||
FAST = np.arange(5, | FAST = np.arange(5, | ||
SLOW, FAST = np.meshgrid(SLOW, | SLOW, FAST = np.meshgrid(SLOW, | ||
- | Z = np.zeros_like(SLOW) | + | Z = np.zeros_like(SLOW).astype(float) |
# https:// | # https:// | ||
for i in range(SLOW.shape[0]): | for i in range(SLOW.shape[0]): | ||
for j in range(SLOW.shape[1]): | for j in range(SLOW.shape[1]): | ||
+ | # print(fct (df, | ||
Z[i, j] = fct (df, SLOW[i, j], FAST[i, j]) | Z[i, j] = fct (df, SLOW[i, j], FAST[i, j]) | ||
print(f" | print(f" | ||
Line 97: | Line 58: | ||
ax.plot_surface(SLOW, | ax.plot_surface(SLOW, | ||
- | ax.view_init(elev=20, azim=115, roll=0) | + | ax.view_init(elev=35, azim=115, roll=0) |
ax.set_xlabel(' | ax.set_xlabel(' | ||
Line 109: | Line 70: | ||
plt.show() | plt.show() | ||
+ | |||
</ | </ |
compare_strategies_w_graph_3d.1740953422.txt.gz · Last modified: 2025/03/02 22:10 by bruno