Tuesday, January 27, 2009

sympy

version 0.6.3 of sympy has c and python code generation. now i can do symbolic math and have very fast computation of the resulting expressions. cool! In [2]: f = sympy.sympify('exp(-x**2)') In [3]: sympy.printing.ccode(f) Out[3]: 'exp(-pow(x,2))' In [4]: sympy.printing.python(f) Out[4]: "x = Symbol('x')\ne = exp(-x**2)" also has some built-in plotting, which would be more interesting if it weren't so dangerous (pyglet crashed x twice now). but it does have plotting.textplot, which is a cheap and easy way to plot stuff in a terminal. brings back memories of the ol' hp48g. the mpmath module that comes with sympy also has a plot module that promises convenient expression plotting. too bad it doesn't seem to work yet.

sfepy, symfe

sfepy is a finite element code written (mostly) in python. wow! i gotta check it out some time. produces convenient output formats (eg, vtk, hdf5), input files are python scripts, etc. looks like it will eventually use symfe to do some symbolic computations with sympy. symfe looks like it's been stale for a little over a year, though. i hope these projects don't just die.

py

more python goodies, from the people who are working on pypy. py has a test utility, name export control, greenlets, local/remote/svn filesystem access, etc. it also has some channel-based remote execution capability, with no remote-side server installation/maintenance. might make a good light-weight alternative to pyro. utilities for handling code object, too. if i ever do an object caching database with distributed execution, i think this is the way to go. auto api docs based on running instances. cool. definitely the simplest greenlet implementation i've ever seen; i might actually be able to understand and use it. i know pypi has a greenlet module for a coroutine paradigm; i wonder if it's the same. better than the improved generator type of greenlet because you can switch anywhere in the call stack. the tutorials by david beazley are recommended.

Wednesday, January 21, 2009

ksplice: hot-patch your kernel

ksplice is a tool for patching a running kernel without rebooting. i should check it out some time, especially if gentoo makes a package for it.

Wednesday, January 14, 2009

investment optimization functions

i already know that an objective function for an investment optimization needs to have more than just the expected value of the rate of return (though i think this should be the o.f. if constraints are applied as parameter boundaries). otherwise, i would be saying that i would tolerate an unlimited increase in any risk metric for a small increase in expected return, and that's not very smart. so, what else do i throw into the o.f.? the sortino ratio looks interesting. i think it makes a good critique of the sharpe ratio: upside variability should not be punished like downside variability. maybe a variant of it that, like the information ratio, uses a benchmark rather than a risk-free asset for active return. the wikipedia articles on these list others, and the upside potential ratio article refers to an article comparing it to sharpe and sortino ratios. value-at-risk and expected shortfall are both easy to compute, given a pdf on returns. i know value-at-risk has taken a beating. but even though expected shortfall has nice mathematical properties as a coherent, spectral risk measure, it is sensitive to errors in the distribution in the tail. i'm nervous about estimating distributions on something that provides few data by definition. hmmm, that makes me wonder... are there financial risk metrics based on extreme value theory? one thing they all have in common, though, is that they are functionals of the rate of return. the rate of return is a function of the time to reach a limit order, the price relative, and the transaction cost. so, given a pdf for time as a function of price relative, and the function defining rate of return, it should be easy to wrap an optimizer around any of the objective functions above. EDIT: i think the upside potential ratio is the same thing as the sortino ratio, differing perhaps only in the context. the information ratio is the same as the sharpe ratio, except that it uses a benchmark rather than a risk-free return for comparison. looks like the sharpe ratio, sortino ratio, value-at-risk, and expected shortfall (and probably many/most others) are not only funtionals of the rate of return pdf, they are functions of first and second partial moments. if i can boil those partial moments down to a small set, it would be possible to define a multi-objective space in which constant-value contours of the various financial objective functions are simple manifolds. the advantage of this is that i could find a pareto-optimal front in that partial moment space, and it would be easy to see not only the trade-offs but also how sensitive the o.f.s are at any point. otoh, maybe it would be just as easy to look at an overlay of all the o.f.s plotted in the control parameter space, and see values/sensitivities that way. at the very least, splitting up the moments into partials would facilitate simultaneous computation.

Friday, January 9, 2009

Elementary Calculus of Financial Mathematics

this might be a book worth reading: Elementary Calculus of Financial Mathematics, by A. J. Roberts December 2008 / xii + 128 pages / Softcover / ISBN 978-0-898716-67-2 List Price $59.00 / SIAM Member Price $41.30 / Order Code MM15 some of the description sounds like stuff i already know, but the idea of seeing solutions to some practical problems is appealing. www.siam.org/books