質問編集履歴
4
データを添付グラフにあうようなものにしました
test
CHANGED
File without changes
|
test
CHANGED
@@ -268,26 +268,42 @@
|
|
268
268
|
|
269
269
|
コード
|
270
270
|
|
271
|
-
|
271
|
+
DATE FINISH START HIGH LOW VOLUME RATE
|
272
|
-
|
273
|
-
|
272
|
+
|
274
|
-
|
275
|
-
2020/7/
|
273
|
+
2020/7/17 22,696.42 22,807.57 22,857.82 22,643.52 558.65M -0.32%
|
276
|
-
|
274
|
+
|
277
|
-
2020/7/16 22,770.36 22,907.96 22,925.90 22,739.42
|
275
|
+
2020/7/16 22,770.36 22,907.96 22,925.90 22,739.42 894.44M -0.76%
|
278
|
-
|
276
|
+
|
279
|
-
2020/7/15 22,945.50 22,817.91 22,965.56 22,800.11 1.59%
|
277
|
+
2020/7/15 22,945.50 22,817.91 22,965.56 22,800.11 725.70M 1.59%
|
280
|
-
|
278
|
+
|
281
|
-
2020/7/14 22,587.01 22,631.87 22,677.02 22,538.78 -0.87%
|
279
|
+
2020/7/14 22,587.01 22,631.87 22,677.02 22,538.78 609.65M -0.87%
|
282
|
-
|
280
|
+
|
283
|
-
2020/7/13 22,784.74 22,591.81 22,784.74 22,561.47 2.22%
|
281
|
+
2020/7/13 22,784.74 22,591.81 22,784.74 22,561.47 712.47M 2.22%
|
284
|
-
|
282
|
+
|
285
|
-
2020/7/10 22,290.81 22,534.97 22,563.68 22,285.07 -1.06%
|
283
|
+
2020/7/10 22,290.81 22,534.97 22,563.68 22,285.07 788.05M -1.06%
|
286
|
-
|
284
|
+
|
287
|
-
2020/7/9 22,529.29 22,442.30 22,679.08 22,434.38 0.40%
|
285
|
+
2020/7/9 22,529.29 22,442.30 22,679.08 22,434.38 651.67M 0.40%
|
288
|
-
|
286
|
+
|
289
|
-
2020/7/8 22,438.65 22,481.61 22,667.95 22,438.65 -0.78%
|
287
|
+
2020/7/8 22,438.65 22,481.61 22,667.95 22,438.65 649.12M -0.78%
|
290
|
-
|
288
|
+
|
291
|
-
2020/7/7 22,614.69 22,649.90 22,742.28 22,540.44 -0.44%
|
289
|
+
2020/7/7 22,614.69 22,649.90 22,742.28 22,540.44 626.64M -0.44%
|
292
|
-
|
290
|
+
|
293
|
-
2020/7/6 22,714.44 22,341.27 22,734.11 22,325.75
|
291
|
+
2020/7/6 22,714.44 22,341.27 22,734.11 22,325.75 580.11M 1.83%
|
292
|
+
|
293
|
+
2020/7/3 22,306.48 22,266.91 22,312.44 22,154.97 516.77M 0.72%
|
294
|
+
|
295
|
+
2020/7/2 22,145.96 22,182.68 22,267.51 22,072.11 735.69M 0.11%
|
296
|
+
|
297
|
+
2020/7/1 22,121.73 22,338.30 22,360.31 22,039.56 673.60M -0.75%
|
298
|
+
|
299
|
+
2020/6/30 22,288.14 22,335.10 22,448.30 22,273.38 741.69M 1.33%
|
300
|
+
|
301
|
+
2020/6/29 16,995.04 22,255.05 22,281.38 21,969.59 737.16M -2.30%
|
302
|
+
|
303
|
+
2020/6/26 12,512.08 22,424.37 22,589.14 22,408.27 666.39M 1.13%
|
304
|
+
|
305
|
+
2020/6/25 18,259.79 22,287.87 22,423.41 22,165.14 808.20M -1.22%
|
306
|
+
|
307
|
+
2020/6/24 12,534.32 22,541.01 22,663.29 22,479.86 669.68M -0.07%
|
308
|
+
|
309
|
+
2020/6/23 12,549.05 22,636.06 22,693.89 22,257.14 - 0.50%
|
3
コードを追加、図を追加しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -2,54 +2,192 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
|
5
|
-
プログラムを実行すると、終値、移動平均のグラフは表示されるのですが、散布図のY軸がうまく表示できません。添付のファイルのように散布図のY軸は
|
5
|
+
プログラムを実行すると、終値、移動平均のグラフは表示されるのですが、散布図のY軸がうまく表示できません。添付のファイルのように散布図のY軸は下記の’22,288.14’となってますが、本来はこの「22,288.14」はN255上の数値(N=15 のときはN255のY軸は22,288.14)と一致させたいのですが一致できないです
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
![![イメージ説明](6155c4844dc7ea7908c55c3673f9bc2b.png)説明](9106123498c62615e28fb6af5886721a.png)ジ説明](28b32ff52f3793afd4a3f98233950e9d.png)明](821275e844b03dd02ed3806af5dce030.png)](0712aa29bf2a5a32c80d741317563cd1.png)
|
6
10
|
|
7
11
|
|
8
12
|
|
9
13
|
終値のグラフは、下記でfloatに変換したうえで描いております
|
10
14
|
|
15
|
+
一方、散布図は、mydf1をiloc関数で抽出しております
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
散布図のY座標は
|
20
|
+
|
21
|
+
golden_y= ['22,288.14']のように’’があるからではと思いましたが
|
22
|
+
|
23
|
+
map関数をns=map(lambda s:float(s),golden_y)を試しましたがうまく変換できなかったです。
|
24
|
+
|
25
|
+
よく理解できていないです。
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
考えられる原因などにつきましてアドバイスいただけますと大変ありがたいです。
|
30
|
+
|
31
|
+
わかりにくい質問で申し訳ありませんがよろしくお願いいたします。
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
```python
|
38
|
+
|
39
|
+
<こちらはわかりにくいコードですので、もう1つ下のコードをご確認ください>
|
40
|
+
|
41
|
+
#移動平均GC DCを描く
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
import numpy as np
|
46
|
+
|
47
|
+
import pandas as pd
|
48
|
+
|
49
|
+
import matplotlib.pyplot as plt
|
50
|
+
|
51
|
+
from sklearn import linear_model
|
52
|
+
|
53
|
+
from sklearn import metrics
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
#CSVファイルの読み込み
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
mydf1=pd.read_csv('NIKKEI20200719.csv')
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
#DATEで順番の並び替え
|
66
|
+
|
67
|
+
mydf1=mydf1.sort_values(by=['DATE'])
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
#print(mydf.head())
|
72
|
+
|
73
|
+
N=len(mydf1)
|
74
|
+
|
75
|
+
print('N=',N)
|
76
|
+
|
11
77
|
|
12
78
|
|
13
79
|
nikkei=mydf1['FINISH']
|
14
80
|
|
15
|
-
nikkei=nikkei.apply(lambda x: x.replace(',','')).astype(np.float)
|
81
|
+
nikkei=nikkei.apply(lambda x: x.replace(',','')).astype(np.float)#これで終値グラフはfloat
|
82
|
+
|
83
|
+
|
84
|
+
|
16
|
-
|
85
|
+
types=[[5,25],[25,75],[13,26]]
|
86
|
+
|
17
|
-
|
87
|
+
for short_day,long_day in types:
|
88
|
+
|
18
|
-
|
89
|
+
#移動平均
|
90
|
+
|
91
|
+
rolling_s=nikkei.rolling(short_day).mean().fillna(0)
|
92
|
+
|
93
|
+
rolling_l=nikkei.rolling(long_day).mean().fillna(0)
|
94
|
+
|
95
|
+
#print('MA=',rolling_s.tail())
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
#クロスを確認
|
100
|
+
|
101
|
+
over = rolling_s > rolling_l
|
102
|
+
|
103
|
+
over_major=(over+over.shift(1)+over.shift(2))>=2
|
104
|
+
|
105
|
+
golden=(over_major!=over_major.shift(1))&(over_major==True)
|
106
|
+
|
107
|
+
dead=(over_major!=over_major.shift(1))&(over_major==False)
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
#列追加
|
112
|
+
|
113
|
+
#0:クロスなし、1:GC、-1:DC
|
114
|
+
|
115
|
+
col_name = 'cross_' + str(short_day)+'_'+str(long_day)
|
116
|
+
|
117
|
+
mydf1[col_name]=[x+y*-1 for x,y in zip(golden,dead)]
|
118
|
+
|
119
|
+
mydf1[col_name]=np.append(np.array([0]*(long_day+3)),mydf1[col_name][long_day+3:])
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
#チャート
|
124
|
+
|
125
|
+
plt.plot(range(len(mydf1)),nikkei,label='N255')
|
126
|
+
|
127
|
+
plt.plot(range(short_day-1,len(mydf1)),rolling_s[short_day-1:],color='r',label='MA'+str(short_day))
|
128
|
+
|
129
|
+
plt.plot(range(long_day-1,len(mydf1)),rolling_l[long_day-1:],color='g',label='MA'+str(long_day))
|
130
|
+
|
131
|
+
plt.legend(loc='upper left')
|
132
|
+
|
133
|
+
plt.grid()
|
134
|
+
|
135
|
+
plt.xlim(len(mydf1)-250,len(mydf1)+1)#
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
|
140
|
+
|
19
|
-
|
141
|
+
crosses=mydf1[mydf1[col_name]!=0]
|
142
|
+
|
143
|
+
golden_x = []
|
144
|
+
|
145
|
+
golden_y = []
|
146
|
+
|
147
|
+
golden_day=[]
|
148
|
+
|
149
|
+
dead_x=[]
|
150
|
+
|
151
|
+
dead_y=[]
|
152
|
+
|
153
|
+
dead_day=[]
|
20
154
|
|
21
155
|
for i in range(len(crosses)):
|
22
156
|
|
23
157
|
if (crosses.iloc[i][col_name]==1):
|
24
158
|
|
159
|
+
golden_x.append(crosses.index[i])
|
160
|
+
|
161
|
+
golden_y.append(crosses.iloc[i]['FINISH'])#golden_y はリストを参照にする
|
162
|
+
|
163
|
+
golden_day.append(crosses.iloc[i]['DATE'])#
|
164
|
+
|
165
|
+
else:
|
166
|
+
|
167
|
+
dead_x.append(crosses.index[i])
|
168
|
+
|
25
|
-
|
169
|
+
dead_y.append(crosses.iloc[i]['FINISH'])#
|
26
|
-
|
27
|
-
|
28
|
-
|
170
|
+
|
29
|
-
|
171
|
+
dead_day.append(crosses.iloc[i]['DATE'])#
|
30
|
-
|
172
|
+
|
173
|
+
|
174
|
+
|
31
|
-
golden_y=
|
175
|
+
plt.scatter(golden_x,golden_y,c='black',s=80,marker='^')
|
32
|
-
|
176
|
+
|
177
|
+
|
178
|
+
|
33
|
-
|
179
|
+
plt.show()
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
180
|
+
|
38
|
-
|
39
|
-
|
181
|
+
```
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
182
|
+
|
183
|
+
|
184
|
+
|
45
|
-
```python
|
185
|
+
```python
|
186
|
+
|
46
|
-
|
187
|
+
<こちらを確認してもらえると助かります>
|
47
|
-
|
48
188
|
|
49
189
|
#移動平均GC DCを描く
|
50
190
|
|
51
|
-
|
52
|
-
|
53
191
|
import numpy as np
|
54
192
|
|
55
193
|
import pandas as pd
|
@@ -64,9 +202,7 @@
|
|
64
202
|
|
65
203
|
#CSVファイルの読み込み
|
66
204
|
|
67
|
-
|
68
|
-
|
69
|
-
mydf1=pd.read_csv('NIKKEI202007
|
205
|
+
mydf1=pd.read_csv('NIKKEI20200726.csv')
|
70
206
|
|
71
207
|
|
72
208
|
|
@@ -90,105 +226,41 @@
|
|
90
226
|
|
91
227
|
|
92
228
|
|
93
|
-
t
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
#チャート
|
132
|
-
|
133
|
-
plt.plot(range(len(mydf1)),nikkei,label='N255')
|
134
|
-
|
135
|
-
plt.plot(range(short_day-1,len(mydf1)),rolling_s[short_day-1:],color='r',label='MA'+str(short_day))
|
136
|
-
|
137
|
-
plt.plot(range(long_day-1,len(mydf1)),rolling_l[long_day-1:],color='g',label='MA'+str(long_day))
|
138
|
-
|
139
|
-
plt.legend(loc='upper left')
|
140
|
-
|
141
|
-
plt.grid()
|
142
|
-
|
143
|
-
plt.xlim(len(mydf1)-250,len(mydf1)+1)#
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
crosses=mydf1[mydf1[col_name]!=0]
|
150
|
-
|
151
|
-
golden_x = []
|
152
|
-
|
153
|
-
golden_y = []
|
154
|
-
|
155
|
-
golden_day=[]
|
156
|
-
|
157
|
-
dead_x=[]
|
158
|
-
|
159
|
-
dead_y=[]
|
160
|
-
|
161
|
-
dead_day=[]
|
162
|
-
|
163
|
-
for i in range(len(crosses)):
|
164
|
-
|
165
|
-
if (crosses.iloc[i][col_name]==1):
|
166
|
-
|
167
|
-
golden_x.append(crosses.index[i])
|
168
|
-
|
169
|
-
golden_y.append(crosses.iloc[i]['FINISH'])#golden_y はリストを参照にする
|
170
|
-
|
171
|
-
golden_day.append(crosses.iloc[i]['DATE'])#
|
172
|
-
|
173
|
-
else:
|
174
|
-
|
175
|
-
dead_x.append(crosses.index[i])
|
176
|
-
|
177
|
-
dead_y.append(crosses.iloc[i]['FINISH'])#
|
178
|
-
|
179
|
-
dead_day.append(crosses.iloc[i]['DATE'])#
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
plt.scatter(golden_x,golden_y,c='black',s=80,marker='^')
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
plt.show()
|
188
|
-
|
189
|
-
```
|
190
|
-
|
191
|
-
---
|
229
|
+
plt.plot(range(len(mydf1)),nikkei,label='N255')
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
golden_x = [15]
|
234
|
+
|
235
|
+
golden_y = []
|
236
|
+
|
237
|
+
golden_y.append(mydf1.iloc[15][1])#golden_y はリストを参照にする
|
238
|
+
|
239
|
+
ns=map(lambda s:float(s),golden_y)##
|
240
|
+
|
241
|
+
#print(list(ns))
|
242
|
+
|
243
|
+
print('golden_x=',golden_x)
|
244
|
+
|
245
|
+
print('golden_y=',golden_y)
|
246
|
+
|
247
|
+
|
248
|
+
|
249
|
+
#チャート
|
250
|
+
|
251
|
+
plt.legend(loc='upper left')
|
252
|
+
|
253
|
+
plt.xlim(0,len(mydf1)+1)#修正
|
254
|
+
|
255
|
+
|
256
|
+
|
257
|
+
plt.scatter(golden_x,golden_y,c='black',marker='^')
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
plt.show()
|
262
|
+
|
263
|
+
|
192
264
|
|
193
265
|
> 引用テキスト
|
194
266
|
|
2
<code>を使用しました。CSVのデータを入れました
test
CHANGED
File without changes
|
test
CHANGED
@@ -42,7 +42,9 @@
|
|
42
42
|
|
43
43
|
|
44
44
|
|
45
|
-
|
45
|
+
```python
|
46
|
+
|
47
|
+
|
46
48
|
|
47
49
|
#移動平均GC DCを描く
|
48
50
|
|
@@ -74,6 +76,8 @@
|
|
74
76
|
|
75
77
|
|
76
78
|
|
79
|
+
#print(mydf.head())
|
80
|
+
|
77
81
|
N=len(mydf1)
|
78
82
|
|
79
83
|
print('N=',N)
|
@@ -96,6 +100,8 @@
|
|
96
100
|
|
97
101
|
rolling_l=nikkei.rolling(long_day).mean().fillna(0)
|
98
102
|
|
103
|
+
#print('MA=',rolling_s.tail())
|
104
|
+
|
99
105
|
|
100
106
|
|
101
107
|
#クロスを確認
|
@@ -110,7 +116,9 @@
|
|
110
116
|
|
111
117
|
|
112
118
|
|
119
|
+
#列追加
|
120
|
+
|
113
|
-
#
|
121
|
+
#0:クロスなし、1:GC、-1:DC
|
114
122
|
|
115
123
|
col_name = 'cross_' + str(short_day)+'_'+str(long_day)
|
116
124
|
|
@@ -170,10 +178,44 @@
|
|
170
178
|
|
171
179
|
dead_day.append(crosses.iloc[i]['DATE'])#
|
172
180
|
|
173
|
-
|
181
|
+
|
174
182
|
|
175
183
|
plt.scatter(golden_x,golden_y,c='black',s=80,marker='^')
|
176
184
|
|
177
|
-
|
185
|
+
|
178
186
|
|
179
187
|
plt.show()
|
188
|
+
|
189
|
+
```
|
190
|
+
|
191
|
+
---
|
192
|
+
|
193
|
+
> 引用テキスト
|
194
|
+
|
195
|
+
```CSV
|
196
|
+
|
197
|
+
コード
|
198
|
+
|
199
|
+
```DATE FINISH START HIGH LOW RATE GAP VOLUME
|
200
|
+
|
201
|
+
2020/7/21 22,884.22 22,789.38 22,925.58 22,780.22 0.73% 685.61M
|
202
|
+
|
203
|
+
2020/7/20 22,717.48 22,772.07 22,788.53 22,580.19 0.09% 500.42M
|
204
|
+
|
205
|
+
2020/7/16 22,770.36 22,907.96 22,925.90 22,739.42 -0.76% 186.5 894.44M
|
206
|
+
|
207
|
+
2020/7/15 22,945.50 22,817.91 22,965.56 22,800.11 1.59% 165.5 580.11M
|
208
|
+
|
209
|
+
2020/7/14 22,587.01 22,631.87 22,677.02 22,538.78 -0.87% 138.2 516.77M
|
210
|
+
|
211
|
+
2020/7/13 22,784.74 22,591.81 22,784.74 22,561.47 2.22% 223.3 735.69M
|
212
|
+
|
213
|
+
2020/7/10 22,290.81 22,534.97 22,563.68 22,285.07 -1.06% 278.6 673.60M
|
214
|
+
|
215
|
+
2020/7/9 22,529.29 22,442.30 22,679.08 22,434.38 0.40% 244.7 741.69M
|
216
|
+
|
217
|
+
2020/7/8 22,438.65 22,481.61 22,667.95 22,438.65 -0.78% 229.3 741.69M
|
218
|
+
|
219
|
+
2020/7/7 22,614.69 22,649.90 22,742.28 22,540.44 -0.44% 201.8 741.69M
|
220
|
+
|
221
|
+
2020/7/6 22,714.44 22,341.27 22,734.11 22,325.75 1.83% 408.4 580.11M
|
1
誤字の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -110,9 +110,7 @@
|
|
110
110
|
|
111
111
|
|
112
112
|
|
113
|
-
#列追加
|
114
|
-
|
115
|
-
#0:クロスなし、1:GC、-1:DC
|
113
|
+
#列追加 #0:クロスなし、1:GC、-1:DC
|
116
114
|
|
117
115
|
col_name = 'cross_' + str(short_day)+'_'+str(long_day)
|
118
116
|
|