algorithmic-trading-python icon indicating copy to clipboard operation
algorithmic-trading-python copied to clipboard

002_quantitative_momentum_strategy

Open adalseno opened this issue 4 years ago • 1 comments

Hi, please note that the code

hqm_dataframe.sort_values(by = 'HQM Score', ascending = False)
hqm_dataframe = hqm_dataframe[:51]

does not work as expected. You need to add inplace = True hqm_dataframe.sort_values(by = 'HQM Score', ascending = False, inplace = True) otherwise you are taking the fist 51 elements in alphabetical order.

PS Shouldn't you just take the first 50 elements with hqm_dataframe = hqm_dataframe[:50] instead of 51 (they start from 0)

adalseno avatar May 20 '21 17:05 adalseno

It would actually require a further line as well or an error is thrown later and i found the following worked best;

hqm_dataframe.sort_values(by = 'HQM Score', ascending=False, inplace= True) hqm_dataframe = hqm_dataframe[:51] hqm_dataframe.reset_index(drop = True, inplace = True)

Purgitoria avatar Oct 10 '21 09:10 Purgitoria