Getting error while implementing Stochastic Oscillator in ta-lib

288 views
Skip to first unread message

Shakti D

unread,
Nov 29, 2012, 6:06:26 PM11/29/12
to talib...@googlegroups.com
Hi All
I am trying to extend Antonio's example code to include  Stochastic Oscillator using ta-lib

Original Code :

Following line after Line # 26 
analysis['rsi'] = ta.RSI(spy.Close, RSI_PERIOD)
 is giving me runtime error 

analysis['STOCH'] = ta.STOCH(spy.High, spy.Low, spy.Close)

Traceback (most recent call last):
  File "C:\Android\workspace\talibpython\src\org\example\talib\simplesmaexample.py", line 30, in <module>
    analysis['STOCH'] = ta.STOCH(spy.High, spy.Low, spy.Close)
  File "C:\Python27\lib\site-packages\pandas\core\frame.py", line 1550, in __setitem__
    self._set_item(key, value)
  File "C:\Python27\lib\site-packages\pandas\core\frame.py", line 1589, in _set_item
    value = self._sanitize_column(key, value)
  File "C:\Python27\lib\site-packages\pandas\core\frame.py", line 1618, in _sanitize_column
    assert(len(value) == len(self.index))
AssertionError


Any pointers guys ?

Peter Cawthron

unread,
Nov 29, 2012, 6:56:58 PM11/29/12
to talib...@googlegroups.com
Have you fixed it? It's the shape of the data returned by ta.STOCH i.e.

shape(np.reshape(ta.STOCH(spy.High, spy.Low, spy.Close), (len(spy.Close),2)))
Out[99]: (732L, 2L)


P.

Peter Cawthron

unread,
Nov 29, 2012, 7:03:37 PM11/29/12
to talib...@googlegroups.com
Sorry,posted slightly the wrong thing - I was playing in IPython.

shape(ta.STOCH(spy.High, spy.Low, spy.Close))
Out[103]: (2L, 732L)

P.

On Thursday, 29 November 2012 23:06:26 UTC, Shakti D wrote:

Peter Cawthron

unread,
Nov 29, 2012, 7:11:25 PM11/29/12
to talib...@googlegroups.com
No idea how to check in the code. Sorry:

analysis['STOCH1'] = ta.STOCH(spy.High, spy.Low, spy.Close)[0]

analysis['STOCH2'] = ta.STOCH(spy.High, spy.Low, spy.Close)[1]


See: http://www.quanttools.com/HTMLHelp/html/CT.14462.htm


P.


On Thursday, 29 November 2012 23:06:26 UTC, Shakti D wrote:

Shakti D

unread,
Nov 30, 2012, 8:20:57 AM11/30/12
to Peter Cawthron, talib...@googlegroups.com
Thanks Peter ! It worked . 
I have added your id
 pcawthron 
 as a Collaborators, so now you can commit to this project

If anyone else is interested to collaborate , please mail me your github ids 

Cheers,
Shakti



--
 
 

Peter Cawthron

unread,
Nov 30, 2012, 8:30:51 AM11/30/12
to talib...@googlegroups.com, Peter Cawthron
Much better solution from Antonio:

That's right Peter. The talib STOCH function return 2 values, one for the %K, the other for %D.
You could code it in one line if you wish:

analysis['STOCH_K'], analysis['STOCH_D'] = ta.STOCH(spy.High, spy.Low, spy.Close)




Shakti D

unread,
Nov 30, 2012, 8:39:04 AM11/30/12
to talib...@googlegroups.com
Not sure how to manage this , added a custom message at bottom as how to send messages to group.
need to configure the group such that History is not embedded each time someone replies.
Reply always goes to the group instead of individuals.

Shakti D

unread,
Nov 30, 2012, 8:41:08 AM11/30/12
to talib...@googlegroups.com
Now I think reply - to will automatically show talib...@googlegroups.com instead of user's email
Just that now I have to manually delete the history each time I post, Is there a way to configure this ?

Peter Cawthron

unread,
Nov 30, 2012, 9:19:33 AM11/30/12
to talib...@googlegroups.com
The reply does now show talib...@googlegroups.com

P.

On 30 November 2012 13:41, Shakti D <shak...@gmail.com> wrote:
Now I think reply - to will automatically show talib...@googlegroups.com instead of user's email
Just that now I have to manually delete the history each time I post, Is there a way to configure this ?

--
You received this message because you are subscribed to the Google Groups "talibpython" group.
To post to this group, send email to talib...@googlegroups.com.
 
 

Reply all
Reply to author
Forward
0 new messages