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    import org.otfeed.command.OptionTypeEnum;
029    
030    /**
031     * This class provides an Option Initialize event and 
032     * member functions to reference the data returned.
033     */
034    public final class OTOptionInit implements Comparable<OTOptionInit>, Serializable {
035    
036            private static final long serialVersionUID = -4489013332981157210L;
037            
038            private String underlyerSymbol;
039        private String symbol;
040        private double strikePrice;
041        private int contractSize;
042        private int expYear;
043        private int expMonth;
044        private int expDay;
045        private OptionTypeEnum exerciseStyle;
046        private String underlyerCusip;
047        private String currency;
048        private char optionMarker;
049    
050        /**
051         * Default constructor.
052         */
053        public OTOptionInit() { }
054    
055        /**
056         * Constructor.
057         * @param underlyerSymbol Underlying symbol name.
058         * @param symbol Symbol.
059         * @param strikePrice  Strike price.
060         * @param contractSize Contract size.
061         * @param expYear Expiration year.
062         * @param expMonth Expiration month.
063         * @param expDay Expiration daty.
064         * @param exerciseStyle Exercise style.
065         * @param underlyerCusip Underlyer CUSIP.
066         * @param currency Currency type used.
067         * @param optionMarker Option marker.
068         */
069        public OTOptionInit(String underlyerSymbol, 
070                    String symbol, 
071                    double strikePrice, 
072                    int contractSize, 
073                    int expYear,
074                    int expMonth, 
075                    int expDay, 
076                    OptionTypeEnum exerciseStyle,    
077                    String underlyerCusip, 
078                    String currency, 
079                    char optionMarker) {
080            this.underlyerSymbol=underlyerSymbol;
081            this.symbol=symbol;
082            this.strikePrice=strikePrice;
083            this.contractSize=contractSize;
084            this.expYear=expYear;
085            this.expMonth=expMonth;
086            this.expDay=expDay;
087            this.exerciseStyle=exerciseStyle;
088            this.underlyerCusip=underlyerCusip;
089            this.currency=currency;
090            this.optionMarker=optionMarker;
091        }
092    
093        /**
094         * 
095         * @return     Contract size.
096         */
097        public int getContractSize() {
098            return contractSize;
099        }
100        
101        public void setConstrctSize(int val) {
102            contractSize = val;
103        }
104    
105        /**
106         * 
107         * @return Currency type used.
108         */
109        public String getCurrency() {
110            return currency;
111        }
112        
113        public void setCurrency(String val) {
114            currency = val;
115        }
116    
117        /**
118         * 
119         * @return Option excersize style (AMERICAN/EUROPEAN/CAPPED).
120         */
121        public OptionTypeEnum getExerciseStyle() {
122            return exerciseStyle;
123        }
124        
125        public void setExcerciseStyle(OptionTypeEnum val) {
126            exerciseStyle = val;
127        }
128    
129        /**
130         * 
131         * @return Expiration day.
132         */
133        public int getExpDay() {
134            return expDay;
135        }
136        
137        public void setExpDay(int val) {
138            expDay = val;
139        }
140    
141        /**
142         * 
143         * @return Expiration month.
144         */
145        public int getExpMonth() {
146            return expMonth;
147        }
148        
149        public void setExpMonth(int val) {
150            expMonth = val;
151        }
152    
153        /**
154         * 
155         * @return Expiration year.
156         */
157        public int getExpYear() {
158            return expYear;
159        }
160        
161        public void setExpYear(int val) {
162            expYear = val;
163        }
164    
165        /**
166         * (Montreal only).
167         * @return Option marker.
168         */
169        public char getOptionMarker() {
170            return optionMarker;
171        }
172        
173        public void setOptionMarker(char val) {
174            optionMarker = val;
175        }
176    
177        /**
178         * 
179         * @return Strike price for the option.
180         */
181        public double getStrikePrice() {
182            return strikePrice;
183        }
184        
185        public void setStrikePrice(double val) {
186            strikePrice = val;
187        }
188    
189        /**
190         *
191         * @return Symbol name for the option.
192         */
193        public String getSymbol() {
194            return symbol;
195        }
196        
197        public void setSymbol(String val) {
198            symbol = val;
199        }
200    
201        /**
202         *
203         * @return CUSIP ID for the underlying symbol.
204         */
205        public String getUnderlyerCusip() {
206            return underlyerCusip;
207        }
208        
209        public void setUnderlyerCusip(String val) {
210            underlyerCusip = val;
211        }
212    
213        /**
214         * 
215         * @return Underlying symbol name.
216         */
217        public String getUnderlyerSymbol() {
218            return underlyerSymbol;
219        }
220        
221        public void setUnderlyerSymbol(String val) {
222            underlyerSymbol = val;
223        }
224        
225        @Override
226            public String toString() {
227            return "OTOptionInit: underlyerSymbol=" + underlyerSymbol
228                            + ", symbol=" + symbol
229                            + ", strikeprice=" + strikePrice 
230                            + ", contractsize=" + contractSize
231                            + ", expyear=" + expYear
232                            + ", expmonth=" + expMonth
233                            + ", expday=" + expDay 
234                            + ", exercisestyle=" + exerciseStyle
235                            + ", underlyercusip=" + underlyerCusip
236                            + ", currency=" + currency
237                            + ", optionmarker=" + optionMarker;
238        }
239    
240        @Override
241            public int hashCode() {
242            return safeHashCode(underlyerSymbol) 
243                    + 3 * safeHashCode(symbol)
244                    + 5 * safeHashCode(strikePrice)
245                    + 7 * safeHashCode(contractSize)
246                    + 11 * safeHashCode(expYear)
247                    + 13 * safeHashCode(expMonth)
248                    + 17 * safeHashCode(expDay)
249                            + 23 * safeHashCode(exerciseStyle)
250                            + 29 * safeHashCode(underlyerCusip)
251                            + 31 * safeHashCode(currency)
252                            + 41 * safeHashCode(optionMarker);
253        }
254            
255        @Override
256            public boolean equals(Object o) {
257            return equalsTo(this, o);
258        }
259        
260            public int compareTo(OTOptionInit other) {
261                    int rc;
262    
263                    if((rc = safeCompare(underlyerSymbol, other.underlyerSymbol)) != 0) {
264                            return rc;
265                    }
266                    
267                    if((rc = safeCompare(symbol, other.symbol)) != 0) {
268                            return rc;
269                    }
270    
271                    if((rc = safeCompare(strikePrice, other.strikePrice)) != 0) {
272                            return rc;
273                    }
274    
275                    if((rc = safeCompare(contractSize, other.contractSize)) != 0) {
276                            return rc;
277                    }
278    
279                    if((rc = safeCompare(expYear, other.expYear)) != 0) {
280                            return rc;
281                    }
282    
283                    if((rc = safeCompare(expMonth, other.expMonth)) != 0) {
284                            return rc;
285                    }
286    
287                    if((rc = safeCompare(expDay, other.expDay)) != 0) {
288                            return rc;
289                    }
290    
291                    if((rc = safeCompare(exerciseStyle, other.exerciseStyle)) != 0) {
292                            return rc;
293                    }
294                    
295                    if((rc = safeCompare(underlyerCusip, other.underlyerCusip)) != 0) {
296                            return rc;
297                    }
298    
299                    if((rc = safeCompare(currency, other.currency)) != 0) {
300                            return rc;
301                    }
302    
303                    if((rc = safeCompare(optionMarker, other.optionMarker)) != 0) {
304                            return rc;
305                    }
306    
307                    return 0;
308            }
309    }