001package burrows.api.finance.model;
002
003/**
004 * An enumeration that represents the companies that the Yahoo API supports.
005 * <p>
006 * Basic Bash Script for adding Enums:
007 * </p>
008 * <pre>
009 * {@code
010 * pbpaste | awk 'BEGIN { OFS="\t"} { printf "%s(%d, \"%s\", \"%s\"),\n", $1, NR-1, $1, $(NF) }' | pbcopy
011 * pbpaste | awk 'BEGIN { OFS="\t"} { printf "%s(%d, \"%s\", \"%s\"),\n", toupper($1), NR-1, $1, $(NF) }' | pbcopy
012 * }
013 * </pre>
014 *
015 * @author <a href="mailto:jaredsburrows@gmail.com">Jared Burrows</a>
016 * @see <a href="https://code.google.com/p/yahoo-finance-managed/wiki/enumQuoteProperty">https://code.google.com/p/yahoo-finance-managed/wiki/enumQuoteProperty</a>
017 * @since 0.0.1
018 */
019public enum Property {
020    AfterHoursChangeRealtime(0, "AfterHoursChangeRealtime", "c8"),
021    AnnualizedGain(1, "AnnualizedGain", "g3"),
022    Ask(2, "Ask", "a0"),
023    AskRealtime(3, "AskRealtime", "b2"),
024    AskSize(4, "AskSize", "a5"),
025    AverageDailyVolume(5, "AverageDailyVolume", "a2"),
026    Bid(6, "Bid", "b0"),
027    BidRealtime(7, "BidRealtime", "b3"),
028    BidSize(8, "BidSize", "b6"),
029    BookValuePerShare(9, "BookValuePerShare", "b4"),
030    Change(10, "Change", "c1"),
031    Change_ChangeInPercent(11, "Change_ChangeInPercent", "c0"),
032    ChangeFromFiftydayMovingAverage(12, "ChangeFromFiftydayMovingAverage", "m7"),
033    ChangeFromTwoHundreddayMovingAverage(13, "ChangeFromTwoHundreddayMovingAverage", "m5"),
034    ChangeFromYearHigh(14, "ChangeFromYearHigh", "k4"),
035    ChangeFromYearLow(15, "ChangeFromYearLow", "j5"),
036    ChangeInPercent(16, "ChangeInPercent", "p2"),
037    ChangeInPercentRealtime(17, "ChangeInPercentRealtime", "k2"),
038    ChangeRealtime(18, "ChangeRealtime", "c6"),
039    Commission(19, "Commission", "c3"),
040    Currency(20, "Currency", "c4"),
041    DaysHigh(21, "DaysHigh", "h0"),
042    DaysLow(22, "DaysLow", "g0"),
043    DaysRange(23, "DaysRange", "m0"),
044    DaysRangeRealtime(24, "DaysRangeRealtime", "m2"),
045    DaysValueChange(25, "DaysValueChange", "w1"),
046    DaysValueChangeRealtime(26, "DaysValueChangeRealtime", "w4"),
047    DividendPayDate(27, "DividendPayDate", "r1"),
048    TrailingAnnualDividendYield(28, "TrailingAnnualDividendYield", "d0"),
049    TrailingAnnualDividendYieldInPercent(29, "TrailingAnnualDividendYieldInPercent", "y0"),
050    DilutedEPS(30, "DilutedEPS", "e0"),
051    EBITDA(31, "EBITDA", "j4"),
052    EPSEstimateCurrentYear(32, "EPSEstimateCurrentYear", "e7"),
053    EPSEstimateNextQuarter(33, "EPSEstimateNextQuarter", "e9"),
054    EPSEstimateNextYear(34, "EPSEstimateNextYear", "e8"),
055    ExDividendDate(35, "ExDividendDate", "q0"),
056    FiftydayMovingAverage(36, "FiftydayMovingAverage", "m3"),
057    SharesFloat(37, "SharesFloat", "f6"),
058    HighLimit(38, "HighLimit", "l2"),
059    HoldingsGain(39, "HoldingsGain", "g4"),
060    HoldingsGainPercent(40, "HoldingsGainPercent", "g1"),
061    HoldingsGainPercentRealtime(41, "HoldingsGainPercentRealtime", "g5"),
062    HoldingsGainRealtime(42, "HoldingsGainRealtime", "g6"),
063    HoldingsValue(43, "HoldingsValue", "v1"),
064    HoldingsValueRealtime(44, "HoldingsValueRealtime", "v7"),
065    LastTradeDate(45, "LastTradeDate", "d1"),
066    LastTradePriceOnly(46, "LastTradePriceOnly", "l1"),
067    LastTradeRealtimeWithTime(47, "LastTradeRealtimeWithTime", "k1"),
068    LastTradeSize(48, "LastTradeSize", "k3"),
069    LastTradeTime(49, "LastTradeTime", "t1"),
070    LastTradeWithTime(50, "LastTradeWithTime", "l0"),
071    LowLimit(51, "LowLimit", "l3"),
072    MarketCapitalization(52, "MarketCapitalization", "j1"),
073    MarketCapRealtime(53, "MarketCapRealtime", "j3"),
074    MoreInfo(54, "MoreInfo", "i0"),
075    Name(55, "Name", "n0"),
076    Notes(56, "Notes", "n4"),
077    OneyrTargetPrice(57, "OneyrTargetPrice", "t8"),
078    Open(58, "Open", "o0"),
079    OrderBookRealtime(59, "OrderBookRealtime", "i5"),
080    PEGRatio(60, "PEGRatio", "r5"),
081    PERatio(61, "PERatio", "r0"),
082    PERatioRealtime(62, "PERatioRealtime", "r2"),
083    PercentChangeFromFiftydayMovingAverage(63, "PercentChangeFromFiftydayMovingAverage", "m8"),
084    PercentChangeFromTwoHundreddayMovingAverage(64, "PercentChangeFromTwoHundreddayMovingAverage", "m6"),
085    ChangeInPercentFromYearHigh(65, "ChangeInPercentFromYearHigh", "k5"),
086    PercentChangeFromYearLow(66, "PercentChangeFromYearLow", "j6"),
087    PreviousClose(67, "PreviousClose", "p0"),
088    PriceBook(68, "PriceBook", "p6"),
089    PriceEPSEstimateCurrentYear(69, "PriceEPSEstimateCurrentYear", "r6"),
090    PriceEPSEstimateNextYear(70, "PriceEPSEstimateNextYear", "r7"),
091    PricePaid(71, "PricePaid", "p1"),
092    PriceSales(72, "PriceSales", "p5"),
093    Revenue(73, "Revenue", "s6"),
094    SharesOwned(74, "SharesOwned", "s1"),
095    SharesOutstanding(75, "SharesOutstanding", "j2"),
096    ShortRatio(76, "ShortRatio", "s7"),
097    StockExchange(77, "StockExchange", "x0"),
098    Symbol(78, "Symbol", "s0"),
099    TickerTrend(79, "TickerTrend", "t7"),
100    TradeDate(80, "TradeDate", "d2"),
101    TradeLinks(81, "TradeLinks", "t6"),
102    TradeLinksAdditional(82, "TradeLinksAdditional", "f0"),
103    TwoHundreddayMovingAverage(83, "TwoHundreddayMovingAverage", "m4"),
104    Volume(84, "Volume", "v0"),
105    YearHigh(85, "YearHigh", "k0"),
106    YearLow(86, "YearLow", "j0"),
107    YearRange(87, "YearRange", "w0");
108
109    private final int intValue;
110    private final String stringValue;
111    private final String tagValue;
112
113    private Property(final int intValue, final String stringValue, final String tagValue) {
114        this.intValue = intValue;
115        this.stringValue = stringValue;
116        this.tagValue = tagValue;
117    }
118
119    /**
120     * Returns the integer value of this enum instance.
121     *
122     * @return the integer value of this enum instance.
123     *
124     * @see #fromInt(int)
125     * @since 0.0.1
126     */
127    public int getIntValue() {
128        return this.intValue;
129    }
130
131    /**
132     * Returns the underlying {@link #stringValue} of this instance.
133     *
134     * @return the underlying {@link #stringValue} of this instance.
135     *
136     * @see #fromString(String)
137     * @since 0.0.1
138     */
139    public String getStringValue() {
140        return this.stringValue;
141    }
142
143    /**
144     * Returns the underlying {@link #tagValue} of this instance.
145     *
146     * @return the underlying {@link #tagValue} of this instance.
147     *
148     * @see #fromTag(String)
149     * @since 0.0.1
150     */
151    public String getTagValue() {
152        return this.tagValue;
153    }
154
155    /**
156     * Returns the integer value of this enum instance.
157     *
158     * @param intValue the integer value to determine the matching enum instance for.
159     *
160     * @return the enum instance for the specified int value, or {@code null} if there is no match.
161     *
162     * @see #getIntValue()
163     * @since 0.0.1
164     */
165    public static Property fromInt(int intValue) {
166        for (Property instance : values()) {
167            if (instance.intValue == intValue) {
168                return instance;
169            }
170        }
171        return null;
172    }
173
174    /**
175     * Returns the enum instance for the specified string.
176     *
177     * @param stringValue the string value to determine the matching enum instance for.
178     *
179     * @return the enum instance for the specified string, or {@code null} if there is no match.
180     *
181     * @see #getStringValue()
182     * @since 0.0.1
183     */
184    public static Property fromString(String stringValue) {
185        if (stringValue == null || stringValue.length() == 0) {
186            return null;
187        }
188
189        for (Property instance : values()) {
190            if (instance.stringValue.equalsIgnoreCase(stringValue)) {
191                return instance;
192            }
193        }
194        return null;
195    }
196
197    /**
198     * Returns the enum instance for the specified string for tag.
199     *
200     * @param tagValue the string value to determine the matching enum instance for.
201     *
202     * @return the enum instance for the specified string, or {@code null} if there is no match.
203     *
204     * @see #getTagValue()
205     * @since 0.0.1
206     */
207    public static Property fromTag(String tagValue) {
208        if (tagValue == null || tagValue.length() == 0) {
209            return null;
210        }
211
212        for (Property instance : values()) {
213            if (instance.tagValue.equalsIgnoreCase(tagValue)) {
214                return instance;
215            }
216        }
217        return null;
218    }
219}