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    
018    package org.otfeed.command;
019    
020    import org.otfeed.event.IDataDelegate;
021    import org.otfeed.event.OTOptionInit;
022    import org.otfeed.protocol.ICommand;
023    
024    /**
025     * Request for option detailed information.
026     * <p/>
027     * Generates {@link OTOptionInit} event.
028     */
029    public final class OptionInitCommand 
030                    extends ExchangeAndSymbolHolder implements ICommand {
031    
032            /**
033             * Creates new option init command, initializing 
034             * all its properties.
035             * 
036             * @param exchangeCode exchange code.
037             * @param symbolCode symbol code.
038             * @param expiration expiration.
039             * @param strike strike.
040             * @param dataDelegate delegate.
041             */
042            public OptionInitCommand(String exchangeCode,
043                            String symbolCode,
044                            MonthAndYear expiration,
045                            PriceRange strike,
046                            IDataDelegate<OTOptionInit> dataDelegate) {
047                    setExchangeCode(exchangeCode);
048                    setSymbolCode(symbolCode);
049                    setExpiration(expiration);
050                    setStrike(strike);
051                    setDataDelegate(dataDelegate);
052            }
053            
054            /**
055             * Default constructor. Initializes
056             * {@link #getExpiration expiration} property to its 
057             * default value of <code>null</code> (meaning "any").
058             * Initializes {@link #getStrike strike} property to
059             * its default value of <code>null</code> (meaning "any").
060             * All other properties must be explicitly set before 
061             * using this command object.
062             */
063            public OptionInitCommand() {
064                    this(null, null, null, null, null);
065            }
066            
067            /**
068             * Creates new option init command with any expiration,
069             * initializing all its properties.
070             * 
071             * @param exchangeCode exchange code.
072             * @param symbolCode symbol code.
073             * @param strike strike.
074             * @param dataDelegate delegate.
075             */
076            public OptionInitCommand(String exchangeCode,
077                            String symbolCode,
078                            PriceRange strike,
079                            IDataDelegate<OTOptionInit> dataDelegate) {
080                    this(exchangeCode, symbolCode, null, strike, dataDelegate);
081            }
082    
083            /**
084             * Creates new option init command with any strike,
085             * initializing all its properties.
086             * 
087             * @param exchangeCode exchange code.
088             * @param symbolCode symbol code.
089             * @param expiration expiration.
090             * @param dataDelegate delegate.
091             */
092            public OptionInitCommand(String exchangeCode,
093                            String symbolCode,
094                            MonthAndYear expiration,
095                            IDataDelegate<OTOptionInit> dataDelegate) {
096                    this(exchangeCode, symbolCode, expiration, null, dataDelegate);
097            }
098    
099            /**
100             * Creates new option init command with any strike and
101             * any expiration date,
102             * initializing all its properties.
103             * 
104             * @param exchangeCode exchange code.
105             * @param symbolCode symbol code.
106             * @param dataDelegate delegate.
107             */
108            public OptionInitCommand(String exchangeCode,
109                            String symbolCode,
110                            IDataDelegate<OTOptionInit> dataDelegate) {
111                    this(exchangeCode, symbolCode, null, null, dataDelegate);
112            }
113    
114            private MonthAndYear expiration;
115            
116            /**
117             * Expiration month and year for the option.
118             * This is optional property. Defaults to null, which
119             * is interpreted as any expiration date.
120             * 
121             * @return expiration month and year.
122             */
123            public MonthAndYear getExpiration() {
124                    return expiration;
125            }
126            
127            /**
128             * Sets expiration month and year.
129             * 
130             * @param val expiration month and year.
131             */
132            public void setExpiration(MonthAndYear val) {
133                    expiration = val;
134            }
135            
136            private PriceRange strike;
137            
138            /**
139             * Price range for the option strike.
140             * This property is optional. Defaults to null, which 
141             * means "any strike".
142             * 
143             * @return strike price range.
144             */
145            public PriceRange getStrike() {
146                    return strike;
147            }
148            
149            /**
150             * Sets strike price range.
151             * 
152             * @param val end date/time.
153             */
154            public void setStrike(PriceRange val) {
155                    strike = val;
156            }
157            
158            private IDataDelegate<OTOptionInit> dataDelegate;
159    
160            /**
161             * Delegate to receive {@link OTOptionInit} events.
162             * This parameter is mandatory.
163             * 
164             * @return delegate.
165             */
166            public IDataDelegate<OTOptionInit> getDataDelegate() {
167                    return dataDelegate;
168            }
169    
170            /**
171             * Sets delegate.
172             * 
173             * @param dataDelegate delegate.
174             */
175            public void setDataDelegate(IDataDelegate<OTOptionInit> dataDelegate) {
176                    this.dataDelegate = dataDelegate;
177            }
178    }