Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
taglitis opened this issue Apr 22, 2024 · 1 comment
Open

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

taglitis opened this issue Apr 22, 2024 · 1 comment

Comments

@taglitis
Copy link

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
Copy link
Author

taglitis commented Apr 23, 2024

looks like this issue has been discussed already #8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant