Message-ID: <7763737.1075840783924.JavaMail.evans@thyme> Date: Sun, 13 Jan 2002 18:13:45 -0800 (PST) From: vkaminski@aol.com To: j.kaminski@enron.com Subject: Fwd: Doc Draft Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-From: VKaminski@aol.com@ENRON X-To: Kaminski, Vince J X-cc: X-bcc: X-Folder: \vkamins\Inbox X-Origin: KAMINSKI-V X-FileName: vincent kaminski 1-30-02.pst Content-Transfer-Encoding: 7bit Return-Path: Received: from rly-xf01.mx.aol.com (rly-xf01.mail.aol.com [172.20.105.225]) by air-xf01.mail.aol.com (v82.22) with ESMTP id MAILINXF17-0113205551; Sun, 13 Jan 2002 20:55:51 1900 Received: from sm14.texas.rr.com (sm14.texas.rr.com [24.93.35.41]) by rly-xf01.mx.aol.com (v83.18) with ESMTP id MAILRELAYINXF15-0113205539; Sun, 13 Jan 2002 20:55:39 1900 Received: from [192.168.1.101] (cs662537-99.houston.rr.com [66.25.37.99]) by sm14.texas.rr.com (8.12.0.Beta16/8.12.0.Beta16) with ESMTP id g0E1vPu3014816 for ; Sun, 13 Jan 2002 19:57:25 -0600 Subject: Doc Draft From: Vince Kaminski To: VKaminski@aol.com Content-Type: text/plain X-Mailer: Evolution/1.0 (Preview Release) Date: 13 Jan 2002 19:55:16 -0600 Message-Id: <1010973316.1635.2.camel@localhost.localdomain> Mime-Version: 1.0 The application takes as input the name of a file containing a stocks trading history. The first line of the file has the stocks symbol, the second a human-readable description of each quotes fields (This comes from the format used by Yahoo! Finance and is simply skipped by the application), and the remaining lines are quotes, starting with the most recent, in the form: --,,,,, Where, == Day of the month (1-31) == Three-letter abbreviation of the months name == Two-digit representation of the year (The rest are self-explainatory) Example: AAPL Date,Open,High,Low,Close,Volume 31-Dec-01,22.51,22.66,21.83,21.90,2460400 28-Dec-01,21.97,23,21.96,22.43,5341500 27-Dec-01,21.58,22.25,21.58,22.07,3419800 26-Dec-01,21.35,22.30,21.14,21.49,2614300 24-Dec-01,20.90,21.45,20.90,21.36,904100 21-Dec-01,21.01,21.54,20.80,21,4577400 20-Dec-01,21.40,21.47,20.62,20.67,3944000 --------8<--------- 10-Jan-91,22.875,23.625,22.875,23.5625,3886800 9-Jan-91,22.125,23,21.875,22.625,4172000 8-Jan-91,21.875,21.9375,21.25,21.625,1952600 7-Jan-91,21.50,22.625,21.50,21.625,2775000 4-Jan-91,21.50,22.125,21.50,21.625,1263600 3-Jan-91,21.75,22.125,21.50,21.50,1340900 2-Jan-91,21.375,22,21,21.75,1383800 Adapting the application to use different formats is trivial. In its current form the analysis is quite simple. A stochasitic (fast or slow, with abritrary periods) is computed from the stocks data (see below for a more detailed description). Next, the stock data searched for Japanese Candlestick patterns (see below). The actual analysis consists of simulating several years of trading (here ten years). Each is stochastic and candlestick data is examined. If the days candlestick is a hammer and the %k is above a pre-defined value, a buy signal is triggered. Likewise, if the days candlestick is a hanging man and the %k is below a second pre-defined value, a sell signal is triggered. When simulating a buy, a long position of a constant number of shares is opened if long positions already exist or if no positions exist. If there are open short positions, each of these is closed. Likewise, when simulating a sell, a short position of the same constant number of shares is opened if short positions already exist or if no positions exist. If there are open long positions, each of these is closed. When closing a position, the rate-of-return and annualize rate-of-return are calculated. For both long and short positions: sale cost - purchase cost RoR = ------------------------- purchase cost (a better method is needed for shorts) and, 365 -------------------- Duration of Position Annualized RoR = (RoR + 1.0) - 1.0 Stochastics: (Todays Close - Lowest Low for kN Periods) %k = --------------------------------------------------------- Highest High for kN Periods - Lowest Low for kN Periods) %p = Simple Moving Average of %k for pN Periods (Where the lowest low is chosen from amongst the lows field and the highest high is chosen from amongst the high field.) This is a fast-stochastic. When computing a slow stochastic, %k is replaced with its 3-day Simple Moving Average. %p is then calculated from this value. Japanese Candlesticks: The application currently searches the data for the Hanging Man and Hammer patterns. A Hanging Man is defined as very short top-shadow, medium body, and long bottom-shadow. The ratios are adjustable. A Hammer is a Hanging Man where the days close is higher than the open. -- Vince Kaminski vincek@cs.stanford.edu