trendet icon indicating copy to clipboard operation
trendet copied to clipboard

AttributeError: 'int' object has no attribute 'days'

Open taglitis opened this issue 2 months ago • 1 comments

I tried to use AAPL data to define trend for the last two years. I set up window_size = 5 it gave, an error below. I changed it to 10, it ran ok. Then, changed the ticker to AMZAN it gave me the error for 5 and 10.

Please, let me know if you have any suggestions

AttributeError Traceback (most recent call last) File G:\My Drive\development\swing\main.py:392 385 print('script is completed') 390 if name == 'main': --> 392 main() 402 # WMA https://corporatefinanceinstitute.com/resources/career-map/sell-side/capital-markets/weighted-moving-average-wma/

File G:\My Drive\development\swing\main.py:284, in main() 280 df['day'] = df['timestamp'].dt.strftime('%Y-%m-%d') 281 # trend_df = alpaca_paral_data_col([ticker], start_date_ms, end_date_ms, timespan = 'day', multiplier=1) 282 # print(f'{ticker} i = {i} trend_df\n', trend_df.head()) 283 # trend_df = sf.trend_define(ticker, start_date_ms, end_date_ms) --> 284 trend_df = sf.trend_define_trendet(ticker, start_date_ms, end_date_ms) 285 print(f'{ticker} i = {i} trend_df\n', trend_df.head()) 286 df = df.merge(trend_df[['ticker', 'day', 'trend']], on=['ticker', 'day'], how='inner')

File G:\My Drive\development\swing\swing_functions.py:197, in trend_define_trendet(ticker, start_date_ms, end_date_ms) 195 trend_df = alpaca_paral_data_col([ticker], start_date_ms, end_date_ms, timespan = 'day', multiplier=1) 196 trend_df['close'] = trend_df['close'].astype('float64') --> 197 trend_df = trendet.identify_df_trends(df=trend_df, 198 column='close', 199 window_size=5, 200 identify='both')#.rename(columns={'Up Trend': 'trend'}) 201 trend_df['trend'] = trend_df['Up Trend'].notnull().replace({True: 'uptrend', False: None}) 202 trend_df['Down Trend'] = trend_df['Down Trend'].notnull().replace({True: 'downtrend', False: None})

File ~\Anaconda3\envs\VENV_SWING_P3_9_11\lib\site-packages\trendet\identification.py:589, in identify_df_trends(df, column, window_size, identify) 587 for down in results['Down Trend']: 588 if down['from'] < up['from'] < down['to'] or down['from'] < up['to'] < down['to']: --> 589 if (up['to'] - up['from']).days > (down['to'] - down['from']).days: 590 flag = True 591 else:

AttributeError: 'int' object has no attribute 'days'

taglitis avatar Apr 22 '24 12:04 taglitis