The Penn-Lehman Automated Trading Project

The Penn-Lehman Automated Trading Project Participants Lawrence Sohn [email protected] Hahn Bak [email protected] Faculty Advisor Michael Kearns...
Author: Jack Hoover
23 downloads 1 Views 207KB Size
The Penn-Lehman Automated Trading Project

Participants Lawrence Sohn [email protected] Hahn Bak [email protected] Faculty Advisor Michael Kearns [email protected]

ABSTRACT Billions of dollars change hands throughout the course of every business day on Wall Street. At the basic foundation of this elaborate system of financial institutions are traders, whose strategies can determine the profitability of their respective firms. Prior to implementation, these strategies must be tested on simulated exchanges in order to evaluate potential success for obvious reasons of capital and risk exposure that would be necessary to conduct such experiments on actual exchanges. The Penn-Lehman Automated Trading (“PLAT”) Project provides a framework called the Penn Exchange Simulator (“PXS”) that realistically simulates an exchange by combining real-time market data with automated client orders. All major Wall Street broker-dealers currently maintain backtesting environments in which trading strategies can be tested based primarily on price information. The uniqueness of PXS stems from the fact that it is based primarily on order books, which keep track of current limit order data. This adds a new level of realism to the automated trading platform and increases the accuracy of the associated algorithms and strategies. The PLAT project is structured in a way that multiple pools of automated trading teams, or clients, compete against one another in the PXS market. The clients develop automated trading strategies that maximize their returns by taking both long and short positions while maintaining a balance between risk and return. Automated trading strategy performance is measured on the basis of profitability, robustness, and good trading practices. As PLAT competitions have been simulated in past years, the clients must execute their strategies under the imposed limits: a single security may be traded over the course of ten business days within a window of ±100,000 shares. Our objective

is to develop an automated trading strategy that will maximize such performance statistics given any number of market conditions. In developing such a strategy, we will examine the assumptions underlying the various strategies of the past and determine the necessary conditions for their success and a way to consistently outperform such strategies.

RELATED WORK A series of market trading strategies are based on price movement trend prediction. These strategies each calculate their own threshold where if the current price of the stock increases past this threshold then the strategy dictates to buy, and to sell if the price decreases past the threshold. The motivation behind these actions is that when the price of the stock crosses the strategy-determined threshold, it is perceived as an indicator that the price will follow a trend moving in that direction. Therefore, if the price is determined to be increasing, these strategies will buy, and sell if the price is determined to be decreasing. These strategies use the stock price to predict price movement. The Moving Average strategy uses the moving average statistic as its threshold, which is the average price of the stock over an interval of time. The Channel Breakouts strategy records the highest price and lowest price over an interval of time, and so whenever the price increases beyond the interval high it will buy shares predicting an upward price movement trend. The Momentum strategy looks at the general movement of the stock price by comparing the current price with the price of the stock at a certain amount of time before. A higher current price expresses upward movement, and a lower current price expresses downward movement. The technical analysis statistics that these

strategies use to determine their thresholds are known to be useful to the stock trader, but their simple derived trading strategies prove to be weak compared to other strategies when simulated on PXS. A reverse strategy has proven to be strong in PXS simulations. It does the opposite of the price movement prediction strategies in that when it predicts an upward trend in price, it sells instead of buys. The reason why the reverse strategy fares better than the trend prediction strategies is that the market rarely follows trends uniformly. It seems that trend prediction based on price alone is very weak in the short-term, and that price volatility and order book data are much more pervasive factors in the scope of the PLAT project. The Relative Strength Index, a value between zero and one hundred, is an indicator of strength of the stock compared to its past performance. A higher RSI means that the average of upward price change is greater than the average of downward price change, and speculates that the market has topped off. The RSI-based strategy will therefore sell when the RSI value decreases past a certain high value, as this indicates that the price will decrease. RSI predicts price movement without considering general price trends, but still performs poorly in PXS simulations against other standard strategies. The Market Making Agent takes a volatility-based approach rather than the typical predictive pricing approach. Rather than attempting to predict the future direction of the stock price movement, the Market Making Agent exploits the fluctuations of up and down movements by simultaneously placing buy and sell orders of equal volume, the buy order below the current price by some amount and the sell order above by some amount. Intuitively, this makes sense since, in a sufficiently volatile price environment,

when the buy price is matched the agent buys in and when the sell price is matched the agent neutralizes the buy order volume, in an attempt to achieve market neutral arbitrage. Each time the pair is matched, the agent earns the associated spread. In order to adjust for large one-way trends, the Market Making Agent incorporates both price and volume controls, adjusting those values to alleviate such asymmetric scenarios. The Static Order Book Imbalance Agent is a relatively simple algorithm based on the buy and sell order book data from the Island ECN. It analyzes the disparity between the limit order distributions, quantified by the volume weighted average price from the respective books. The agent compares the spread between the volume weighted average price of the limit order books and the current price, with respect to the buy and sell order books. Based on a parameter, theta, if buy spreads are relatively higher than sell spreads, a sell order is placed. If sell spreads are relatively higher, then a buy order is placed. This makes sense because tighter spreads indicate lower demand and if the order books exhibit relatively tighter sell spreads, for example, there is a higher probability that these trades will be matched and thus the price would decrease. This agent would take advantage of this probability and sell accordingly.

TECHNICAL APPROACH Our technical approach is straightforward and has been outlined by the PennLehman Automated Trading Project. We will be implementing an automated trading client strategy in the Unix environment. The PLAT Project provides us with a client API which consists of those functions necessary to track applicable trading data as well as the overall market state and to execute all trading functions in real-time, as the PXS is

continuously updated. Our client program will monitor the market data and send API commands, such as buyOrder(), sellOrder(), and withdraw(), to the server at appropriate times by way of our strategy. The primary objective of the PLAT Project is to design and implement an automated trading agent based on a strategy that outperforms both the market and all other such strategies. In order to research the ideal strategy, we first established for ourselves a background in finance as relevant to trading strategy. With this foundation in place, we examined the provided five basic trading agents: Moving Average, Channel Breakouts, Momentum, Relative Strength Index, and Market Making. Using a variety of normal distributions for price environments, we ran all the possible permutations of pairs in direct competition with one another, along with a set of MM (vs MA) Distribution 2

self-competing agents. Upon thorough examination of all the strategy pairs, we came to the conclusion that the Market Making Agent was the dominant strategy in this strategy pool.

From this foundation, we expanded to the analysis of the most pertinent examples: last year’s participant strategies. Since we have access to the results of actual simulation, it is relatively apparent to see which strategies dominated the competition. As it turns out, the strategies based on Static Order Book Imbalance seemed to perform the best and it seems accurate that this is the case. The SOBI methodology makes the fullest use of the available limit order books, the unique characteristic of the project. It also seemed like the most logical predictor of price trends, taking into account actual limit orders, rather

MM (vs. MyTrader) 12/01/04

than simply past price movements. After

MyTrader (vs. MM) 12/01/04

SOBI (vs. MyTrader) 12/01/04

experimenting with a number of variations of both the Market Making Agent and the SOBI Agent, as well as various combinations with the basic strategies, we decided to focus on the SOBI approach. The original algorithm based its decisions on the spread between the last price and the volume weighted average price for both the buy and sell order books. We decided to focus specifically on the total matched buy volume and total matched sell volume at each instant of comparison. The basic theory behind this design is founded on the assumption that a higher matched buy volume relative to sell volume indicates a relatively higher demand for the stock and thus a likely indicator of a subsequent price increase. Conversely, a higher matched sell volume relative to buy volume indicates a relatively lower demand for the stock and thus a likely indicator of a subsequent price decrease. If the matched buy volume equals the matched sell volume, we decided to institute the market making strategy. Our previous strategy did not account for this scenario. The relevant source code is shown below:

int updateAgentOrder (ClientState *cState, MarketState *mState, MarketStatistics *pxsStat, MarketStatistics *iStat, Strategy *myStrategy)

