enzoampil / fastquant

fastquant — Backtest and optimize your ML trading strategies with only 3 lines of code!
MIT License
1.54k stars 239 forks source link

AttributeError: 'DataFrame' object has no attribute 'append' #425

Closed Enrico68 closed 1 year ago

Enrico68 commented 1 year ago

Problem description

When I try to fetch more crypto_data using a more window temporal, I am getting this error

Example

from fastquant import get_crypto_data

crypto = get_crypto_data("BTC/USDT", 
                         "2018-12-01", 
                         "2020-12-31",
                         time_resolution='1d'
                        )

AttributeError                            Traceback (most recent call last)
/var/folders/b8/ryrff26d5_3g7m25jc_wbfgw0000gn/T/ipykernel_3727/2728600994.py in ?()
----> 3 from fastquant import get_crypto_data
      4 
      5 crypto = get_crypto_data("BTC/USDT", 
      6                          "2018-12-01",

~/fastquant/python/fastquant/data/crypto/crypto.py in ?(ticker, start_date, end_date, time_resolution, exchange)
     97             else:
     98                 # Trim any overlap with the new results
     99                 ohlcv_df = ohlcv_df[ohlcv_df.dt < current_request_df.dt.min()]
    100                 # Append the results to what we have so far
--> 101                 ohlcv_df = ohlcv_df.append(current_request_df)
    102 
    103             # Get the last entry timestamp after we've retrieved (or attempted to) additional records
    104             current_request_end_date_epoch = int(ohlcv_df.dt.max())

~/Library/Python/3.9/lib/python/site-packages/pandas/core/generic.py in ?(self, name)
   5985             and name not in self._accessors
   5986             and self._info_axis._can_hold_identifiers_and_holds_name(name)
   5987         ):
   5988             return self[name]
-> 5989         return object.__getattribute__(self, name)

AttributeError: 'DataFrame' object has no attribute 'append'

Expected behavior

getting the data

Environment

skon7 commented 1 year ago

I believe the error may be related to your Pandas version. In the requirements.txt file, you've specified 'pandas>=1.1.5.' However, in Pandas 2.0, the 'append' method has been deprecated. You have a few options to resolve this:

You can update the Pandas version to one that supports the 'append' method. Replace 'append' with '_append' if it's suitable for your code. Use the 'concat' function instead. Please note that the syntax for 'concat' will change, and you'll need to modify your code to use it like this: 'pd.concat([s1, s2]).'