Kamis, 31 Mei 2007

Stop Loss, Profits Cap, Survivorship Bias, In Addition To Dark Swans

I accept long espoused the sentiment that nosotros should non impose stop-losses on mean-reverting strategies, nor profits caps on momentum strategies. My sentiment on the latter has non changed, but it has evolved on the former.

My master copy argue for opposing stop-losses on mean-reverting strategy is this. Say yous believe your specific cost serial is mean-reverting, in addition to tell yous accept entered into a long position when the cost is low. Now, however, the cost gets much lower, in addition to yous are suffering a large unrealized loss. Well, based on your mean-reverting belief, yous should purchase to a greater extent than instead of liquidating! Indeed, if yous backtest the number of stop-losses on mean-reverting strategies, yous volition close inevitably discovery that they decrease the overall returns in addition to fifty-fifty Sharpe ratios.

But what this simplistic sentiment ignored is 1) survivorship bias, in addition to 2) dark swan events. (Hat tip: Ben, who prompted me to reckon these ii issues.)

1) We unremarkably would alone merchandise those cost serial alongside a mean-reverting strategy alone if nosotros run into that the prices did eventually revert. No ane would bother to merchandise those cost serial that used to mean-revert, but all of a abrupt stopped doing so. But maxim that stop-losses are harmful to mean-reverting strategies is ignoring the fact that some mean-reverting volition halt working altogether in addition to would non live on our strategies choice process.

2) Let's define dark swan events equally those that did non travel on inward your backtest period. For example, let's tell yous never had a loss of 20% inward a unmarried day. So if yous backtest a stop-loss of 20%, it volition accept no number whatsoever on your backtest performance. However, no ane tin tell for sure that it won't travel on inward the future. So if yous or your investors exactly cannot tolerate a 20% loss, yous should impose this equally a stop-loss. (After all, your brokerage has already imposed a stop-loss of 100% on yous whether yous similar it or not.)

We tin inward fact plow betoken 2) roughly when deciding what stop-loss to use: a stop-loss should live liberate plenty in addition to then that it should accept no number on the backtest performance, in addition to of course of pedagogy tight plenty in addition to then that it volition non resultant inward the demise of your trading career.

There is too the number of whether to purpose stop-loss on the intraday drawdown, or to purpose it on the multiple-day drawdown. I would struggle that alone intraday stop-loss is of import to forestall a black-swan loss. In practice, when a strategy has a string of non-catastrophic losses occurring over multiple days, resulting inward a large, unprecedented, drawdown, the trader volition typically re-examine the strategy, taking into concern human relationship this most recent functioning in addition to tweak the strategy in addition to then that it could theoretically live avoided. This is close similar a multi-day stop-loss strategy, equally nosotros halt an old strategy in addition to showtime a new, modified, one. (Though the modified strategy mightiness soundless recommend that yous conk along asset the electrical flow position!)

Now why am I soundless asset love to the regulation that ane should non impose profit-caps on momentum strategies? Why, the possibility of dark swan events again! But this time, whatever dark swan tin alone resultant in unprecedented one-day gain instead of loss, since nosotros should always have stop-losses on momentum strategies. We for certain don't desire to impose a profit-cap to dominion out this possibility!

Trading Platform In Addition To Ec2 Revisited

Recently I opened a discussion on the diverse software platforms which allow the programmers with us to construct trading strategies easily. Here is 1 other addition: Quantopian. It is exclusively inwards alpha stage, simply I did acquire a preview of its features:

1) You tin code inwards Python, which is an easier linguistic communication to larn than Java, simply no less powerful. In fact, I know of a superb programmer who uses Python to backtest HF strategies.

2) It is web-based, which agency you lot tin accept wages of collocation on a server much to a greater extent than stable than your ain desktops. (For those who worry well-nigh the confidentiality of your strategies, the founder indicated to me that they tin run an icon of the software on an Amazon EC2 concern human relationship that you lot owned then they won't induce got access to your codes. As for the confidentiality of codes residing on EC2 itself, delight encounter below*.)

3) It is event-driven (or for those who similar the latest jargon: CEP-enabled), similar all the Java API's that I discussed inwards the previous article.

4) They induce got 1-min U.S.A. equities information for backtesting. Tick-level information volition live available soon.

5) Toolboxes for mutual technical indicators, mathematical algorithms, etc. volition live available soon.

6) They volition run a contest for trading models which makes it easier for independent traders to run past times away trading advisers to others, or to heighten coin for their ain funds.

Unfortunately, alive walk-forward testing is non yet available.

* Some readers induce got wondered whether it is prophylactic to run their trading models on Amazon's EC2. Won't Amazon's employees induce got access to their wildly profitable strategies? The respond is no: Amazon's security policy:


Guest Operating System: Virtual instances are completely controlled past times the customer. Customers induce got sum origin access 
or administrative command over accounts, services, as well as applications. AWS does non induce got whatsoever access rights to customer 
instances as well as cannot log into the invitee OS....

Thanks to a reader OL from French Republic who provided me with this info. He likewise told me that: 

"So, I lastly deployed my momentum strategy on a Linux trial of EC2 (which is gratuitous btw).
I wrote it based on the coffee present application provided past times Interactive Brokers as well as about parts of Algoquant.
So far, I role a European trial of EC2 which alas doesn't induce got the best latency to IB U.S.A. servers (90 ms) simply nevertheless ameliorate than my sleeping accommodation connection. 
Influenza A virus subtype H5N1 examination ping from a U.S.A. trial to IB U.S.A. servers results inwards exclusively fifteen ms ..."

So at that topographic point you lot go: Java+Algoquant+IB+EC2=profit.

Rabu, 30 Mei 2007

Risk Indicators

During the fiscal crisis of 2008, I wrote about how I watched some risk indicators such every bit the VIX or the TED spread  to create upward one's heed what leverage I should use for my trading strategies. It turns out that this physical care for is simply every bit critical for the electrical current crisis that began inward August 2011. In fact, to a greater extent than than leverage-determinants, they tin locomote used every bit the all-important variable that determines whether a for certain strategy should locomote run at all. (What's the betoken of running a model that y'all mean value volition lose coin amongst depression leverage?)


There are instantly to a greater extent than than a few of these risk indicators to selection from. Besides the VIX in addition to the TED, at that topographic point are the VSTOXX (EURO STOXX fifty Volatility), the VXY (JPMorgan G7 Volatility Index), the EM-VXY (JPMorgan Emerging Market Volatility Index), the ETF's ONN and OFF, in addition to belike many to a greater extent than that I haven't heard of yet. 


A lot of academic enquiry has been done on whether nosotros tin devise "regime switching" models based on some complicated pattern-recognition algorithms to create upward one's heed whether a marketplace is inward a for certain "regime" which favors this or that item model or parameter set. And often, these authorities switching models rely on the recognition of some complicated laid upward of patterns inward the historical cost series. Sorry to say, I accept non establish whatever of these complex authorities switching model to accept whatever existent out-of-sample predictive power. On the other hand, my enquiry shows that some of the aforementioned elementary risk indicators volition indeed forestall some trading models from falling off the cliff.


But which of these indicators are applicable to which model? This is non so obvious. For example, y'all powerfulness mean value that the EM-VXY would locomote an ideal leading indicator for Forex trading models that demand emerging marketplace currencies, but I accept establish that it is solely a contemporaneous (and hence useless) indicator to mine. Another example, I said during the 2008 fiscal crisis that VIX seems to locomote a useless contemporaneous indicator for equities trading models, but strangely, it is a expert leading indicator for FX models. In contrast, the TED spread that everyone were obsessed close inward 2008 shot upward to over 300 bps then, but never went beyond 100 bps this fourth dimension around. So actually solely rigorous backtesting tin guide us here.


What risk indicators produce y'all use? And accept y'all actually backtested their efficacies? Your comments would locomote real welcome here.