{ int currentShare = 0; float currentValue = getSimPresentValue(cState); float currentPrice = getSimLastPrice(mState); float qvalue = 0; float* currentBid = NULL; float* currentAsk = NULL; int* OrderRef = NULL; int j = 0; int NumbOfOrder = 0; float lastPrice; simTime_t currentTime = 0; int NumbOfBuyOrder = 0; int NumbOfSellOrder = 0; int* BuyOrderShare = NULL; int* SellOrderShare = NULL; int TotalBuyShare = 0; int TotalSellShare = 0; int flag = 0; // SET this variable at some point during the execution of the automated strategy below to 1 IF an order is placed; otherwise SET it to 0 float Si, Bi, Si2, Bi2; currentTime = simTime(mState, NULL); lastPrice = getSimLastPrice(mState); if(currentTime myStrategy->theta) { /* if *buy-side* volume larger than *sell-side* volume by more than theta */ /* place a *buy* order for orderVolume shares at orderPrice dollars *below* lastPrice */ buyOrder(lastPrice-myStrategy->orderPrice, myStrategy->orderVolume, cState, mState); printf("buyOrder placed at [%.4f]\n", lastPrice-myStrategy->orderPrice); /* if hedging, also place a *sell* order for orderVolume shares at hegdeOrderPrice dollars *above* lastPrice */ if (myStrategy->hedgeFlag) { sellOrder(lastPrice+myStrategy->hedgeOrderPrice, myStrategy->orderVolume, cState, mState); printf("hedging sellOrder placed at [%.4f]\n", lastPrice+myStrategy>hedgeOrderPrice); } /* set flag to signal an order has been placed */ flag = 1; } else if ((Si - Bi) > myStrategy->theta) { /* if *sell-side* difference larger than *buy-side* difference by more than theta dollars */ /* place a *sell* order for orderVolume shares at orderPrice dollars *above* lastPrice */ if(lastPrice > 0) { sellOrder(lastPrice+myStrategy->orderPrice, myStrategy->orderVolume, cState, mState); printf("sellOrder placed at [%.4f]\n", lastPrice+myStrategy->orderPrice);

/* if hedging, also place a *buy* order for orderVolume shares at hegdeOrderPrice dollars *below* lastPrice */ if (myStrategy->hedgeFlag) { buyOrder(lastPrice - myStrategy->hedgeOrderPrice, myStrategy->orderVolume, cState, mState); printf("hedging buyOrder placed at [%.4f]\n", lastPrice-myStrategy->hedgeOrderPrice); } /* set flag to signal an order has been placed */ flag = 1; } } else if (Bi == Si) { /* set difference between current price and volume weighted price for quartile */ Bi2 = lastPrice - getBuyQuartile(mState, pxsStat, myStrategy->quartile); /* set difference between current price and volume weighted price for quartile */ Si2 = getSellQuartile(mState, pxsStat, myStrategy->quartile) - lastPrice; printf("Bi: %f Si: %f\n", Bi2, Si2); if ((Si2 - Bi2) > myStrategy->theta2) { /* if *sell-side* difference larger than *buy-side* difference by more than theta dollars */ /* place a *buy* order for orderVolume shares at orderPrice dollars *below* lastPrice */ buyOrder(lastPrice-myStrategy->orderPrice, myStrategy->orderVolume, cState, mState); printf("buyOrder placed at [%.4f]\n", lastPrice-myStrategy->orderPrice); /* if hedging, also place a *sell* order for orderVolume shares at hegdeOrderPrice dollars *above* lastPrice */ if (myStrategy->hedgeFlag) { sellOrder(lastPrice+myStrategy->hedgeOrderPrice, myStrategy->orderVolume, cState, mState); printf("hedging sellOrder placed at [%.4f]\n", lastPrice+myStrategy>hedgeOrderPrice); } /* set flag to signal an order has been placed */ flag = 1; } else if ((Bi2 - Si2) > myStrategy->theta2) { /* if *buy-side* difference larger than *sell-side* difference by more than theta dollars */ /* place a *sell* order for orderVolume shares at orderPrice dollars *above* lastPrice */ if(lastPrice > 0) { sellOrder(lastPrice+myStrategy->orderPrice, myStrategy->orderVolume, cState, mState); printf("sellOrder placed at [%.4f]\n", lastPrice+myStrategy->orderPrice); /* if hedging, also place a *buy* order for orderVolume shares at hegdeOrderPrice dollars *below* lastPrice */ if (myStrategy->hedgeFlag) { buyOrder(lastPrice - myStrategy->hedgeOrderPrice, myStrategy->orderVolume, cState, mState); printf("hedging buyOrder placed at [%.4f]\n", lastPrice-myStrategy->hedgeOrderPrice); } /* set flag to signal an order has been placed */ flag = 1; } } } }

