999 是 pandas 数据框中的最大行数吗?

Is 999 the maximum amount of rows in pandas dataframe?

我正在尝试在 python 中制作一个 加密货币交易机器人 ,并且我使用名为 [=28= 的库收集历史数据(价格和其他东西) ]ccxt,并将其存储在pandas数据帧中。当我尝试存储超过 999 行时,出现如下所示的错误 (KeyError: 999)。基本上它不会让我存储超过 999 行。有没有办法在 pandas 数据帧中获取超过 999 条数据?

代码相当长,但这里有一些片段:

数据框构建:

exchange = ccxt.binance()
bars = exchange.fetch_ohlcv(pair_to_trade, timeframe=timeframe, limit=amount_of_timeframe)
df = pd.DataFrame(bars[:-1], columns=['timestamp', 'open', 'high', 'low', 'close', 'volume'])

Last_row_index:

 for i in range(1, amount_of_timeframe-1):  # where amount_of_timeframe > 1000
        last_row_index = i
        previous_row_index = last_row_index - 1

数据框如下所示:

              timestamp     open     high  ...    upperband    lowerband  in_uptrend
0   2021-09-05 16:27:00  3913.51  3914.97  ...          NaN          NaN        True
1   2021-09-05 16:28:00  3914.04  3914.22  ...          NaN          NaN        True
2   2021-09-05 16:29:00  3910.01  3912.00  ...          NaN          NaN        True
3   2021-09-05 16:30:00  3911.84  3911.85  ...          NaN          NaN        True
...
995 2021-09-06 09:02:00  3956.10  3956.36  ...  3967.517857  3942.412143       False
996 2021-09-06 09:03:00  3954.32  3954.32  ...  3964.035000  3941.775000       False
997 2021-09-06 09:04:00  3951.52  3955.85  ...  3964.035000  3941.610714       False
998 2021-09-06 09:05:00  3955.58  3955.58  ...  3964.035000  3943.252857       False

错误:

File "D:/myfolders/supertrendStrategy/main.py", line 105, in testStrategy
    if not stdf['in_uptrend'][previous_row_index] and stdf['in_uptrend'][last_row_index]:
  File "C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\series.py", line 882, in __getitem__
    return self._get_value(key)
  File "C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\series.py", line 989, in _get_value
    loc = self.index.get_loc(label)
  File "C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\indexes\range.py", line 357, in get_loc
    raise KeyError(key) from err
KeyError: 999

ccxt.binance() 不会让你拿超过 1000 支蜡烛。尝试另一个 API,它适用于更大的数据