MCPcopy Create free account
hub / github.com/plotly/plotly.py / validate_ohlc

Function validate_ohlc

plotly/figure_factory/_ohlc.py:11–55  ·  view source on GitHub ↗

ohlc and candlestick specific validations Specifically, this checks that the high value is the greatest value and the low value is the lowest value in each unit. See FigureFactory.create_ohlc() or FigureFactory.create_candlestick() for params :raises: (PlotlyError) If the

(open, high, low, close, direction, **kwargs)

Source from the content-addressed store, hash-verified

9
10
11def validate_ohlc(open, high, low, close, direction, **kwargs):
12 """
13 ohlc and candlestick specific validations
14
15 Specifically, this checks that the high value is the greatest value and
16 the low value is the lowest value in each unit.
17
18 See FigureFactory.create_ohlc() or FigureFactory.create_candlestick()
19 for params
20
21 :raises: (PlotlyError) If the high value is not the greatest value in
22 each unit.
23 :raises: (PlotlyError) If the low value is not the lowest value in each
24 unit.
25 :raises: (PlotlyError) If direction is not 'increasing' or 'decreasing'
26 """
27 for lst in [open, low, close]:
28 for index in range(len(high)):
29 if high[index] < lst[index]:
30 raise exceptions.PlotlyError(
31 "Oops! Looks like some of "
32 "your high values are less "
33 "the corresponding open, "
34 "low, or close values. "
35 "Double check that your data "
36 "is entered in O-H-L-C order"
37 )
38
39 for lst in [open, high, close]:
40 for index in range(len(low)):
41 if low[index] > lst[index]:
42 raise exceptions.PlotlyError(
43 "Oops! Looks like some of "
44 "your low values are greater "
45 "than the corresponding high"
46 ", open, or close values. "
47 "Double check that your data "
48 "is entered in O-H-L-C order"
49 )
50
51 direction_opts = ("increasing", "decreasing", "both")
52 if direction not in direction_opts:
53 raise exceptions.PlotlyError(
54 "direction must be defined as 'increasing', 'decreasing', or 'both'"
55 )
56
57
58def make_increasing_ohlc(open, high, low, close, dates, **kwargs):

Callers 2

create_candlestickFunction · 0.90
create_ohlcFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected