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 [2024/11/08 10:44] – bruno | compare_strategies_w_graph_3d [2025/03/14 11:20] (current) – bruno | ||
|---|---|---|---|
| Line 7: | Line 7: | ||
| # https:// | # https:// | ||
| + | import numpy as np | ||
| import pandas as pd | import pandas as pd | ||
| + | import talib as ta | ||
| - | #df = kbt_init(' | + | # Donwload data |
| - | df = pd.read_csv(' | + | # https:// |
| - | #df = df[int(-3*365):] | + | df = pd.read_csv(' |
| + | df = df[int(-10.5*365):] | ||
| + | df[' | ||
| + | |||
| def fct (df, slow, fast): | def fct (df, slow, fast): | ||
| + | df[' | ||
| + | df[' | ||
| + | df[' | ||
| + | df[' | ||
| + | df[' | ||
| + | df[' | ||
| + | df[' | ||
| + | df[' | ||
| + | return np.exp(df[' | ||
| + | |||
| + | def fct2 (df, slow, fast): | ||
| df[' | df[' | ||
| df[' | df[' | ||
| Line 19: | Line 34: | ||
| df = kbt_compute(df) | df = kbt_compute(df) | ||
| return 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" | ||
| + | |||
| import matplotlib.pyplot as plt | import matplotlib.pyplot as plt | ||
| from matplotlib import cm | from matplotlib import cm | ||
| from mpl_toolkits.mplot3d import axes3d | from mpl_toolkits.mplot3d import axes3d | ||
| + | |||
| fig = plt.figure() | fig = plt.figure() | ||
| ax = fig.add_subplot(projection=' | ax = fig.add_subplot(projection=' | ||
| - | + | ||
| - | + | ||
| - | + | ||
| # Plot a basic wireframe. | # Plot a basic wireframe. | ||
| 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(' | ||
| ax.set_ylabel(' | ax.set_ylabel(' | ||
| ax.set_zlabel(' | ax.set_zlabel(' | ||
| ax.set_title(' | ax.set_title(' | ||
| + | |||
| # https:// | # https:// | ||
| ind = np.unravel_index(np.argmax(Z, | ind = np.unravel_index(np.argmax(Z, | ||
| print(ind, SLOW[ind], FAST[ind], Z[ind]) | print(ind, SLOW[ind], FAST[ind], Z[ind]) | ||
| + | |||
| plt.show() | plt.show() | ||
| + | |||
| </ | </ | ||
compare_strategies_w_graph_3d.1731062652.txt.gz · Last modified: 2024/11/08 10:44 by bruno
