@@ -109,23 +109,46 @@ def test_unequal_ohlc_length(self):
109
109
# check: PlotlyError if open, high, low, close are not the same length
110
110
# for TraceFactory.ohlc_increase and TraceFactory.ohlc_decrease
111
111
112
- kwargs = {'open' : [1 ], 'high' : [1 , 3 ], 'low' : [1 , 2 ], 'close' : [1 , 2 ]}
113
- self .assertRaises (PlotlyError , tls .TraceFactory .create_ohlc_increase ,
114
- ** kwargs )
115
-
116
- kwargs = {'open' : [1 , 2 ], 'high' : [1 , 2 , 3 ], 'low' : [1 , 2 ],
117
- 'close' : [1 , 2 ]}
118
- self .assertRaises (PlotlyError , tls .TraceFactory .create_ohlc_increase ,
119
- ** kwargs )
120
-
121
- kwargs = {'open' : [1 ], 'high' : [1 , 3 ], 'low' : [1 , 2 ], 'close' : [2 ]}
122
- self .assertRaises (PlotlyError , tls .TraceFactory .create_ohlc_decrease ,
123
- ** kwargs )
112
+ kwargs = {'open' : [1 ], 'high' : [1 , 3 ],
113
+ 'low' : [1 , 2 ], 'close' : [1 , 2 ],
114
+ 'direction' : ['increasing' ]}
115
+ self .assertRaises (PlotlyError , tls .TraceFactory .create_ohlc , ** kwargs )
116
+
117
+ kwargs = {'open' : [1 , 2 ], 'high' : [1 , 2 , 3 ],
118
+ 'low' : [1 , 2 ], 'close' : [1 , 2 ],
119
+ 'direction' : ['decreasing' ]}
120
+ self .assertRaises (PlotlyError , tls .TraceFactory .create_ohlc , ** kwargs )
121
+
122
+ kwargs = {'open' : [1 , 2 ], 'high' : [2 , 3 ],
123
+ 'low' : [0 ], 'close' : [1 , 3 ],
124
+ 'direction' : ['increasing' ]}
125
+ self .assertRaises (PlotlyError , tls .TraceFactory .create_ohlc , ** kwargs )
126
+
127
+ kwargs = {'open' : [1 , 2 ], 'high' : [2 , 3 ],
128
+ 'low' : [1 , 2 ], 'close' : [1 ],
129
+ 'direction' : ['decreasing' ]}
130
+ self .assertRaises (PlotlyError , tls .TraceFactory .create_ohlc , ** kwargs )
131
+
132
+ def test_direction_arg (self ):
133
+
134
+ # check: PlotlyError if direction is not defined as "increasing" or
135
+ # "decreasing"
136
+
137
+ kwargs = {'open' : [1 , 4 ], 'high' : [1 , 5 ],
138
+ 'low' : [1 , 2 ], 'close' : [1 , 2 ],
139
+ 'direction' : ['inc' ]}
140
+ self .assertRaisesRegexp (PlotlyError ,
141
+ "direction must be defined as "
142
+ "'increasing' or 'decreasing'" ,
143
+ tls .TraceFactory .create_ohlc , ** kwargs )
124
144
125
- kwargs = {'open' : [1 , 2 ], 'high' : [1 , 2 ],
126
- 'low' : [1 , 2 , .5 ], 'close' : [1 , 2 ]}
127
- self .assertRaises (PlotlyError , tls .TraceFactory .create_ohlc_decrease ,
128
- ** kwargs )
145
+ kwargs = {'open' : [1 , 2 ], 'high' : [1 , 3 ],
146
+ 'low' : [1 , 2 ], 'close' : [1 , 2 ],
147
+ 'direction' : ['d' ]}
148
+ self .assertRaisesRegexp (PlotlyError ,
149
+ "direction must be defined as "
150
+ "'increasing' or 'decreasing'" ,
151
+ tls .TraceFactory .create_ohlc , ** kwargs )
129
152
130
153
def test_high_highest_value (self ):
131
154
@@ -135,27 +158,15 @@ def test_high_highest_value(self):
135
158
136
159
# create_ohlc_increase
137
160
kwargs = {'open' : [2 , 3 ], 'high' : [4 , 2 ],
138
- 'low' : [1 , 1 ], 'close' : [1 , 2 ]}
161
+ 'low' : [1 , 1 ], 'close' : [1 , 2 ],
162
+ 'direction' : ['increasing' ]}
139
163
self .assertRaisesRegexp (PlotlyError , "Oops! Looks like some of "
140
164
"your high values are less "
141
165
"the corresponding open, "
142
166
"low, or close values. "
143
167
"Double check that your data "
144
168
"is entered in O-H-L-C order" ,
145
- tls .TraceFactory .create_ohlc_increase ,
146
- ** kwargs )
147
-
148
- # create_ohlc_decrease
149
- kwargs = {'open' : [2 , 3 ], 'high' : [4 , 3 ],
150
- 'low' : [1 , 1 ], 'close' : [1 , 6 ]}
151
- self .assertRaisesRegexp (PlotlyError ,
152
- "Oops! Looks like some of "
153
- "your high values are less "
154
- "the corresponding open, "
155
- "low, or close values. "
156
- "Double check that your data "
157
- "is entered in O-H-L-C order" ,
158
- tls .TraceFactory .create_ohlc_decrease ,
169
+ tls .TraceFactory .create_ohlc ,
159
170
** kwargs )
160
171
161
172
def test_low_lowest_value (self ):
@@ -167,38 +178,27 @@ def test_low_lowest_value(self):
167
178
168
179
# create_ohlc_increase
169
180
kwargs = {'open' : [2 , 3 ], 'high' : [4 , 6 ],
170
- 'low' : [3 , 1 ], 'close' : [1 , 2 ]}
171
- self .assertRaisesRegexp (PlotlyError ,
172
- "Oops! Looks like some of "
173
- "your low values are greater "
174
- "than the corresponding high"
175
- ", open, or close values. "
176
- "Double check that your data "
177
- "is entered in O-H-L-C order" ,
178
- tls .TraceFactory .create_ohlc_increase ,
179
- ** kwargs )
180
-
181
- # create_ohlc_decrease
182
- kwargs = {'open' : [2 , 3 ], 'high' : [4 , 6 ],
183
- 'low' : [1 , 5 ], 'close' : [1 , 6 ]}
181
+ 'low' : [3 , 1 ], 'close' : [1 , 2 ],
182
+ 'direction' : ['decreasing' ]}
184
183
self .assertRaisesRegexp (PlotlyError ,
185
184
"Oops! Looks like some of "
186
185
"your low values are greater "
187
186
"than the corresponding high"
188
187
", open, or close values. "
189
188
"Double check that your data "
190
189
"is entered in O-H-L-C order" ,
191
- tls .TraceFactory .create_ohlc_decrease ,
190
+ tls .TraceFactory .create_ohlc ,
192
191
** kwargs )
193
192
194
193
def test_one_ohlc_increase (self ):
195
194
196
195
# This should create one "increase" (i.e. close > open) ohlc stick
197
196
198
- ohlc_incr = tls .TraceFactory .create_ohlc_increase (open = [33.0 ],
199
- high = [33.2 ],
200
- low = [32.7 ],
201
- close = [33.1 ])
197
+ ohlc_incr = tls .TraceFactory .create_ohlc (open = [33.0 ],
198
+ high = [33.2 ],
199
+ low = [32.7 ],
200
+ close = [33.1 ],
201
+ direction = "increasing" )
202
202
203
203
expected_ohlc_incr = {
204
204
'mode' : 'lines' ,
@@ -215,11 +215,12 @@ def test_ohlc_increase_with_kwargs(self):
215
215
# This should create one "increase" (i.e. close > open) ohlc stick
216
216
# and change the name to "POSITIVE!!"
217
217
218
- ohlc_incr = tls .TraceFactory .create_ohlc_increase (open = [1.5 ],
219
- high = [30 ],
220
- low = [1 ],
221
- close = [25 ],
222
- name = "POSITIVE!!" )
218
+ ohlc_incr = tls .TraceFactory .create_ohlc (open = [1.5 ],
219
+ high = [30 ],
220
+ low = [1 ],
221
+ close = [25 ],
222
+ direction = "increasing" ,
223
+ name = "POSITIVE!!" )
223
224
224
225
expected_ohlc_incr = {
225
226
'text' : ('Open' , 'Open' , 'High' , 'Low' , 'Close' , 'Close' , '' ),
@@ -236,10 +237,11 @@ def test_one_ohlc_decrease(self):
236
237
237
238
# This should create one "decrease" (i.e. close < open) ohlc stick
238
239
239
- ohlc_decr = tls .TraceFactory .create_ohlc_decrease (open = [33.3 ],
240
- high = [33.3 ],
241
- low = [32.7 ],
242
- close = [32.9 ])
240
+ ohlc_decr = tls .TraceFactory .create_ohlc (open = [33.3 ],
241
+ high = [33.3 ],
242
+ low = [32.7 ],
243
+ close = [32.9 ],
244
+ direction = "decreasing" )
243
245
244
246
expected_ohlc_decr = {
245
247
'mode' : 'lines' ,
@@ -256,11 +258,12 @@ def test_ohlc_decrease_with_kwargs(self):
256
258
# This should create one "decrease" (i.e. close < open) ohlc stick
257
259
# and change the line width to 4
258
260
259
- ohlc_decr = tls .TraceFactory .create_ohlc_decrease (open = [15 ], high = [30 ],
260
- low = [1 ], close = [5 ],
261
- line = Line (
262
- color = 'rgb(214, 39, 40)' ,
263
- width = 4 ))
261
+ ohlc_decr = tls .TraceFactory .create_ohlc (open = [15 ], high = [30 ],
262
+ low = [1 ], close = [5 ],
263
+ direction = "decreasing" ,
264
+ line = Line (
265
+ color = 'rgb(214, 39, 40)' ,
266
+ width = 4 ))
264
267
265
268
expected_ohlc_decr = {
266
269
'text' : ('Open' , 'Open' , 'High' , 'Low' , 'Close' , 'Close' , '' ),
@@ -284,8 +287,10 @@ def test_ohlc_increase_and_decrease(self):
284
287
l = [3 , 2 , 7 , 3 , 2 , 2 , 1.1 , 2.3 ]
285
288
c = [3.3 , 6.3 , 10 , 9 , 9.2 , 3 , 2.9 , 6.1 ]
286
289
287
- ohlc_incr = tls .TraceFactory .create_ohlc_increase (o , h , l , c )
288
- ohlc_decr = tls .TraceFactory .create_ohlc_decrease (o , h , l , c )
290
+ ohlc_incr = tls .TraceFactory .create_ohlc (o , h , l , c ,
291
+ direction = 'increasing' )
292
+ ohlc_decr = tls .TraceFactory .create_ohlc (o , h , l , c ,
293
+ direction = 'decreasing' )
289
294
ohlc_data = Data ([ohlc_incr , ohlc_decr ])
290
295
291
296
expected_ohlc_data = [{
0 commit comments