Generates a Technical Study Chart

	Parameters:
	-----------
			study : string
				Technical Study to be charted
					sma - 'Simple Moving Average'
					rsi - 'R Strength Indicator'
			periods : int
				Number of periods
			column : string
				Name of the column on which the
				study will be done
			include : bool
				Indicates if the input column(s)
				should be included in the chart
			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}'
			detail : bool
				If True the supporting data/calculations
				are included in the chart 
			study_colors : string or [string]
				Colors to be used for the studies

		Study Specific Parameters
		-------------------------
		RSI 
			rsi_upper : int (0,100]
				Level for the upper rsi band
				default : 70
			rsi_lower : int (0,100]
				Level for the lower rsi band
				default : 30
		CCI 
			cci_upper : int 
				Level for the upper cci band
				default : 100
			cci_lower : int 
				Level for the lower cci band
				default : -100
		BOLL
			boll_std : int or float
				Number of standard deviations
		MACD
			fast_period : int
				Number of periods for the fast moving average
			slow_period : int
				Number of periods for the slow moving average
			signal_period : int
				Number of periods for the signal 
		CORREL
			how : string
				Method for the correlation calculation
					values
					pct_cht
					diff

def _ta_plot(self,study,periods=14,column=None,include=True,str='{name}({period})',detail=False,
			 theme=None,sharing=None,filename='',asFigure=False,**iplot_kwargs):
	"""
	Generates a Technical Study Chart

	Parameters:
	-----------
			study : string
				Technical Study to be charted
					sma - 'Simple Moving Average'
					rsi - 'R Strength Indicator'
			periods : int
				Number of periods
			column : string
				Name of the column on which the
				study will be done
			include : bool
				Indicates if the input column(s)
				should be included in the chart
			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}'
			detail : bool
				If True the supporting data/calculations
				are included in the chart 
			study_colors : string or [string]
				Colors to be used for the studies

		Study Specific Parameters
		-------------------------
		RSI 
			rsi_upper : int (0,100]
				Level for the upper rsi band
				default : 70
			rsi_lower : int (0,100]
				Level for the lower rsi band
				default : 30
		CCI 
			cci_upper : int 
				Level for the upper cci band
				default : 100
			cci_lower : int 
				Level for the lower cci band
				default : -100
		BOLL
			boll_std : int or float
				Number of standard deviations
		MACD
			fast_period : int
				Number of periods for the fast moving average
			slow_period : int
				Number of periods for the slow moving average
			signal_period : int
				Number of periods for the signal 
		CORREL
			how : string
				Method for the correlation calculation
					values
					pct_cht
					diff
					
	"""

	if 'columns' in iplot_kwargs:
		column=iplot_kwargs.pop('columns')
		
	if 'period' in iplot_kwargs:
		periods=iplot_kwargs.pop('period')
		
	if 'world_readable' in iplot_kwargs:
		sharing=iplot_kwargs.pop('world_readable')

	if 'study_color' in iplot_kwargs:
		iplot_kwargs['study_colors']=iplot_kwargs.pop('study_color')
		
	if sharing is None:
			sharing = auth.get_config_file()['sharing']
	if isinstance(sharing,bool):
			if sharing:
				sharing='public'
			else:
				sharing='private'
	iplot_kwargs['sharing']=sharing
	if theme is None:
		theme = iplot_kwargs.pop('study_theme',auth.get_config_file()['theme'])

	if not filename:
		if 'title' in iplot_kwargs:
			filename=iplot_kwargs['title']
		else:
			filename='Plotly Playground {0}'.format(time.strftime("%Y-%m-%d %H:%M:%S"))

	def get_subplots(figures):
		shape=(len(figures),1)
		layout=tools.get_base_layout(figures)
		subplots=tools.subplots(figures,shape=shape,shared_xaxes=True,base_layout=layout)
		if len(figures)==2:
			subplots['layout']['yaxis']['domain']=[.27,1.0]
			subplots['layout']['yaxis2']['domain']=[0,.25]
		return subplots

	def get_study(df,func,iplot_kwargs,iplot_study_kwargs,str=None,include=False,column=None,inset=False):
		df=df.copy()
		if inset:
			if not column:
				if isinstance(df,pd.DataFrame):
					column=df.keys().tolist()
				else:
					df=pd.DataFrame(df)
					column=df.keys().tolist()
		if 'legend' in iplot_kwargs:
			iplot_study_kwargs['legend']=iplot_kwargs['legend']
		fig_0=df.figure(**iplot_kwargs)
		df_ta=func(df,column=column,include=False,str=str,**study_kwargs)	
		kind=iplot_kwargs['kind'] if 'kind' in iplot_kwargs else ''
		iplot_study_kwargs['kind']='scatter'
		iplot_study_kwargs['colors']=iplot_study_kwargs.get('colors',['blue','green','red'] if study=='dmi' else 'blue')
		fig_1=df_ta.figure(theme=theme,**iplot_study_kwargs)
		if kind in ['candle','ohlc']:
				for i in fig_1['data']:
					i['x']=[pd.Timestamp(_) for _ in i['x']]
		if inset:
			figure=tools.merge_figures([fig_0,fig_1]) if include else fig_1
		else:
			figure=get_subplots([fig_0,fig_1]) if include else fig_1
		return figure

	study_kwargs={}  
	iplot_study_kwargs={}

	study_kwargs=check_kwargs(iplot_kwargs,__TA_KWARGS,{},clean_origin=True)
	iplot_study_kwargs=kwargs_from_keyword(iplot_kwargs,{},'study')

	study_kwargs.update({'periods':periods})

	ta_func = eval('ta.{0}'.format(study))

	inset=study in ('sma','boll','ema','atr','ptps')
	figure=get_study(self,ta_func,iplot_kwargs,iplot_study_kwargs,include=include,
					 column=column,str=str,inset=inset)

	## Add Bands
	if study in ('rsi','cci'):
		bands= {'rsi':(30,70),
				'cci':(-100,100)}
		_upper=study_kwargs.get('{0}_upper'.format(study),bands[study][0])
		_lower=study_kwargs.get('{0}_lower'.format(study),bands[study][1])
		yref='y2' if include else 'y1'
		shapes=[tools.get_shape(y=i,yref=yref,color=j,dash='dash') for (i,j) in [(_lower,'green'),(_upper,'red')]]
		figure['layout']['shapes']=shapes

	# if study=='rsi':
	# 	rsi_upper=study_kwargs.get('rsi_upper',70)
	# 	rsi_lower=study_kwargs.get('rsi_lower',30)
	# 	yref='y2' if include else 'y1'
	# 	shapes=[tools.get_shape(y=i,yref=yref,color=j,dash='dash') for (i,j) in [(rsi_lower,'green'),(rsi_upper,'red')]]
	# 	figure['layout']['shapes']=shapes
	
	# if study=='cci':
	# 	cci_upper=study_kwargs.get('cci_upper',100)
	# 	cci_lower=study_kwargs.get('cci_lower',-100)
	# 	yref='y2' if include else 'y1'
	# 	shapes=[tools.get_shape(y=i,yref=yref,color=j,dash='dash') for (i,j) in [(cci_lower,'green'),(cci_upper,'red')]]
	# 	figure['layout']['shapes']=shapes

	## Exports

	if asFigure:
		return figure
	else: 
		return iplot(figure,sharing=sharing,filename=filename)