Opened 14 years ago

Closed 14 years ago

#3346 closed defect (fixed)

[with patch; positive review with comments] finance -- add a very very basic first little tiny amount of quantitative finance functionality to sage

Reported by: was Owned by: was
Priority: major Milestone: sage-3.0.3
Component: finance Keywords:
Cc: Merged in:
Authors: Reviewers:
Report Upstream: Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description (last modified by was)

This is a first tentative step toward Sage having some little amount of FAST useful finance functionality. This patch provides:

  1. finance.[tab] for some new functions
  1. finance.Stock -- gets historical stock data
  1. finance.TimeSeries?(...) -- highly optimized object for working with double precision time series. This does many basic calculations, like moving averages, standard deviations, histograms, all surprisingly much faster than numpy and R.

See also #3356, which has the next step after this gets reviewed.

Attachments (6)

sage-3346.patch (4.3 KB) - added by was 14 years ago.
sage-3346-part2.patch (21.2 KB) - added by was 14 years ago.
sage-3346-part3.patch (20.5 KB) - added by was 14 years ago.
sage-3346-part4.patch (11.2 KB) - added by was 14 years ago.
sage-3346-part5.patch (27.1 KB) - added by was 14 years ago.
sage-3346-part6.patch (1.0 KB) - added by was 14 years ago.

Download all attachments as: .zip

Change History (10)

Changed 14 years ago by was

Changed 14 years ago by was

Changed 14 years ago by was

Changed 14 years ago by was

Changed 14 years ago by was

comment:1 Changed 14 years ago by was

  • Description modified (diff)
  • Summary changed from [with patch; not ready for review] finance -- add a very very basic first little tiny amount of quantitative finance functionality to sage to [with patch; needs review] finance -- add a very very basic first little tiny amount of quantitative finance functionality to sage

Changed 14 years ago by was

comment:2 Changed 14 years ago by was

  • Description modified (diff)

comment:3 Changed 14 years ago by jkantor

  • Summary changed from [with patch; needs review] finance -- add a very very basic first little tiny amount of quantitative finance functionality to sage to [with patch; positive review with comments] finance -- add a very very basic first little tiny amount of quantitative finance functionality to sage

This is very cool. I'm going to give this a positive review, but I have a bunch of suggestions and comments. Most of these are not critical.

  1. the historical function doesn't seem to work with ETFs which have ticker symbols but are not stocks. In particular for the ticker symbol USO it gives an error, though getting the current value works. I'm not sure if google gets the data differently? Probably they should both work or neither?
  1. The allowed syntax for specifying dates is not documented (unless I missed it).
  1. The documentation for the historical doesn't say what fields it displays are (open, high, low, current, volume). It is documented in the date class, but it might be good to be explicit.
  1. Unless I missed it there is no function to automatically construct a time series out of historical data, this seems like it would be nice.

It would also be nice to be able to get other historical parameters (P/E). It would also be nice to be able to grab historical data between two specified dates. Also what happens when you plug in holidays, weekends, etc, I guess its just what google does but it should probably be specified.

  1. The MarkovMultiFractal? needs more documentation. I want to point out that it is not a standardized model for financial returns (garch is much more widely used), so documentation is important. In particular intuitively what do the different parameters control. Especially since the parameters are kind of misleading as sigma is not the volatility as one would expect a priori. There is a paper cited in the source, but the function needs more documentation. Also, its kind of important that the MarkovMultiFractal? is supposed to be modeling the returns and actually the log returns (difference of the log of the prices). So simply saying that yen_usd is equal to this process isn't a very illustrative example.
  1. Its obviously a lot of work but some sort of maximum likelihood parameter fitting would make this much more useful, I see from the source that this was planned and then commented out. I'm not suggesting this needs to be done I just want to emphasize the estimation of parameters is what makes this actually useful.
  1. If we are including this markov multi fractal there should probably be a garch model at some point, which is what this markov multi fractal is supposed to improve on.
  1. I would put forth the idea that time series should be its own category, or maybe in numerical or statistics (is there a statistics category). After all time series arise everywhere (biology, physics, etc) not just in finance. There are quite a few things it would be nice for the time series to have (arma models at very least) but those aren't relevant to reviewing the patch.

comment:4 Changed 14 years ago by mabshoff

  • Resolution set to fixed
  • Status changed from new to closed

Merged all six patches in Sage 3.0.3.alpha2. The points raised will be adressed in follow up tickets.

Note: See TracTickets for help on using tickets.