question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Output index differs from input index (stoch, td_seq)

See original GitHub issue

Hello @twopirllc,

upon releasing vectorbt v0.20 I noticed some pandas-ta tests failing. As you know, I previously created a simple parser to extract the meta of each pandas-ta indicator (it builds a dummy DataFrame with 50 random floating elements and passes it to pandas-ta to see what outputs to expect). The parser started to fail for some of the indicators:

>>> import vectorbt as vbt

>>> vbt.IndicatorFactory.get_pandas_ta_indicators(silence_warnings=False)
Function stoch: Couldn't parse the output: mismatching index
Function td_seq: Couldn't parse the output: mismatching index
Function trix: Couldn't parse the indicator: inputs are all NaN
Function ichimoku: 'NoneType' object has no attribute 'index'
UserWarning: Function kvo: 'NoneType' object has no attribute 'index'

I can’t remember which ones I wasn’t able to parse previously (probably Ichimoku), but the new ones are definitely stoch and td_seq. Upon looking closer, I noticed that stoch removes head entries that are NaN, while td_seq returns a simple range index instead of a datetime-like index.

To address this, I can quickly patch vectorbt to 1) fill the missing index if the output index is of the same type and 2) copy the input index if the output index has another type but the same length.

Would love to hear your thoughts on this matter.

Edit: I’m running 0.3.14b0

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
polakowocommented, Aug 4, 2021

@twopirllc,

perfect, I’ll look into the other two and maybe tweak the parser a bit. Thank you!

0reactions
twopirllccommented, Sep 5, 2021

@bennycode,

Why does it need 9 inputs of high, low, close before the Stochastic Oscillator returns a result?

It has the required inputs to calculate ta.stoch as described in help(ta.stoch), which is closer to 7. Some (offset, fillna, fill_method) you won’t use unless you actually need them.

Is ta.stoch not working as expected?

Stochastic (STOCH)

    Args:
        high (pd.Series): Series of 'high's
        low (pd.Series): Series of 'low's
        close (pd.Series): Series of 'close's
        k (int): The Fast %K period. Default: 14
        d (int): The Slow %K period. Default: 3
        smooth_k (int): The Slow %D period. Default: 3
        mamode (str): See ```help(ta.ma)```. Default: 'sma'
        offset (int): How many periods to offset the result. Default: 0

    Kwargs:
        fillna (value, optional): pd.DataFrame.fillna(value)
        fill_method (value, optional): Type of fill method

However, I should probably add another mamode like TA-Lib does:

/*
 * TA_STOCH - Stochastic
 * 
 * Input  = High, Low, Close
 * Output = double, double
 * 
 * Optional Parameters
 * -------------------
 * optInFastK_Period:(From 1 to 100000)
 *    Time period for building the Fast-K line
 * 
 * optInSlowK_Period:(From 1 to 100000)
 *    Smoothing for making the Slow-K line. Usually set to 3
 * 
 * optInSlowK_MAType:
 *    Type of Moving Average for Slow-K
 * 
 * optInSlowD_Period:(From 1 to 100000)
 *    Smoothing for making the Slow-D line
 * 
 * optInSlowD_MAType:
 *    Type of Moving Average for Slow-D
 * 
 */

Kind Regards, KJ

Read more comments on GitHub >

github_iconTop Results From Across the Web

A Scalable Near-Memory Architecture for Training Deep ...
We observe that we can subdivide the pixels of the input derivative into different categories: Each pixel subset can be computed as a...
Read more >
RVI — Indicators and Signals - TradingView
Based on the Stochastic RSI but uses RVI (Relative Volatility Index) as source. Another great tool for finding market lows and entry points....
Read more >
47467-hoio-ux-o0 relbet 4.0 user's guide
Adjust The Linput Input Files to Reflect. Mission Characteristics ... QA Kalman Filter Output . ... index to difference.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found