Remove trailing whitespaces

There is no advantage in having trailing whitespaces in the
code. There are also certain disadvantages such as:
 - Navigating to the end of the line works unexpectedly if line
   contains trailing whitespaces
 - Code looks ugly in some editors
 - Trailing whitespaces create commit noise
Organize docstrings according to PEP08 and PEP257

Reformatted docstrings according to
PEP 08 Style Guide for Python Code
http://legacy.python.org/dev/peps/pep-0008/#documentation-strings
and
PEP 257 Docstring Conventions
http://legacy.python.org/dev/peps/pep-0257/

Added docstrings to all functions.
Surround binary operators with a single space

Fixed the code style according to this PEP 08 recommendations:
http://legacy.python.org/dev/peps/pep-0008/#other-recommendations

Signed-off-by: Ed Bartosh <bartosh@gmail.com>
Avoid calling history when it's not needed

Moved call of history function down the place where it's used.
Hopefully this makes code easier to understand.

history will be called less frequently, which can speed up the algo a bit.

Signed-off-by: Ed Bartosh <bartosh@gmail.com>
Use zip function in rebalance_portfolio

This is small optimisation. It gets rid of loop variable 'i' and allows
to pass iterables to rebalance_portfolio.

Signed-off-by: Ed Bartosh <bartosh@gmail.com>
Stop using context.b_t

b_t is used only locally, so it doesn't make much sense
to keep it in context.

Signed-off-by: Ed Bartosh <bartosh@gmail.com>