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/09/13 09:34] – bruno | compare_strategies_w_graph_3d [2025/03/14 11:20] (current) – bruno | ||
---|---|---|---|
Line 7: | Line 7: | ||
# https:// | # https:// | ||
- | #df = kbt_init(' | + | import numpy as np |
- | df = pd.read_csv(' | + | import pandas as pd |
- | #df = df[int(-3*365): | + | import talib as ta |
+ | # Donwload data | ||
+ | # https:// | ||
+ | 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 17: | 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.1726220046.txt.gz · Last modified: 2024/09/13 09:34 by bruno