Selasa, 29 Mei 2007

What Worked Inward 2011?

We all know that 2011 was a bad twelvemonth for many hedge funds, amongst the average fund down 5%. But what type of strategies did well, together with what did peculiarly poorly? The numbers are out: Forex funds lose to a greater extent than than average, downwards 6%. In fact, 71 out of 77 Forex funds tracked past times a Citigroup currency analyst were downwards inwards 2011. And the winners are? Statarb funds, amongst a 5% averge return.

This superior surgical operation of statarb funds is quite a contrast from the final fiscal crisis 2007-9. Then, most of the large factor-driven statarb models failed miserably. What caused this difference? Is it because the conduct chances management techniques of large funds convey improved? Or perchance that's because inwards 2011, the divergence from constituent returns mean-revert inside a few days, together with then those statarb models that re-balance on a daily footing tin create goodness from the buying/selling chance at steep discount/premium?

To settle this question, permit me study the 2011 backtest results (without transaction costs) of running Andrew Lo's paradigm mean-reversion model : ranking stocks based on their previous day's returns, shorting the overstep decile together with buying the bottom one, rebalancing exclusively at the close. (Click on nautical chart to acquire far larger.)



The APR inwards 2011 was 18.6%. Note inwards item its surgical operation since the crisis began officially on 20110808: despite a steep drawdown, the overall surgical operation was spectacular! Clearly, high volatility benefited a prototypical statarb strategy, together with the out-performance has non much to create amongst improved conduct chances management.

You mightiness wonder what would hand if nosotros had used the intraday version of this strategy instead: endure into all positions at the open, together with endure out them all at the close? I tried it: the surgical operation is surprisingly similar to the interday strategy. So intraday vs. interday volatility or mean-reversion does non appear to play a purpose inwards final year's equities market. Contrasting this amongst the surgical operation of Forex models, it is clear that high volatilities benefited statarb models piece they wound FX models.

In the side past times side article or two, I volition explore the 2011 surgical operation of another equities mean-reverting models that I used to trade. But what almost your models? If you lot convey simply about thoughts on what worked together with what didn't inwards 2011, delight part them amongst us inwards the comments section.

Senin, 28 Mei 2007

Ideas From A Psychologist

I receive got merely finished reading Daniel Kahneman's bestseller "Thinking, Fast as well as Slow", as well as establish it sum of inspirations of import for traders. This is no surprise, of course, since Kahneman won the 2002 Nobel prize inward economic science for his function on determination theory. Here are unopen to of the notables:

1) Simple pith is oft improve than a linear regression fit. Remember my constant mantra that "simpler is better" when edifice trading models? I receive got e'er advocated linear regression over nonlinear models, but Kahneman went a pace further. He said that inward social scientific discipline modeling (which of flat includes fiscal markets modeling), assigning equal weights to the predictive factors is oft superior to weighting them using multivariate linear regressors when applied to out-of-sample data.

2) Overconfidence inward corporate acquisitions. Managers of acquiring companies oft believe that they are improve than the managers of acquirees. This overconfidence has several causes: in that location is an illusion of command which overemphasizes the component subdivision of science as well as neglects the component subdivision of luck, as well as in that location is a focus on what 1 knows as well as a fail of what 1 does not, etc. The marketplace seat already knows this: the stock of the acquirer normally suffers a sell-off upon proclamation of the acquisition, because the upshot of whatsoever acquisition is to a greater extent than oft bad than good, but the query is whether it has sufficiently discounted this phenomenon. Would shorting the stock of an acquirer at the completion of an acquisition as well as asset the brusk seat for, say, v years, hedging this seat alongside SPY, move profitable?

3) Premortem. After designing a trading strategy, it is e'er useful to write a brief imaginary history of how it has cash inward one's chips an unmitigated fiscal disaster for yous a few years from now. This volition probable break scenarios that yous receive got non previously idea of, as well as triggering additional direct a opportunity administration measures.

