O'Reilly logo

NumPy Cookbook - Second Edition by Ivan Idris

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating a scores table with a recarray function

The recarray class is a subclass of ndarray. These arrays can hold records as in a database, with different data types. For instance, we can store records about employees, containing numerical data such as salary and strings such as the employee name.

Modern economic theory tells us that investing boils down to optimizing risk and reward. Risk is represented by the standard deviation of log returns (see http://en.wikipedia.org/wiki/Rate_of_return#Arithmetic_and_logarithmic_return). Reward, on the other hand, is represented by the average of log returns. We can come up with a relative score, where a high score means low risk and high reward. This is just theoretical and untested, so do not take it ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required