@@ -163,35 +163,74 @@ def test_fill_between06(bolldata):
163
163
signal = macd .ewm (span = 9 , adjust = False ).mean ()
164
164
histogram = macd - signal
165
165
166
- fb_12up = dict (y1 = exp12 .values ,y2 = exp26 .values ,where = exp12 > exp26 ,color = "#93c47d" ,alpha = 0.6 ,interpolate = True )
167
- fb_12dn = dict (y1 = exp12 .values ,y2 = exp26 .values ,where = exp12 < exp26 ,color = "#e06666" ,alpha = 0.6 ,interpolate = True )
166
+ fb_12up = dict (y1 = exp12 .values ,y2 = exp26 .values ,where = ( exp12 > exp26 ). values ,color = "#93c47d" ,alpha = 0.6 ,interpolate = True )
167
+ fb_12dn = dict (y1 = exp12 .values ,y2 = exp26 .values ,where = ( exp12 < exp26 ). values ,color = "#e06666" ,alpha = 0.6 ,interpolate = True )
168
168
fb_exp12 = [fb_12up ,fb_12dn ]
169
169
170
- fb_macd_up = dict (y1 = macd .values ,y2 = signal .values ,where = signal < macd ,color = "#93c47d" ,alpha = 0.6 ,interpolate = True )
171
- fb_macd_dn = dict (y1 = macd .values ,y2 = signal .values ,where = signal > macd ,color = "#e06666" ,alpha = 0.6 ,interpolate = True )
172
- #fb_macd_up['panel'] = 1
173
- #fb_macd_dn['panel'] = 1
170
+ fb_macd_up = dict (y1 = macd .values ,y2 = signal .values ,where = (signal < macd ).values ,color = "#93c47d" ,alpha = 0.6 ,interpolate = True )
171
+ fb_macd_dn = dict (y1 = macd .values ,y2 = signal .values ,where = (signal > macd ).values ,color = "#e06666" ,alpha = 0.6 ,interpolate = True )
174
172
175
173
fb_macd = [fb_macd_up ,fb_macd_dn ]
176
174
177
- apds = [mpf .make_addplot (exp12 ,color = 'lime' ),
178
- mpf .make_addplot (exp26 ,color = 'c' ),
179
- mpf .make_addplot (histogram ,type = 'bar' ,width = 0.7 ,panel = 1 ,
180
- color = 'dimgray' ,alpha = 0.65 ,secondary_y = True ),
181
- mpf .make_addplot (macd ,panel = 1 ,color = 'fuchsia' ,secondary_y = False ),
182
- mpf .make_addplot (signal ,panel = 1 ,color = 'b' ,secondary_y = False ,fill_between = fb_macd ),
183
- ]
175
+ s = mpf .make_mpf_style (base_mpf_style = 'blueskies' ,facecolor = 'aliceblue' )
176
+
177
+ import pprint
178
+ pp = pprint .PrettyPrinter (indent = 4 )
179
+
180
+ for tag in ['a' ,'b' ,'c' ]:
181
+ apds = [mpf .make_addplot (exp12 ,color = 'lime' ),
182
+ mpf .make_addplot (exp26 ,color = 'c' ),
183
+ mpf .make_addplot (histogram ,type = 'bar' ,width = 0.7 ,panel = 1 ,
184
+ color = 'dimgray' ,alpha = 0.65 ,secondary_y = True ),
185
+ mpf .make_addplot (macd ,panel = 1 ,color = 'fuchsia' ,secondary_y = False ),
186
+ mpf .make_addplot (signal ,panel = 1 ,color = 'b' ,secondary_y = False )
187
+ ]
188
+
189
+ new_tname = tname [0 :- 4 ]+ tag + tname [- 4 :]
190
+ if tag == 'a' :
191
+ print ('fb_exp12' )
192
+ pp .pprint (fb_exp12 )
193
+ print ('fb_macd' )
194
+ pp .pprint (fb_macd )
195
+ apds [ 0 ] = mpf .make_addplot (exp12 ,color = 'lime' ,fill_between = fb_exp12 )
196
+ apds [- 1 ] = mpf .make_addplot (signal ,panel = 1 ,color = 'b' ,secondary_y = False ,fill_between = fb_macd )
197
+ mpf .plot (df ,type = 'candle' ,addplot = apds ,figscale = 0.8 ,figratio = (1 ,1 ),title = '\n \n MACD' ,
198
+ style = s ,volume = True ,volume_panel = 2 ,panel_ratios = (3 ,4 ,1 ),tight_layout = True ,
199
+ savefig = new_tname )
200
+ elif tag == 'b' :
201
+ print ('fb_exp12' )
202
+ pp .pprint (fb_exp12 )
203
+ print ('fb_macd' )
204
+ pp .pprint (fb_macd )
205
+ apds [ 0 ] = mpf .make_addplot (exp12 ,color = 'lime' )
206
+ apds [- 1 ] = mpf .make_addplot (signal ,panel = 1 ,color = 'b' ,secondary_y = False ,fill_between = fb_macd )
207
+ mpf .plot (df ,type = 'candle' ,addplot = apds ,figscale = 0.8 ,figratio = (1 ,1 ),title = '\n \n MACD' ,
208
+ style = s ,volume = True ,volume_panel = 2 ,panel_ratios = (3 ,4 ,1 ),tight_layout = True ,
209
+ fill_between = fb_exp12 ,
210
+ savefig = new_tname )
211
+ elif tag == 'c' :
212
+ apds [ 0 ] = mpf .make_addplot (exp12 ,color = 'lime' )
213
+ apds [- 1 ] = mpf .make_addplot (signal ,panel = 1 ,color = 'b' ,secondary_y = False )
214
+ fb_macd [0 ]['panel' ] = 1
215
+ fb_macd [1 ]['panel' ] = 1
216
+ print ('fb_exp12' )
217
+ pp .pprint (fb_exp12 )
218
+ print ('fb_macd' )
219
+ pp .pprint (fb_macd )
220
+ print ('fb_macd+fb_exp12' )
221
+ pp .pprint (fb_macd + fb_exp12 )
222
+ mpf .plot (df ,type = 'candle' ,addplot = apds ,figscale = 0.8 ,figratio = (1 ,1 ),title = '\n \n MACD' ,
223
+ style = s ,volume = True ,volume_panel = 2 ,panel_ratios = (3 ,4 ,1 ),tight_layout = True ,
224
+ fill_between = fb_macd + fb_exp12 ,
225
+ savefig = new_tname )
226
+ else :
227
+ print ('Should NEVER get to here!' )
228
+ raise ValueError ('Should NEVER get to here!' )
184
229
185
- s = mpf .make_mpf_style (base_mpf_style = 'blueskies' ,facecolor = 'aliceblue' )#,rc={'figure.facecolor':'lightcyan'})
186
-
187
- mpf .plot (df ,type = 'candle' ,addplot = apds ,figscale = 1.6 ,figratio = (1 ,1 ),title = '\n \n MACD' ,
188
- style = s ,volume = True ,volume_panel = 2 ,panel_ratios = (3 ,4 ,1 ),tight_layout = True ,
189
- fill_between = fb_exp12 ,
190
- savefig = tname )
191
-
192
- _report_file_sizes (tname ,rname )
230
+ _report_file_sizes (new_tname ,rname )
231
+
232
+ result = compare_images (rname ,new_tname ,tol = IMGCOMP_TOLERANCE )
233
+ if result is not None :
234
+ print ('result=' ,result )
235
+ assert result is None
193
236
194
- result = compare_images (rname ,tname ,tol = IMGCOMP_TOLERANCE )
195
- if result is not None :
196
- print ('result=' ,result )
197
- assert result is None
0 commit comments