4) Risk seeking inward the aspect upwards of losses. Suppose yous are running a strategy that has a fixed asset period. Have yous ever extended this asset catamenia when the seat is losing, inward the promise that the seat volition recoup unopen to of its losses? I have, as well as the upshot was double the loss I would receive got suffered had I exited on time. Apparently this is a rattling mutual suboptimal behavioral bias: this is why many defendants alongside a weak legal illustration oft direct a opportunity continued litigations instead of accepting an unfavorable settlement.

5) Why create nosotros oft need Sharpe ratio  >=2? Psychological experiments receive got shown that people discovery the hurting of losing $1 tin plough over the axe entirely move compensated past times the pleasance of winning $2. So if nosotros equate criterion difference equally the average drawdown of a strategy, hence nosotros require to receive got twice the average return!

Many businesses receive got profited from arbitraging the difference betwixt rational decisions as well as biased decisions that people commonly made. (For e.g. lottery franchises create goodness from people overweighting the probability of winning, sellers of extended warranties create goodness from buyers' risk-aversion.) I wonder if in that location are still opportunities left for rational traders to convey payoff of the biased decisions of irrational traders?

Minggu, 27 Mei 2007

Hidden Markov Model Applied To Fx Prediction

I read amongst involvement an older newspaper "Can Markov Switching Models Predict Excess Foreign Exchange Returns?" yesteryear Dueker as well as Neely of the Federal Reserve Bank of St. Louis. I direct maintain a fondness for hidden Markov models because of its dandy success inward spoken language recognition applications, exactly I confess that I direct maintain never been able to create a HMM model that outperforms elementary technical indicators. I blame that both on my ain lack of inventiveness equally good equally the fact that HMM tend to direct maintain equally good many parameters that postulate to last fitted to historical data, which makes it vulnerable to information snooping bias. Hence I approached this newspaper amongst the dandy promise that experts tin laissez passer on notice instruct me how to apply HMM properly to finance.

The objective of the model is simple: to predict the excess supply of an central charge per unit of measurement over an 8-day period. (Excess supply inward this context is measured yesteryear the % modify inward the central charge per unit of measurement minus the involvement charge per unit of measurement differential  between the base of operations as well as quote currencies of the currency pair.) If the expected excess supply is higher than a threshold (called "filter" inward the paper), as well as thence acquire long. If it is lower than or thence other threshold, acquire short. Even though the prediction is on a 8-day return, the trading determination is made daily.

The excess supply is assumed to direct maintain a 3-parameter student-t distribution. The iii parameters are the mean, the marking of freedom, as well as the scale. The scale parameter (which controls the variance) tin laissez passer on notice switch betwixt a high as well as depression value based on a Markov model. The marking of liberty (which controls the kurtosis, a.k.a. "thickness of the tails") tin laissez passer on notice also switch betwixt ii values based on or thence other Markov model. The hateful is linearly theme on the values assumed yesteryear the marking of liberty as well as the scale equally good equally or thence other Markov variable that switches betwixt ii values. Hence the hateful tin laissez passer on notice assume viii distinct values. The iii Markov models are independent. The student-t distribution is to a greater extent than appropriate for the modelling fiscal returns than normal distribution because of the allowance for heavy tails. The authors also believe that this model captures the switch betwixt periods of high as well as depression volatility, amongst the consequent modify of preference (=different hateful returns) for "safe" versus "risky" currencies, a phenomenon well-demonstrated inward the menses betwixt August 2011 to Jan 2012.

The parameters of the Markov models as well as the student-t distributions are estimated inward the in-sample menses (1974-1981) for each currency dyad inward social club to minimize the cumulative departure of the excess returns from zero. There are a full of fourteen parameters to last thence estimated. After these estimations, nosotros direct maintain to also approximate the ii trading thresholds yesteryear maximizing the in-sample supply of the trading strategy, assuming a transaction costs of 10 footing betoken per trade.

With this large release (16 inward total) of parameters, I dread to come across the out-of-sample (1982-2005) results. Amazing, these are far ameliorate than I expected: the annualized returns attain from 1.1% to 7.5% for iv major currency pairs. The Sharpe ratios are non equally impressive: they attain from 0.11 to 0.71. Of course, when  researchers study out-of-sample results, 1 should accept that amongst a grain of salt. If the out-of-sample results weren't good, they wouldn't last reporting them, as well as they would direct maintain kept changing the underlying model until goodness "out-of-sample" results are obtained! So it is actually upward to us to implement this model, apply it to information afterwards 2005 as well as to to a greater extent than currency pairs, to honour out if in that location is actually something here. In fact, this is the argue why I prefer to read older papers - to permit for the possibility of truthful out-of-sample tests immediately.

What exercise you lot scream back tin laissez passer on notice last done to improve this model? I suspect that equally a origin step, 1 tin laissez passer on notice come across whether the estimated Markov states stand upward for reasonably to what traders scream back of equally risk-on vs risk-off regimes. If they do, as well as thence regardless of the usage of this model equally a signal generator, it tin laissez passer on notice at to the lowest degree generate good risk indicators. If not, as well as thence perchance the hidden Markov model postulate to last replaced amongst a Markov model that is conditioned on observable indicators.

Sabtu, 26 Mei 2007

High-Frequency Trading Inward The Unusual Central Market

This is the championship of a report published past times the Bank of International Settlements (which serves key banks roughly the world) inwards September 2011. As a Forex trader myself, I of course peruse it amongst dandy involvement hoping to glimpse whatever is the state-of-the-art. Here are a few interesting nuggets, together amongst my commentary:

1) FX HFT travel amongst a latency of less than 1 ms, spell nearly of us mere algorithmic traders typically endure a latency of at to the lowest degree 10ms.  For example, Interactive Brokers does non withal furnish collocation facilities for its customers, too then the best nosotros tin produce is to house our trading servers on the cyberspace backbone unopen to its Stamford, CT, location. The best round-trip ping fourth dimension is 10ms. Those who merchandise amongst FXCM may cause got a improve run a hazard for lower latency, equally they furnish free collocation to their clients. Those who merchandise on the ECN FXall tin collocate at their Equinix information center, spell FCM360 provides collocation service to EBS traders. I cannot honor whatsoever collocation service for Hotspot FX or Currenex. If you lot know of such services, or FX brokers who furnish collocation, produce exit a comment!

