com.studerw.tda.model.instrument.Query Maven / Gradle / Ivy
package com.studerw.tda.model.instrument;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
*
* Query TDA for instruments , either using symbol, name, description, cusip, etc.
* Apparently the following instrument types are queryable: {@link Instrument.AssetType}.
*
*
*
* The following {@link com.studerw.tda.model.instrument.Query.QueryType QueryTypes} can be made:
*
*
*
* - SYMBOL_SEARCH: retrieve an instrument using the exact symbol name or CUSIP
* - SYMBOL_REGEX: Retrieve instrument data for all symbols matching regex. For example XYZ.* will return all symbols beginning with XYZ
* - DESCRIPTION_SEARCH: Retrieve instrument data for instruments whose description contains the word supplied. Example: Bank will return all instruments with Bank in the description.
* - DESCRIPTION_REGEX: Search description with full regex support.
* For example XYZ.[A-C] returns all instruments whose descriptions contain a word beginning with XYZ followed by a character A through C.
*
*
* @see Instrument.AssetType
* @see com.studerw.tda.client.TdaClient#queryInstruments(Query)
*/
public class Query {
private String searchStr;
private QueryType queryType;
public Query(String searchStr, QueryType queryType) {
this.searchStr = searchStr;
this.queryType = queryType;
}
public String getSearchStr() {
return searchStr;
}
public QueryType getQueryType() {
return queryType;
}
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("searchStr", searchStr)
.append("queryType", queryType)
.toString();
}
public enum QueryType {
SYMBOL_SEARCH("symbol-search"),
SYMBOL_REGEX("symbol-regex"),
DESCRIPTION_SEARCH("desc-search"),
DESCRIPTION_REGEX("desc-regex");
private String queryType;
QueryType(String queryType) {
this.queryType = queryType;
}
public String getQueryType() {
return queryType;
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy