1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
m = 10000
h = 0
b = 0
p = 0
q = 0
control_list = []
for i in range(len(Times)):
x1 = 0
x2 = 0
j = 0
t = 0
if i <= 9:
control_list.append([i,0,m,h,j,b,t,x1,x2])
continue
else:
if i not in list(np.array(BH['0'])):
control_list.append([i,0,m,h,j,b,t,x1,x2])
continue
if np.array(BH[BH['0'].isin([str(i)])]['1_x'])[0] != 0: # H
# if np.array(BH[BH['0'].isin([str(i)])]['2_y'])[0] == 0: # B
if np.array(BH[BH['0'].isin([str(i)])]['1_x'])[0] < 0: # 买
j = np.array(H[H['0'].isin([i])]['2'])[0]
print(j)
x1 = np.array(Times.iloc[[i]]['0'])[0]
x2 = np.array(Times.iloc[[i]]['1'])[0]
p = m*x1#(x1/(x1+x2))
q = m*x2#(x2/(x1+x2))
h = (p-0.01*p)/j
p = 0
m = p + q
control_list.append([i,11,m,h,j,b,0,x1,x2])
# print(m)
if np.array(BH[BH['0'].isin([str(i)])]['1_x'])[0] > 0: # 卖
j = np.array(H[H['0'].isin([i])]['2'])[0]
x1 = np.array(Times.iloc[[i]]['0'])[0]
x2 = np.array(Times.iloc[[i]]['1'])[0]
p = m*x1
q = m*x2
m = h*j-h*j*0.01+p+q
h = 0
control_list.append([i,-11,m,h,j,b,0,x1,x2])
# print(m)
# if np.array(BH[BH['0'].isin([str(i)])]['2_x'])[0] == 0: # H
if np.array(BH[BH['0'].isin([str(i)])]['1_y'])[0] != 0: # B
if np.array(BH[BH['0'].isin([str(i)])]['1_y'])[0] < 0: # 买
t = np.array(B[B['0'].isin([i])]['2'])[0]
x1 = np.array(Times.iloc[[i]]['0'])[0]
x2 = np.array(Times.iloc[[i]]['1'])[0]
p = m*x1#(x1/(x1+x2))
q = m*x2#(x2/(x1+x2))
b = (q-0.02*q)/t
q = 0
m = p + q
control_list.append([i,22,m,h,0,b,t,x1,x2])
# print(m)
elif np.array(BH[BH['0'].isin([str(i)])]['1_y'])[0] > 0: # 卖
t = np.array(B[B['0'].isin([i])]['2'])[0]
x1 = np.array(Times.iloc[[i]]['0'])[0]
x2 = np.array(Times.iloc[[i]]['1'])[0]
p = m*x1
q = m*x2
m = b*t-b*t*0.02+p+q
b = 0
control_list.append([i,-22,m,h,0,b,t,x1,x2])
# print(m)
m
|