nickmccullum / algorithmic-trading-python

The repository for freeCodeCamp's YouTube course, Algorithmic Trading in Python
2.35k stars 2.37k forks source link

Calculating Momentum Percentiles #27

Open seanmaman opened 2 years ago

seanmaman commented 2 years ago

Capture hey, i cant find a solution to the problem am facing i see no mistake on the code

hbquoc commented 2 years ago

@seanmaman @nickmccullum I encounter the exact same error. Have you found any solution?

seanmaman commented 2 years ago

yea, you just need to search for nulls and replace all the nulls with values i suggest to fill the nulls with the mean of each col. if you need a code for it you can ask.. but i think you will be ok

On Sun, Mar 6, 2022 at 11:48 AM hbquoc @.***> wrote:

@seanmaman https://github.com/seanmaman @nickmccullum https://github.com/nickmccullum I encounter the exact same error. Have you found any solution?

— Reply to this email directly, view it on GitHub https://github.com/nickmccullum/algorithmic-trading-python/issues/27#issuecomment-1059929500, or unsubscribe https://github.com/notifications/unsubscribe-auth/AXUZL3544MDVHWPQGUPKJJ3U6R5PHANCNFSM5N6DP2AQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.Message ID: @.***>

hbquoc commented 2 years ago

@seanmaman Thanks! It is indeed a data problem. The price return is unavailable for several tickers.

Below is the code to check for unavailable data for future readers.

mask = hqm_dataframe['One-Year Price Return'].isnull() \
            | hqm_dataframe['Six-Month Price Return'].isnull() \
            | hqm_dataframe['Three-Month Price Return'].isnull() \
            | hqm_dataframe['One-Month Price Return'].isnull()

hqm_dataframe[mask]

image

seanmaman commented 2 years ago

You can check nulls for each col, df.isnull().sum() And then:

df = df.fillna({'Name of col':df['open'].mean()}) Of curse you need to add every col with null value

Sent from my iPhone

On 6 Mar 2022, at 16:21, hbquoc @.***> wrote:

 @seanmaman Thanks! It is indeed a data problem. The price return is unavailable for several tickers.

Below is the code to check for unavailable data for future readers. `mask = hqm_dataframe['One-Year Price Return'].isnull() | hqm_dataframe['Six-Month Price Return'].isnull() | hqm_dataframe['Three-Month Price Return'].isnull() | hqm_dataframe['One-Month Price Return'].isnull()

hqm_dataframe[mask]`

— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you were mentioned.

hbquoc commented 2 years ago

Thanks for the code. The function mean(), or mean(skipna=True), doesn't work for me; it can only return the mean of the "Price" column. By the way, I prefer dropping the tickers without price return values so I created a new data frame without them.

seanmaman commented 2 years ago

Try to Insert 0 in strings columns

Sent from my iPhone

On 6 Mar 2022, at 18:37, hbquoc @.***> wrote:

 Thanks for the code. The function mean() doesn't work for me; it can only return the mean of the "Price" column. By the way, I prefer dropping the tickers without price return values.

— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you were mentioned.