Hot answers tagged

18

My deal is HFT so what I care about is read/load data from file or DB quickly in memory perform very efficient data-munging operations (group,transform) visualize easily the data I think is is pretty clear that 3. goes to R, graphics and ggplot2 and others allow you to plot anything from scratch with little effort. About 1. and 2. I am amazed reading ...


16

Sorry for not being able to give more than one hyperlink, please do some web search for the project pages. Portfolio optimization could be done in python using the cvxopt package which covers convex optimization. This includes quadratic programming as a special case for the risk-return optimization. In this sense, the following example could be of some use:...


14

Aside from Zipline, there are a number of algorithmic trading libraries in various stages of development for Python. From the commercial side, RapidQuant looks very interesting though I haven't tried it yet. It's from some of same developers that brought us the excellent Pandas data analysis library. I think Wes McKinney (Pandas's main author) is involved....


14

This is interesting because I see another trend: Matlab is being replaced by R, but I guess this is another story. I use R for my academic (I am also teaching this stuff) as well as my consulting work (I am mainly working in the $\mathbb{P}$ area, with some excursions into $\mathbb{Q}$). I tried Python but it didn't work for me. I think the main reasons I ...


14

I've used both R and Python with Pandas in a professional quantitative financial work to do both large and small scale projects. I would strongly recommend Python with Pandas over R for most new projects in the field especially in time series analysis. While I don't dispute vonjd in that you will find more libraries in R with algorithms on the bleeding ...


13

I don't know why it was removed, but the R package "orderbook" was available: http://journal.r-project.org/archive/2011-1/RJournal_2011-1_Kane~et~al.pdf http://cran.r-project.org/web/packages/orderbook/index.html In the IBrokers package, the function "reqMktDepth" is used for streaming order book data. http://cran.r-project.org/web/packages/IBrokers/...


12

Instead of wild guesses about R's/python's future in the community, here some facts: The following query on StackExchange Data Explorer counts the number of questions that have <r> or <python> tags. If you scroll down on one of the three webpages provided below, you can see a graph with data on a monthly basis. You can easily run this query on ...


9

For data analysis, particularly for large data analysis project, pretty much most of the top quant hedge funds and a lot of the banks are using Python (over R) for a couple of reasons but many still have bits and pieces of R for specific packages or functions (I work at a bank and interface with quite a few quant hedge funds on data analysis): Earlier ...


7

So one such visualization package is demonstrated in http://www.tradeworx.com/movie/booklet_demo/temp/booklet_demo2.mov. AFAICT it looks like a tk script. Trading Technologies (TT) sells another visualization tool. But TBH writing your own tool takes a few hours and allows you to focus on what information you are interested in finding.


6

I guess what they are trying to say here is that, assume you have two time series $X$ and $Y$ which are exactly the same i.e. $X=Y$, the correlation is : $$\rho_{X,Y}= \frac{Cov(X,Y)}{\sigma_X \sigma_Y}\overset{X=Y}{=}\frac{Cov(X,X)}{\sigma_X \sigma_X}=\frac{\sigma_X^2}{\sigma_X^2}=1$$ Now assume a time series $Z=2 \cdot X$, you have: $$\sigma_Z=2 \...


5

Firstly, you'll probably be directed to consider Zipline. It's worth a look but I don't think that it's a good starting point, since: Quantopian's developers don't have a financial background and it shows through in the Zipline source code. Zipline is dreadfully slow if you compare it to any commercial platform with backtesting functionality in a compiled ...


5

http://lobster.wiwi.hu-berlin.de/forum/viewtopic.php?f=4&t=30 R code, pictures and discussion, it's easy to modify it


5

It doesn't matter if you use *100 or just pct_change, as long as you are consistent. However, in practice, due to underlying floating point numerical instabilities in the underlying optimization algorithms/default tolerances used in scipy/arch, having the returns expressed in %, i.e. multiplied by 100, will have a better chance of converging during the ...


5

OpenTSDB is good for large-scale time series storage. metrilyx/opentsdb-pandas and wiktorski/opentsdb_pandas seems to provide the interface with pandas. OpenTSDB and HBase rough performance test | MoreDevs provides a benchmark, may not exactly match your requirements but you can try.


4

possible update: http://pmorissette.github.io/bt/ based on http://pmorissette.github.io/ffn/ both were easily installed and somewhat usable for a novice. would love some examples other that github documentatiion


4

You said:"I understand that the generated ticks will be generated using interpolation (so they won't be exacts)". You are very optimistic, they will not only be far away from being exact, they (the tick data) will be completely removed from reality, the only parameters known for the tick data will be boundary conditions, such as open high low close. You ...


4

For the tasks listed, both Python and R perform very well. There are some packages in Python not in R and vice versa. My solution for this is to simply call R from Python. This allows for the best of both worlds. It is also important to note I do not write any R code other than calling an R library from Python. Calling Python from R does not work equally ...


4

This does the trick. Given "U8", function will get the IMM date for Sep 2018. Given "U4", function gets the IMM date for Sep 2024 (or it will until we've passed that date). Could be easily modified to also pull historical IMMs from a given longer symbol eg. "U2014". def getIMMDate(IMMcode): '''Takes 2 digit IMM code and returns effective date as datetime ...


4

The installation process should be the same as on Linux. Once you have the C++ QuantLib library installed (instructions for that are on the QuantLib site, at http://quantlib.org/install/macosx.shtml) you can download the latest QuantLib-SWIG release, uncompress it and run: ./configure make -C Python sudo make -C Python install Note that the above work ...


4

In the call to Bisection.solve, the question mark must be the Python function whose zero you want to find. In your case, it should be something reproducing the logic of IRRSolver::operator() in Mick Hittesdorf's code, i.e., something like this (which I haven't tested): cashflows = fixedRateBond.cashflows() npv = fixedRateBond.NPV() def ...


3

Edit (2016-06-21): Now with live data/trading integration with Interactive Brokers. It has taken a while but it has finally arrived. A (now) very mature (imho) Python backtesting framework is "backtrader": https://github.com/mementum/backtrader Blog posts with samples and new developments: http://www.backtrader.com The documentation on readthedocs can ...


3

TradeStation offers python support via their WebAPI. Check it out here: http://tradestation.github.io/webapi-docs/


3

I reproduced Ledoit and Wolf's experiment outlined in their paper "Honey I Shrunk the Covariance Matrix" in Python which includes an implementation of their method to shrink the covariance matrix (can be found here see the get_shrunk_covariance_matrix() method on line 417). All the code for the entire thing is on Github here. I make use of the cvxopt module ...


3

I know this is an old question, but Wes McKinney, the developer of pandas (mentioned in another answer) is releasing a new Python package called RapidQuant that I think might meet the OP's stated needs. It appears to include both non-standard risk definitions and portfolio optimization. However, it is not open source. While the OP didn't specifically mention ...


3

You can get this using a pandas rolling_max to find the past maximum in a window to calculate the current day's drawdown, then use a rolling_min to determine the maximum drawdown that has been experienced. Lets say we wanted the moving 1-year (252 trading day) maximum drawdown experienced by a particular symbol. The following should do the trick: import ...


3

What you need is more mutual information rather than Shannon entropy. It is dedicated to capture the influence of one variable on another (you can think about it as a non linear version of Pearson correlations). They are closely related since the mutual information $I$ between two variables $X$ and $Y$ reads: $$I(X;Y) = H(X,Y) - H(X|Y) - H(Y|X)$$ where $H$ ...


3

They expire 30 days before the expiration of the S&P monthly options. The latter usually expire on the third Friday of the month (however, in rare cases the S&P opts. expire on Thursday because the Friday is a holiday; the last time it happened was April 17, 2014 since April 18 2014 was a NYSE holiday). Neglecting the holiday thing, the expiration ...


3

I found out what I was doing wrong - the OLS function was regressing with no intercept value - so I had to use the "add_constant" method to add an intercept term to the X series (z_lag) as follows: z_lag = np.roll(z_array,1) z_lag[0] = 0 z_ret = z_array - z_lag z_ret[0] = 0 #adds intercept terms to X variable for regression z_lag2 = sm.add_constant(z_lag) ...


3

Remember that all back testing is full of lies assumptions. Latency (both line latency and latency internal to the exchanges), adverse selection, market impact (yes, even you have market impact), etc, are all based on assumptions. These assumptions are educated guesses at best, but more often terrible models are used (you always get filled at at mid!) and ...


3

I think the most sophisticated solutions are to be found within the R universe. One package that comes to mind is the quantmod package. You can use it to download data from Yahoo and Google finance, plot charts and filter your stocks using all kinds of technical indicators (that come with the package). It can be found on CRAN: https://cran.r-project.org/...



Only top voted, non community-wiki answers of a minimum length are eligible