cufflinks.quant_figure module

QuantFigure allows you to create a persistent object. Annotations and Technical Studies can be added on demand.

It accepts any dataframe with a timeseries index.

Try it out:
qf=cf.QuantFig(cf.datagen.ohlc()) qf.iplot()
class cufflinks.quant_figure.QuantFig(df, kind='candlestick', columns=None, **kwargs)[source]

Bases: object

add_adx(periods=14, str=None, name='', **kwargs)[source]

Add Average Directional Index (ADX) study to QuantFigure.studies

Parameters:
periods : int or list(int)
Number of periods
name : string
Name given to the study
str : string

Label factory for studies The following wildcards can be used:

{name} : Name of the column {study} : Name of the study {period} : Period used
Examples:
‘study: {study} - period: {period}’
kwargs:
legendgroup : bool
If true, all legend items are grouped into a single one

All formatting values available on iplot()

add_annotations(annotations, **kwargs)[source]

Add an annotation to the QuantFigure.

Parameters:
annotations : dict or list(dict,)
Annotations can be on the form form of
{‘date’ : ‘text’} and the text will automatically be placed at the right level on the chart
or
A Plotly fully defined annotation
kwargs :
fontcolor : str
Text color for annotations
fontsize : int
Text size for annotations
textangle : int
Textt angle

See https://plot.ly/python/reference/#layout-annotations for a complete list of valid parameters.

add_atr(periods=14, str=None, name='', **kwargs)[source]

Add Average True Range (ATR) study to QuantFigure.studies

Parameters:
periods : int or list(int)
Number of periods
name : string
Name given to the study
str : string

Label factory for studies The following wildcards can be used:

{name} : Name of the column {study} : Name of the study {period} : Period used
Examples:
‘study: {study} - period: {period}’
kwargs:
legendgroup : bool
If true, all legend items are grouped into a single one

All formatting values available on iplot()

add_bollinger_bands(periods=20, boll_std=2, fill=True, column=None, name='', str='{name}({column}, {period})', **kwargs)[source]

Add Bollinger Bands (BOLL) study to QuantFigure.studies

Parameters:
periods : int or list(int)
Number of periods
boll_std : int
Number of standard deviations for the bollinger upper and lower bands
fill : boolean
If True, then the innner area of the bands will filled
column :string
Defines the data column name that contains the data over which the study will be applied. Default: ‘close’
name : string
Name given to the study
str : string

Label factory for studies The following wildcards can be used:

{name} : Name of the column {study} : Name of the study {period} : Period used
Examples:
‘study: {study} - period: {period}’
kwargs:
legendgroup : bool
If true, all legend items are grouped into a single one
fillcolor : string

Color to be used for the fill color. Example:

‘rgba(62, 111, 176, .4)’

All formatting values available on iplot()

add_cci(periods=14, cci_upper=100, cci_lower=-100, showbands=True, str=None, name='', **kwargs)[source]

Commodity Channel Indicator study to QuantFigure.studies

Parameters:
periods : int or list(int)
Number of periods
cci_upper : int
Upper bands level default : 100
cci_lower : int
Lower band level default : -100
showbands : boolean
If True, then the cci_upper and cci_lower levels are displayed
name : string
Name given to the study
str : string

Label factory for studies The following wildcards can be used:

{name} : Name of the column {study} : Name of the study {period} : Period used
Examples:
‘study: {study} - period: {period}’
kwargs:
legendgroup : bool
If true, all legend items are grouped into a single one

All formatting values available on iplot()

add_dmi(periods=14, str='{name}({period})', name='', **kwargs)[source]

Add Directional Movement Index (DMI) study to QuantFigure.studies

Parameters:
periods : int or list(int)
Number of periods
name : string
Name given to the study
str : string

Label factory for studies The following wildcards can be used:

{name} : Name of the column {study} : Name of the study {period} : Period used
Examples:
‘study: {study} - period: {period}’
kwargs:
legendgroup : bool
If true, all legend items are grouped into a single one

All formatting values available on iplot()

add_ema(periods=20, column=None, str=None, name='', **kwargs)[source]

Add Exponential Moving Average (EMA) study to QuantFigure.studies

Parameters:
periods : int or list(int)
Number of periods
column :string
Defines the data column name that contains the data over which the study will be applied. Default: ‘close’
name : string
Name given to the study
str : string

Label factory for studies The following wildcards can be used:

{name} : Name of the column {study} : Name of the study {period} : Period used
Examples:
‘study: {study} - period: {period}’
kwargs:
legendgroup : bool
If true, all legend items are grouped into a single one

All formatting values available on iplot()

add_macd(fast_period=12, slow_period=26, signal_period=9, column=None, name='', str=None, **kwargs)[source]

Add Moving Average Convergence Divergence (MACD) study to QuantFigure.studies

Parameters:
fast_period : int
MACD Fast Period
slow_period : int
MACD Slow Period
signal_period : int
MACD Signal Period
column :string
Defines the data column name that contains the data over which the study will be applied. Default: ‘close’
name : string
Name given to the study
str : string

Label factory for studies The following wildcards can be used:

{name} : Name of the column {study} : Name of the study {period} : Period used
Examples:
‘study: {study} - period: {period}’
kwargs:
legendgroup : bool
If true, all legend items are grouped into a single one

All formatting values available on iplot()

add_ptps(periods=14, af=0.2, initial='long', str=None, name='', **kwargs)[source]

Add Parabolic SAR (PTPS) study to QuantFigure.studies

Parameters:
periods : int or list(int)
Number of periods
af : float
acceleration factor
initial : ‘long’ or ‘short’
Iniital position default: long
name : string
Name given to the study
str : string

Label factory for studies The following wildcards can be used:

{name} : Name of the column {study} : Name of the study {period} : Period used
Examples:
‘study: {study} - period: {period}’
kwargs:
legendgroup : bool
If true, all legend items are grouped into a single one

All formatting values available on iplot()

add_resistance(date, on='high', mode='starttoend', text=None, **kwargs)[source]

Adds a resistance line to the QuantFigure

Parameters:
date0 : string
The resistance line will be drawn at the ‘y’ level value that corresponds to this date.
on : string

Indicate the data series in which the resistance should be based.

‘close’ ‘high’ ‘low’ ‘open’
mode : string

Defines how the support/resistance will be drawn

‘starttoened’ : (x0,x1) ‘fromstart’ : (x0,date) ‘toend’ : (date,x1)
text : string
If passed, then an annotation will be added to the resistance (at mid point)
kwargs:
from_strfmt : string
Defines the date formating in which date0 and date1 are stated. default: ‘%d%b%y’
to_strfmt : string
Defines the date formatting to which it should be converted. This should match the same format as the timeseries index. default : ‘%Y-%m-%d’
add_rsi(periods=20, rsi_upper=70, rsi_lower=30, showbands=True, column=None, name='', str=None, **kwargs)[source]

Add Relative Strength Indicator (RSI) study to QuantFigure.studies

Parameters:
periods : int or list(int)
Number of periods
rsi_upper : int
bounds [0,100] Upper (overbought) level
rsi_lower : int
bounds [0,100] Lower (oversold) level
showbands : boolean
If True, then the rsi_upper and rsi_lower levels are displayed
column :string
Defines the data column name that contains the data over which the study will be applied. Default: ‘close’
name : string
Name given to the study
str : string

Label factory for studies The following wildcards can be used:

{name} : Name of the column {study} : Name of the study {period} : Period used
Examples:
‘study: {study} - period: {period}’
kwargs:
legendgroup : bool
If true, all legend items are grouped into a single one

All formatting values available on iplot()

add_shapes(**kwargs)[source]

Add a shape to the QuantFigure.

