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

Function create_ohlc

plotly/figure_factory/_ohlc.py:133–187  ·  view source on GitHub ↗

**deprecated**, use instead the plotly.graph_objects trace :class:`plotly.graph_objects.Ohlc` :param (list) open: opening values :param (list) high: high values :param (list) low: low values :param (list) close: closing :param (list) dates: list of datetime objects. Def

(open, high, low, close, dates=None, direction="both", **kwargs)

Source from the content-addressed store, hash-verified

131
132
133def create_ohlc(open, high, low, close, dates=None, direction="both", **kwargs):
134 """
135 **deprecated**, use instead the plotly.graph_objects trace
136 :class:`plotly.graph_objects.Ohlc`
137
138 :param (list) open: opening values
139 :param (list) high: high values
140 :param (list) low: low values
141 :param (list) close: closing
142 :param (list) dates: list of datetime objects. Default: None
143 :param (string) direction: direction can be 'increasing', 'decreasing',
144 or 'both'. When the direction is 'increasing', the returned figure
145 consists of all units where the close value is greater than the
146 corresponding open value, and when the direction is 'decreasing',
147 the returned figure consists of all units where the close value is
148 less than or equal to the corresponding open value. When the
149 direction is 'both', both increasing and decreasing units are
150 returned. Default: 'both'
151 :param kwargs: kwargs passed through plotly.graph_objs.Scatter.
152 These kwargs describe other attributes about the ohlc Scatter trace
153 such as the color or the legend name. For more information on valid
154 kwargs call help(plotly.graph_objs.Scatter)
155
156 :rtype (dict): returns a representation of an ohlc chart figure.
157
158 Example 1: Simple OHLC chart from a Pandas DataFrame
159
160 >>> from plotly.figure_factory import create_ohlc
161 >>> from datetime import datetime
162
163 >>> import pandas as pd
164 >>> df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/finance-charts-apple.csv')
165 >>> fig = create_ohlc(df['AAPL.Open'], df['AAPL.High'], df['AAPL.Low'], df['AAPL.Close'], dates=df.index)
166 >>> fig.show()
167 """
168 if dates is not None:
169 utils.validate_equal_length(open, high, low, close, dates)
170 else:
171 utils.validate_equal_length(open, high, low, close)
172 validate_ohlc(open, high, low, close, direction, **kwargs)
173
174 if direction == "increasing":
175 ohlc_incr = make_increasing_ohlc(open, high, low, close, dates, **kwargs)
176 data = [ohlc_incr]
177 elif direction == "decreasing":
178 ohlc_decr = make_decreasing_ohlc(open, high, low, close, dates, **kwargs)
179 data = [ohlc_decr]
180 else:
181 ohlc_incr = make_increasing_ohlc(open, high, low, close, dates, **kwargs)
182 ohlc_decr = make_decreasing_ohlc(open, high, low, close, dates, **kwargs)
183 data = [ohlc_incr, ohlc_decr]
184
185 layout = graph_objs.Layout(xaxis=dict(zeroline=False), hovermode="closest")
186
187 return graph_objs.Figure(data=data, layout=layout)
188
189
190class _OHLC(object):

Callers 1

create_ohlcMethod · 0.90

Calls 3

validate_ohlcFunction · 0.85
make_increasing_ohlcFunction · 0.85
make_decreasing_ohlcFunction · 0.85

Tested by

no test coverage detected