Skip to content

Some RSI calculations are missing on the 1 minute timeframe #41

Description

@hackcatml

Describe the bug
When running ta.rsi(close, 14) on a 1-minute timeframe dataset of size 1440, only 1434 RSI values are produced.
However, the correct number of results appears when using a 5-minute timeframe dataset.

To Reproduce
Steps to reproduce the behavior:

  1. Download 1m timeframe datasets.
    pyne data download ccxt --symbol "BITGET:BTC/USDT:USDT" --timeframe 1 --from "1"
  2. Create a simple Pyne strategy
"""
@pyne

This code was compiled by PyneComp — the Pine Script to Python compiler.
Accessible via PyneSys: https://pynesys.io
Run with open-source PyneCore: https://pynecore.org
"""
from pynecore import Series
from pynecore.lib import (
    close, script, ta, log
)


@script.strategy("my strategy", overlay=True, initial_capital=10000)
def main():
    rsi: Series[float] = ta.rsi(close, 14)
    log.info("rsi: {0}", rsi)
  1. Run the strategy
    pyne run test ccxt_BITGET_BTC_USDT_USDT_1.ohlcv

  2. Observe the bar index
    The final bar index is much lower than the number of rows in the OHLCV file.

Expected behavior
RSI values should be generated for every bar in the dataset.

Screenshots

  • OHLCV file size
Image
  • pyne run command result
Image Image
  • Missing calculations
    e.g., 2025-11-14 17:18:00+0000
Image Image Image

Environment:

  • OS: macOS
  • Version: (e.g. Ubuntu 22.04, Windows 11)
  • Python version: 3.11, 3.12, 3.13
  • How you ran the script: pyne run

Additional context
I tested this issue using the latest pynecore commit.

Activity

  1. added theissue type on Nov 26, 2025
  2. removed theissue type on Nov 26, 2025
  3. wallneradam commented on Nov 26, 2025

    @wallneradam
    Contributor

    Thank you for taking the time to report this issue and for providing such detailed reproduction steps! This is really helpful.

    After investigation, this is actually expected behavior, not a bug. Here's what's happening:

    The Cause: Gaps in the Data

    The Bitget API doesn't return data for every minute - there are periods with no trading activity. When we downloaded the same data you used, we found:

    • Total records in OHLCV file: 1440
    • Real bars (with trading): 1434
    • Gap bars (no trading): 6

    The gap timestamps (no trading activity from Bitget):

    2025-11-25 14:20:00 UTC
    2025-11-25 17:41:00 UTC
    2025-11-25 21:02:00 UTC
    2025-11-26 00:23:00 UTC
    2025-11-26 03:44:00 UTC
    2025-11-26 07:05:00 UTC
    

    How PyneCore Handles This

    1. When converting data to OHLCV format, PyneCore fills gaps with volume=-1 (a flat candle with previous close price)
    2. When running scripts, these gap bars are skipped by default (skip_gaps=True)
    3. This matches TradingView's behavior - they also skip bars with no trading activity

    Why This Is Correct

    Calculating RSI (or any indicator) on a "fake" bar with no real price movement would produce misleading results. The 1434 RSI values you're seeing represent all the bars where actual trading occurred.

    How to Verify

    You can check for gaps in your OHLCV file:

    from pynecore.core.ohlcv_file import OHLCVReader
    
    with OHLCVReader("your_file.ohlcv") as reader:
        gaps = sum(1 for ohlcv in reader if ohlcv.volume < 0)
        print(f"Gap bars: {gaps}")

    Note: We're converting this issue to a Discussion, as we found it valuable for other users who might encounter the same situation. Thanks again for bringing this up!

  4. locked and limited conversation to collaborators on Nov 26, 2025
  5. converted this issue into a discussion #43 on Nov 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions