Добрый день помогите пожалуйста решить две проблемы в этом моем коде:
1)Как сделать чтобы значения выводились построчно?
2)И как добавить подписи?
Вот исходный код и вывод
%matplotlib inline
import pandas as pd
import matplotlib.pyplot as plt
import warnings
import numpy as np
warnings.filterwarnings('ignore')
file = r"C:\DS\Sberbank_5.csv"
df = pd.read_csv(file, sep=";")
#print(df.head(5))
df.raznica = df["<CLOSE>"] - df["<OPEN>"]
d = [i for i in df.raznica]
o = [i for i in df["<OPEN>"]]
c = [i for i in df["<CLOSE>"]]
v = [i for i in df["<VOL>"]]
def ind(q, w, e):
ind_bull_pogl = []
ind_bear_pogl = []
k = 1
for i in range(len(d) - 20):
if (d[i] < 0) and (d[i+1] < 0) and (d[i+2] < 0) and (d[i+3] > 0) and ((abs(d[i+3])/abs(d[i+2])) > q) and (((abs(d[i+2])*100)/o[i+2]) > w) and ((((o[i] - c[i+2])*100)/c[i+2]) > e):
ind_bull_pogl.append(i+3)
for i in range(len(d) - 20):
if (d[i] > 0) and (d[i+1] > 0) and (d[i+2] > 0) and (d[i+3] < 0) and ((abs(d[i+3])/abs(d[i+2])) > q) and (((abs(d[i+2])*100)/o[i+2]) > w) and ((((c[i+2] - o[i])*100)/c[i+2]) > e):
ind_bear_pogl.append(i+3)
profit_bull = [c[i + k] - c[i] for i in ind_bull_pogl]
profit_bear = [c[i] - c[i + k] for i in ind_bear_pogl]
summa = sum(profit_bull) + sum(profit_bear)
return summa, len(profit_bull), len(profit_bear)
q = [1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2. , 2.1, 2.2, 2.3,
2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 3. , 3.1, 3.2, 3.3, 3.4, 3.5, 3.6,
3.7, 3.8, 3.9, 4. ]
w = [0.05, 0.1 , 0.15, 0.2 ]
e = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1. ]
pb_dict = {}
for i in q:
for ii in w:
for iii in e:
pb_dict[i, ii, iii]=ind(i, ii, iii)
pb_Dict = [(k, pb_dict[k]) for k in sorted(pb_dict, key=pb_dict.get, reverse=True)]
print(pb_Dict[0: 25])
Хочу получить следующий вывод
То, как на картинке это такой вывод я хочу получить (клепал в пэинте)