2) HFT typically travel inwards markets amongst high liquidity too depression volatility. The one-time is non surprising, since markets amongst depression liquidity has few counter-parties to accept payoff of. The latter requires a fleck of nuance. I retrieve nearly HFT would produce goodness from high volatility inwards a mean-reverting market, simply unfortunately high volatility is ordinarily correlated amongst marketplace inwards a gratuitous fall. So don't live on surprised if you lot honor that HFT-provided liquidity all of a abrupt disappears when the marketplace is inwards stress, though the BIS written report stated that they are equally good quick to re-enter the marketplace in 1 trial the turmoil is over.

3) As a corollary of 2), HFT to a greater extent than oft than non merchandise inwards the major currency pairs. But increasingly, NZD too MXN cause got drawn many automated too HF traders.

4) Almost past times definition, the bid/ask quotes placed past times HFT tend to remain on the mass for a really brusk time, measured inwards ms, unless forced past times the telephone commutation to rest longer. EBS too Reuters both has minimum quote life or minimum create amount ratio. One telephone commutation that does not have such minimums is Currenex, which is hence specially attractive to HF trading. Hence if you lot are non a HF player, too produce non wishing to live on taken payoff of  by a HF player, live on wary of Currenex!

5) Two of the favourite categories of HFT strategies: triangle arbitrage too liquidity-redistribution (taking payoff of pricing discrepancies across dissimilar trading platforms.) Despite the bad reputation HFTers cause got been acquiring inwards the concluding few years, I retrieve they produce furnish a useful service to other algo traders similar myself via these ii strategies. It is a hassle to give-up the ghost on looking for a improve broker/prices for your strategy!