kwargs :
hline : int, list or dict
Draws a horizontal line at the indicated y position(s) Extra parameters can be passed in the form of a dictionary (see shapes)
vline : int, list or dict
Draws a vertical line at the indicated x position(s) Extra parameters can be passed in the form of a dictionary (see shapes)
hspan : (y0,y1)
Draws a horizontal rectangle at the indicated (y0,y1) positions. Extra parameters can be passed in the form of a dictionary (see shapes)
vspan : (x0,x1)
Draws a vertical rectangle at the indicated (x0,x1) positions. Extra parameters can be passed in the form of a dictionary (see shapes)
shapes : dict or list(dict)
List of dictionaries with the specifications of a given shape. See help(cufflinks.tools.get_shape) for more information
add_sma(periods=20, column=None, name='', str=None, **kwargs)[source]

Add Simple Moving Average (SMA) study to QuantFigure.studies

Parameters:
periods : int or list(int)
Number of periods
column :string
Defines the data column name that contains the data over which the study will be applied. Default: ‘close’
name : string
Name given to the study
str : string

Label factory for studies The following wildcards can be used:

{name} : Name of the column {study} : Name of the study {period} : Period used
Examples:
‘study: {study} - period: {period}’
kwargs:
legendgroup : bool
If true, all legend items are grouped into a single one

All formatting values available on iplot()

add_support(date, on='low', mode='starttoend', text=None, **kwargs)[source]

Adds a support line to the QuantFigure

Parameters:
date0 : string
The support line will be drawn at the ‘y’ level value that corresponds to this date.
on : string

Indicate the data series in which the support line should be based.

‘close’ ‘high’ ‘low’ ‘open’
mode : string

Defines how the support/resistance will be drawn

‘starttoened’ : (x0,x1) ‘fromstart’ : (x0,date) ‘toend’ : (date,x1)
text : string
If passed, then an annotation will be added to the support line (at mid point)
kwargs:
from_strfmt : string
Defines the date formating in which date0 and date1 are stated. default: ‘%d%b%y’
to_strfmt : string
Defines the date formatting to which it should be converted. This should match the same format as the timeseries index. default : ‘%Y-%m-%d’
add_trendline(date0, date1, on='close', text=None, **kwargs)[source]

Adds a trendline to the QuantFigure. Given 2 dates, the trendline is connected on the data points that correspond to those dates.

Parameters:
date0 : string
Trendline starting date
date1 : string
Trendline end date
on : string

Indicate the data series in which the trendline should be based.

‘close’ ‘high’ ‘low’ ‘open’
text : string
If passed, then an annotation will be added to the trendline (at mid point)
kwargs:
from_strfmt : string
Defines the date formating in which date0 and date1 are stated. default: ‘%d%b%y’
to_strfmt : string
Defines the date formatting to which it should be converted. This should match the same format as the timeseries index. default : ‘%Y-%m-%d’
add_volume(colorchange=True, column=None, name='', str='{name}', **kwargs)[source]

Add ‘volume’ study to QuantFigure.studies

Parameters:
colorchange : bool
If true then each volume bar will have a fill color depending on if ‘base’ had a positive or negative change compared to the previous value
column :string
Defines the data column name that contains the volume data. Default: ‘volume’
name : string
Name given to the study
str : string

Label factory for studies The following wildcards can be used:

{name} : Name of the column {study} : Name of the study {period} : Period used
Examples:
‘study: {study} - period: {period}’
kwargs :
base : string
Defines the column which will define the positive/negative changes (if colorchange=True). Default = ‘close’
up_color : string
Color for positive bars
down_color : string
Color for negative bars
delete(*args)[source]

Deletes the values for a QuantFigure The key-values are automatically deleted from the correct section of the QuantFigure

figure(**kwargs)[source]

Returns a Plotly figure

iplot(**kwargs)[source]
update(**kwargs)[source]

Updates the values for a QuantFigure The key-values are automatically assigned to the correct section of the QuantFigure

cufflinks.quant_figure.get_annotation_kwargs()[source]
cufflinks.quant_figure.get_layout_kwargs()[source]
cufflinks.quant_figure.get_shapes_kwargs()[source]