Closed ShreyasChari closed 6 years ago
Yea this is an annoying warning that pops up all the time. The good news is I don't think this warning causes any actual problems.
I think returns contains a nan and thats why it is throwing a warning.
temp = np.random.normal(0,1,size=10)
np.minimum(temp,0.)
Out[110]:
array([-1.74248744, 0. , -1.00643656, 0. , 0. ,
0. , 0. , 0. , -0.19332383, 0. ])
temp[0] = np.nan
np.minimum(temp,0.)
__main__:1: RuntimeWarning: invalid value encountered in minimum
Out[112]:
array([ nan, 0. , -1.00643656, 0. , 0. ,
0. , 0. , 0. , -0.19332383, 0. ])
Let me try replacing minimum
with fmin
.
so how do i import this into the package i downloaded? sorry for the noob question, i use anaconda and pip, never done anythng directly from here
Download the source code directly from github and replace your current import ffn
with the code below which adds the location of the new source code to your path manually.
import sys
sys.path.insert(0, "\\\\your\\path\\here\\")
import ffn
So i should add this path which came in the error C:\ProgramData\Anaconda3\lib\site-packages\ffn\core.py ? How do i download source code from github and which file is it?
You need to add replace
import ffn
in your current code with
import sys
sys.path.insert(0, "\\\\your\\path\\here\\")
import ffn
\\your\path\here\ should be the path to wherever you downloaded the github source code. I wouldn't download it to C:\ProgramData\Anaconda3\lib\site-packages\ffn\ because Anaconda mantains that folder. I would download it to documents or something....
https://stackoverflow.com/questions/6466945/fastest-way-to-download-a-github-project
i downloaded it into a folder called ffn-master on my desktop, and am using that path to point to that folder in the code you sent i.e r"C:...\Desktop\ffn-master\ffn" The code seems to run fine in importing as i get no errors.
This has however not fixed my problem when i rerun the stat_calcs, same error...
Can you copy and paste the error?
Do you have nan or 0 prices in your dataframe?
C:\ProgramData\Anaconda3\lib\site-packages\ffn\core.py:2054: RuntimeWarning: invalid value encountered in minimum negative_returns = np.minimum(returns, 0.)
Ihave no NaNs or zero prices in my datframe. I even tried running on just the first ten rows for a sanity check but that did not help
You are still using the ffn package from Anaconda which is why it is referencing your anaconda directory in the warning. You need to restart your python kernel.
i just shut it all down and restarted and reran, the path is not taking coz the error still references the original anaconda library.. dont know what to do..
import sys sys.path.insert(0, r"C:\Users\ShreyasChari\Desktop\ffn-master\ffn\core.py") import ffn print (sys.path)
['C:\Users\ShreyasChari\Desktop\ffn-master\ffn\core.py', 'C:\Users\ShreyasChari\Desktop\ffn-master\ffn\core.py', 'C:\Users\ShreyasChari\Desktop\ffn-master\ffn\core.py', 'C:\Users\ShreyasChari\Desktop\ffn-master\ffn\core.py', 'C:\Users\ShreyasChari\Desktop\ffn-master\ffn\core.py', 'C:\Users\ShreyasChari\Desktop\ffn-master\ffn\core.py', 'C:\Users\ShreyasChari\Desktop\ffn-master\ffn\core.py', 'C:\Users\ShreyasChari\Desktop\ffn-master\ffn', 'C:\Users\ShreyasChari\Desktop\ffn-master\ffn', '', 'C:\ProgramData\Anaconda3\python36.zip', 'C:\ProgramData\Anaconda3\DLLs', 'C:\ProgramData\Anaconda3\lib', 'C:\ProgramData\Anaconda3', 'C:\ProgramData\Anaconda3\lib\site-packages', 'C:\ProgramData\Anaconda3\lib\site-packages\Babel-2.5.0-py3.6.egg', 'C:\ProgramData\Anaconda3\lib\site-packages\win32', 'C:\ProgramData\Anaconda3\lib\site-packages\win32\lib', 'C:\ProgramData\Anaconda3\lib\site-packages\Pythonwin', 'C:\ProgramData\Anaconda3\lib\site-packages\IPython\extensions', 'C:\Users\ShreyasChari\.ipython']
so the path is there but it doesnt take when i run the code can you please help me out with this?
I am running the calc_stats() function on my data frame whihc seems to be formatted correctly and has no errors ( i tried it on the 297 lines of data then 50 then 10, errors on all the different frames), i get the following error: C:\ProgramData\Anaconda3\lib\site-packages\ffn\core.py:2054: RuntimeWarning: invalid value encountered in minimum negative_returns = np.minimum(returns, 0.)
I am not very proficient in Python but i have done my best to see whats wrong with the data and it all looks clean. I am not using Yahoo data as the data retrieval that ffn is using also fails me, so I created my own data from elsewhere. Pls help as this would be very valuable to my project.
Thanks