001    /**
002     * Copyright 2007 Mike Kroutikov.
003     *
004     * This program is free software; you can redistribute it and/or modify
005     *   it under the terms of the Lesser GNU General Public License as 
006     *   published by the Free Software Foundation; either version 3 of
007     *   the License, or (at your option) any later version.
008     *
009     *   This program is distributed in the hope that it will be useful,
010     *   but WITHOUT ANY WARRANTY; without even the implied warranty of
011     *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
012     *   Lesser GNU General Public License for more details.
013     *
014     *   You should have received a copy of the Lesser GNU General Public License
015     *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
016     *   
017     *   Derived from code developed by Opentick Corporation, http://www.opentick.com.
018     */
019    
020    package org.otfeed.event;
021    
022    import static org.otfeed.event.IdentityUtil.equalsTo;
023    import static org.otfeed.event.IdentityUtil.safeCompare;
024    import static org.otfeed.event.IdentityUtil.safeHashCode;
025    
026    import java.io.Serializable;
027    
028    /**
029     * Provides Equity Initialize information.
030     * This is information about a company and its stock. 
031     */
032    public final class OTEquityInit implements Comparable<OTEquityInit>, Serializable {
033     
034            private static final long serialVersionUID = -2370048578021455014L;
035            
036            private String currency;
037        private InstrumentEnum instrumentType;
038        private String company;
039        private double prevClosePrice;
040        private String prevCloseDate;   // FIXME: textual date. this is bad!
041        private double annualHighPrice;
042        private String annualHighDate;  // FIXME: textual date. this is bad!
043        private double annualLowPrice;
044        private String annualLowDate;   // FIXME: textual date. this is bad!
045        private double earningsPrice;
046        private String earningsDate;    // FIXME: textual date. this is bad!
047        private long totalShares;
048        private long averageVolume;
049        private String CUSIP;
050        private String ISIN;
051        private boolean isUPC11830;
052        private boolean isSmallCap;
053        private boolean isTestIssue;
054    
055        /**
056         * Default constructor.
057         */
058        public OTEquityInit() { }
059    
060        /**
061         * Constructor.
062         * @param currency Currency.
063         * @param type      Instrument type.
064         * @param company Company name.
065         * @param prevClosePrice Previous close price.
066         * @param prevCloseDate     Previous close date.
067         * @param annualHighPrice Annual high price. 
068         * @param annualHighDate  Annual high date.
069         * @param annualLowPrice Annual low price.
070         * @param annualLowDate Annual low date.
071         * @param earningsPrice Earnings price.
072         * @param earningsDate Earnings date.
073         * @param totalShares Total shares.
074         * @param averageVolume Average volume.
075         * @param CUSIP CUSIP number.
076         * @param ISIN      International Securities Identification Number, or ISIN.
077         * @param isUPC11830 Notes whether Nasdaq flagged as UPC11830.
078         * @param isSmallCap Notes whether it is a Nasdaq Small Cap.
079         * @param isTestIssue Notes whether it is a known test symbol.
080         */
081        public OTEquityInit(
082                            String currency,
083                            InstrumentEnum type,
084                            String company,
085                            double prevClosePrice,
086                            String prevCloseDate,
087                            double annualHighPrice,
088                            String annualHighDate,
089                            double annualLowPrice,
090                            String annualLowDate,
091                            double earningsPrice,
092                            String earningsDate,
093                            long totalShares,
094                            long averageVolume,
095                            String CUSIP,
096                            String ISIN,
097                            boolean isUPC11830,
098                            boolean isSmallCap,
099                            boolean isTestIssue) {
100            this.currency = currency;
101            this.instrumentType = type;
102            this.company = company;
103            this.prevClosePrice = prevClosePrice;
104            this.prevCloseDate = prevCloseDate;
105            this.annualHighPrice = annualHighPrice;
106            this.annualHighDate = annualHighDate;
107            this.annualLowPrice = annualLowPrice;
108            this.annualLowDate = annualLowDate;
109            this.earningsPrice = earningsPrice;
110            this.earningsDate = earningsDate;
111            this.totalShares = totalShares;
112            this.averageVolume = averageVolume;
113            this.CUSIP = CUSIP;
114            this.ISIN = ISIN;
115            this.isUPC11830 = isUPC11830;
116            this.isSmallCap = isSmallCap;
117            this.isTestIssue = isTestIssue;
118        }
119    
120        /**
121         *
122         * @return Currency.
123         */
124        public String getCurrency() {
125            return currency;
126        }
127    
128        /**
129         * Sets currency.
130         * @param currency Currency.
131         */
132        public void setCurrency(String currency) {
133            this.currency = currency;
134        }
135    
136        /**
137         * 
138         * @return     Instrument type.
139         */
140        public InstrumentEnum getInstrumentType() {
141            return instrumentType;
142        }
143    
144    
145        /**
146         * Sets instrument type.
147         * @param type      Instrument type.
148         */
149        public void setInstrumentType(InstrumentEnum type) {
150            this.instrumentType = type;
151        }
152    
153        /**
154         * 
155         * @return Company name.
156         */
157        public String getCompanyName() {
158            return company;
159        }
160    
161        /**
162         * Sets company name. 
163         * @param company Company name.
164         */
165        public void setCompanyName(String company) {
166            this.company = company;
167        }
168    
169        /**
170         * 
171         * @return     Previous close price.
172         */
173        public double getPrevClosePrice() {
174            return prevClosePrice;
175        }
176    
177        /**
178         * Sets previous close price.
179         * @param prevClosePrice    Previous close price.
180         */
181        public void setPrevClosePrice(double prevClosePrice) {
182            this.prevClosePrice = prevClosePrice;
183        }
184    
185        /**
186         *
187         * @return Previous close date: YYYYMMDD or 8 spaces if not provided.
188         */
189        public String getPrevCloseDate() {
190            return prevCloseDate;
191        }
192    
193        /**
194         * Sets previous close date.
195         * @param prevCloseDate Previous close date.
196         */
197        public void setPrevCloseDate(String prevCloseDate) {
198            this.prevCloseDate = prevCloseDate;
199        }
200    
201        /**
202         * 
203         * @return Annual high price.
204         */
205        public double getAnnualHighPrice() {
206            return annualHighPrice;
207        }
208    
209        /**
210         * Sets annual high price.
211         * @param annualHighPrice Annual high price.
212         */
213        public void setAnnualHighPrice(double annualHighPrice) {
214            this.annualHighPrice = annualHighPrice;
215        }
216    
217        /**
218         * 
219         * @return Annual high date: YYYYMMDD or 8 spaces if not provided.
220         */
221        public String getAnnualHighDate() {
222            return annualHighDate;
223        }
224    
225        /**
226         * Sets annual high date.
227         * @param annualHighDate Annual high date.
228         */
229        public void setAnnualHighDate(String annualHighDate) {
230            this.annualHighDate = annualHighDate;
231        }
232    
233        /**
234         * 
235         * @return Annual low price.
236         */
237        public double getAnnualLowPrice() {
238            return annualLowPrice;
239        }
240    
241        /**
242         * Sets annual low price.
243         * @param annualLowPrice Annual low price.
244         */
245        public void setAnnualLowPrice(double annualLowPrice) {
246            this.annualLowPrice = annualLowPrice;
247        }
248    
249        /**
250         *
251         * @return     Annual low date: YYYYMMDD or 8 spaces if not provided.
252         */
253        public String getAnnualLowDate() {
254            return annualLowDate;
255        }
256    
257        /**
258         * Sets annual low date.
259         * @param annualLowDate Annual low date.
260         */
261        public void setAnnualLowDate(String annualLowDate) {
262            this.annualLowDate = annualLowDate;
263        }
264    
265        /**
266         *
267         * @return Earnings price (earnings per share).
268         */
269        public double getEarningsPrice() {
270            return earningsPrice;
271        }
272    
273        /**
274         * Sets earnings price.
275         * @param earningsPrice Earnings price.
276         */
277        public void setEarningsPrice(double earningsPrice) {
278            this.earningsPrice = earningsPrice;
279        }
280    
281        /**
282         * 
283         * @return Earnings date: YYYYMMDD or 8 spaces if not provided.
284         */
285        public String getEarningsDate() {
286            return earningsDate;
287        }
288    
289        /**
290         * Sets earnings date.
291         * @param earningsDate Earnings date.
292         */
293        public void setEarningsDate(String earningsDate) {
294            this.earningsDate = earningsDate;
295        }
296    
297        /**
298         * 
299         * @return Total shares.
300         */
301        public long getTotalShares() {
302            return totalShares;
303        }
304    
305        /**
306         * Sets total shares.
307         * @param totalShares Total shares.
308         */
309        public void setTotalShares(long totalShares) {
310            this.totalShares = totalShares;
311        }
312    
313        /**
314         * 
315         * @return Average volume.
316         */
317        public long getAverageVolume() {
318            return averageVolume;
319        }
320    
321        /**
322         *  Sets average volume.
323         * @param averageVolume Average volume.
324         */
325        public void setAverageVolume(long averageVolume) {
326            this.averageVolume = averageVolume;
327        }
328    
329        /**
330         *
331         * @return CUSIP number.
332         */
333        public String getCUSIP() {
334            return CUSIP;
335        }
336    
337        /**
338         * Sets CUSIP number.
339         * @param CUSIP CUSIP number.
340         */
341        public void setCUSIP(String CUSIP) {
342            this.CUSIP = CUSIP;
343        }
344    
345        /**
346         *
347         * @return International Securities Identification Number, or ISIN.
348         */
349        public String getISIN() {
350            return ISIN;
351        }
352    
353        /**
354         * Sets International Securities Identification Number, or ISIN.
355         * @param ISIN International Securities Identification Number, or ISIN.
356         */
357        public void setISIN(String ISIN) {
358            this.ISIN = ISIN;
359        }
360    
361        /**
362         *
363         * @return Notes whether Nasdaq flagged as UPC11830. 
364         */
365        public boolean isUPC11830() {
366            return isUPC11830;
367        }
368    
369        /**
370         * Adds UPC118300 bit.
371         * @param isUPC11830 sUPC11830      Notes whether Nasdaq flagged as UPC11830.
372         */
373        public void setUPC11830(boolean isUPC11830) {
374            this.isUPC11830 = isUPC11830;
375        }
376    
377        /**
378         * 
379         * @return Notes whether it is a Nasdaq Small Cap.
380         */
381        public boolean isSmallCap() {
382            return isSmallCap;
383        }
384    
385        /**
386         * Adds Small Cap bit.
387         * @param isSmallCap Notes whether it is a Nasdaq Small Cap.
388         */
389        public void setSmallCap(boolean isSmallCap) {
390            this.isSmallCap = isSmallCap;
391        }
392    
393        /**
394         *
395         * @return Notes whether it is a known test symbol.
396         */
397        public boolean isTestIssue() {
398            return isTestIssue;
399        }
400    
401        /**
402         * Adds test symbol bit.
403         * @param isTestIssue Notes whether it is a known test symbol.
404         */
405        public void setTestIssue(boolean isTestIssue) {
406            this.isTestIssue = isTestIssue;
407        }
408    
409        @Override
410            public String toString() {
411            return "OTEquityInit: currency=" + currency 
412            + ", instrumentType=" + instrumentType 
413                    + ", company=" + company 
414                    + ", prevClosePrice=" + prevClosePrice 
415                    + ", prevCloseDate=" + prevCloseDate 
416                    + ", annualHighPrice=" + annualHighPrice 
417                    + ", annualHighDate=" + annualHighDate 
418                    + ", annualLowPrice=" + annualLowPrice 
419                    + ", annualLowDate=" + annualLowDate 
420                    + ", earningsPrice=" + earningsPrice 
421                    + ", earningsDate=" + earningsDate 
422                    + ", totalShares=" + totalShares 
423                    + ", averageVolume=" + averageVolume 
424                    + ", CUSIP=" + CUSIP 
425                    + ", ISIN=" + ISIN 
426                    + ", isUPC11830=" + isUPC11830 
427                    + ", isSmallCap=" + isSmallCap 
428                    + ", isTestIssue=" + isTestIssue;
429        }
430    
431        @Override
432            public int hashCode() {
433            return safeHashCode(currency) 
434                    + 3 * safeHashCode(instrumentType) 
435                    + 5 * safeHashCode(company) 
436                    + 7 * safeHashCode(prevClosePrice) 
437                    + 11 * safeHashCode(prevCloseDate) 
438                    + 13 * safeHashCode(annualHighPrice) 
439                    + 17 * safeHashCode(annualHighDate) 
440                    + 19 * safeHashCode(annualLowPrice) 
441                    + 23 * safeHashCode(annualLowDate) 
442                    + 29 * safeHashCode(earningsPrice) 
443                    + 31 * safeHashCode(earningsDate) 
444                    + 41 * safeHashCode(totalShares) 
445                    + 47 * safeHashCode(averageVolume) 
446                    + 53 * safeHashCode(CUSIP) 
447                    + 61 * safeHashCode(ISIN) 
448                    + 83 * safeHashCode(isUPC11830) 
449                    + 113 * safeHashCode(isSmallCap) 
450                    + 119 * safeHashCode(isTestIssue); 
451        }
452            
453        @Override
454            public boolean equals(Object o) {
455            return equalsTo(this, o);
456        }
457        
458            public int compareTo(OTEquityInit other) {
459                    int rc;
460    
461                    if((rc = safeCompare(currency, other.currency)) != 0) {
462                            return rc;
463                    }
464                    
465                    if((rc = safeCompare(instrumentType, other.instrumentType)) != 0) {
466                            return rc;
467                    }
468    
469                    if((rc = safeCompare(company, other.company)) != 0) {
470                            return rc;
471                    }
472    
473                    if((rc = safeCompare(prevClosePrice, other.prevClosePrice)) != 0) {
474                            return rc;
475                    }
476    
477                    if((rc = safeCompare(annualHighPrice, other.annualHighPrice)) != 0) {
478                            return rc;
479                    }
480                    
481                    if((rc = safeCompare(annualHighDate, other.annualHighDate)) != 0) {
482                            return rc;
483                    }
484    
485                    if((rc = safeCompare(annualLowPrice, other.annualLowPrice)) != 0) {
486                            return rc;
487                    }
488                    
489                    if((rc = safeCompare(annualLowDate, other.annualLowDate)) != 0) {
490                            return rc;
491                    }
492    
493                    if((rc = safeCompare(earningsPrice, other.earningsPrice)) != 0) {
494                            return rc;
495                    }
496    
497                    if((rc = safeCompare(earningsDate, other.earningsDate)) != 0) {
498                            return rc;
499                    }
500                    
501                    if((rc = safeCompare(totalShares, other.totalShares)) != 0) {
502                            return rc;
503                    }
504    
505                    if((rc = safeCompare(averageVolume, other.averageVolume)) != 0) {
506                            return rc;
507                    }
508    
509                    if((rc = safeCompare(CUSIP, other.CUSIP)) != 0) {
510                            return rc;
511                    }
512    
513                    if((rc = safeCompare(ISIN, other.ISIN)) != 0) {
514                            return rc;
515                    }
516    
517                    if((rc = safeCompare(isUPC11830, other.isUPC11830)) != 0) {
518                            return rc;
519                    }
520    
521                    if((rc = safeCompare(isSmallCap, other.isSmallCap)) != 0) {
522                            return rc;
523                    }
524    
525                    if((rc = safeCompare(isTestIssue, other.isTestIssue)) != 0) {
526                            return rc;
527                    }
528    
529                    return 0;
530            }
531    }