RESOURCES REQUIRED Since this project is strictly code-based, we will need to connect to a remote Unix server to implement our strategy. The provided PXS API documentation is all that is needed to write all our source code. Designing our strategy, however, will prove to require a considerable amount of research. We will need to gain a fundamental understanding of market microstructure, as well as many algorithms, including basic models and those algorithms used currently and in the past. Analysis of past PLAT competitions and research articles will be the bulk of our research. The Wharton School will also prove to be a valuable resource since it is an epicenter of financial research of education. There is a tremendous amount of resources available to us, from the Lippincott library to professors with similar research interests. Other sources of information will be evinced as we delve deeper into the research process. A great deal of the available literature on equity trading strategy is based on valuation. While this is a valuable concept, it is not as useful to the PLAT Project, as the competitions involve transactions of a single preset stock. In fact, much of the research on stock price forecasting and trading strategy is not directly applicable to automated trading strategy. However, the basic concepts put forth contribute valuable background on fundamental financial principles and, albeit indirectly, contribute to both the understanding of current trading agents as well as the formulation of a new strategy. For example, the Static Order Book Imbalance strategy is explained in a high-level fashion on the website dedicated to it (http://www.cis.upenn.edu/~mkearns/projects/sobi.html), but some of the literature dedicates an entire chapter to the theory (Lo and MacKinlay 378)

TIMETABLE Completed? September – November Project orientation Account setup Initial research – fundamental finance concepts Further research – algorithmic approaches Begin Implementation Strategy testing December Initial prototype finalized First Competition Analysis of results January – March Further research using result analysis Revision of strategy Re-implementation April Complete final version of client Final competition CONCLUSION In formulating our strategy, we made the assumption that the objective of the project was to develop an algorithm that could feasibly be used regularly as a trading strategy by an investment bank. While we considered strategies that would distort this microcosm of a market (not a difficult task), we decided this would be against the spirit of the project. Ultimately, another group exploited this fact and thereby won out. In addition, some of the strategy we added in an attempt to repair former problems seem to have caused other problems, one of which was not testing for artificial excess volatility.

Though we are now graduating, we plan to informally continue our project and to research more on optimal equity trading strategy. While we may not have found that strategy just yet, we feel that we have learned a great deal this year not only about the technical aspects of Wall Street but also the about the underlying financial theory.

REFERENCES Blau, William. Momentum, Direction, and Divergence. New York City, NY. John Wiley & Sons, Inc. 1995. Cragg, John G. and Malkiel, Burton G. Expectations and the Structure of Share Prices. Chicago, IL. The University of Chicago Press, 1982. Feng, Yi, Yu Ronggang, and Stone, Peter. Two Stock-Trading Agents: Market Making and Technical Analysis. 2003. Grossman, Sanford J. The Informational Role of Prices. Cambridge, MA. Massachusetts Institute of Technology Press. 1989. Kearns, Michael and Ortiz, Luis. The Penn-Lehman Automated Trading Project. IEEE Intelligent Systems. November/December 2003. Kearns, Michael and Ortiz, Luis. The Penn-Lehman Automated Trading Project (Extended Version). 2003. Kearns, Michael and Ortiz, Luis. The Penn-Lehman Automated Trading Project: 200405. Levy, Robert A. The Relative Strength Concept of Common Stock Price Forecasting. Larchmont, NY. Investors Intelligence, Inc., 1968. Lo, Andrew W. and MacKinlay, Craig A. A Non-Random Walk Down Wall Street. Princeton, NJ. Princeton University Press, 1999. Rossi, Peter E. Modeling Stock Market Volatility. San Diego, CA. Academic Press, Inc., 1996. Shiller, Robert J. Market Volatility. Cambridge, MA. Massachusetts Institute of Technology Press. 1989.

Suggest Documents