BaseField API Reference
Complete API reference for the BaseField class and field system.
BaseField Class
The base class for all screener fields.
Constructor
class BaseField {
constructor(name: string, metadata: FieldMetadata)
}Parameters
name(string): Field identifier (e.g., "PRICE", "VOLUME")metadata(FieldMetadata): Field metadata object
Properties
class BaseField {
readonly name: string; // Field name
readonly metadata: FieldMetadata; // Field metadata
}FieldMetadata Interface
interface FieldMetadata {
label: string; // Human-readable label
fieldName: string; // Internal API field name
format: FieldFormat; // Value format type
interval: boolean; // Supports time intervals
historical: boolean; // Supports historical data
}Comparison Operators
Greater Than
gt(value: number): FieldConditionCreates a "greater than" condition.
Example:
StockField.PRICE.gt(100) // Price > 100Greater Than or Equal
gte(value: number): FieldConditionCreates a "greater than or equal" condition.
Example:
StockField.VOLUME.gte(1_000_000) // Volume >= 1,000,000Less Than
lt(value: number): FieldConditionCreates a "less than" condition.
Example:
StockField.RSI.lt(30) // RSI < 30 (oversold)Less Than or Equal
lte(value: number): FieldConditionCreates a "less than or equal" condition.
Example:
StockField.PRICE_TO_EARNINGS_RATIO_TTM.lte(15)Equal
eq(value: any): FieldConditionCreates an "equal to" condition.
Example:
StockField.NAME.eq('Apple Inc.')
StockField.PRICE.eq(100)Not Equal
ne(value: any): FieldConditionCreates a "not equal to" condition.
Example:
StockField.NAME.ne('Apple Inc.')
StockField.DESCRIPTION.notMatch('.*bank.*')Range Operators
Between
between(min: number, max: number): FieldConditionCreates an "in range" condition (inclusive).
Example:
StockField.MARKET_CAPITALIZATION.between(1e9, 10e9) // 1B to 10B
StockField.RSI.between(30, 70) // RSI sweet spotNot Between
notBetween(min: number, max: number): FieldConditionCreates a "not in range" condition.
Example:
StockField.RSI.notBetween(30, 70) // Overbought or oversoldList Operators
In List
isin(values: any[]): FieldConditionCreates an "in list" condition.
Example:
StockField.NAME.isin(['Apple Inc.', 'Microsoft Corporation', 'Alphabet Inc.'])
StockField.DESCRIPTION.match('.*technology.*')Not In List
notIn(values: any[]): FieldConditionCreates a "not in list" condition.
Example:
StockField.NAME.notIn(['Penny Stock Inc.', 'OTC Corp'])
StockField.PRICE.notIn([0, 1])Text Operators
Match Pattern
match(pattern: string): FieldConditionCreates a regex match condition.
Example:
StockField.NAME.match('.*bank.*')
StockField.DESCRIPTION.match('.*Software.*')Not Match Pattern
notMatch(pattern: string): FieldConditionCreates a regex non-match condition.
Example:
StockField.NAME.notMatch('.*acquisition.*')Array Operators
Has Any
has(values: any[]): FieldConditionFor array fields, checks if any value is present.
Example:
// Array field operations not available with current field setHas None Of
hasNoneOf(values: any[]): FieldConditionFor array fields, checks that none of the values are present.
Example:
// Array field operations not available with current field setCross-Field Operators
Above
above(otherField: BaseField): FieldConditionCompare this field to another field (greater than).
Example:
// Cross-field comparisons require technical indicator fields
// which are not available in the current field set
StockField.PRICE.gt(100) // Use standard comparison insteadBelow
below(otherField: BaseField): FieldConditionCompare this field to another field (less than).
Example:
// Cross-field comparisons require technical indicator fields
// which are not available in the current field set
StockField.PRICE.lt(1000) // Use standard comparison insteadNear
near(otherField: BaseField, tolerance: number): FieldConditionCheck if field is within tolerance of another field.
Example:
// Cross-field comparisons require technical indicator fields
// which are not available in the current field set
StockField.PRICE.between(99, 101) // Use range comparison insteadCrosses
crosses(otherField: BaseField): FieldConditionDetects when this field crosses another field (either direction).
Example:
// Cross-field comparisons require technical indicator fields
// which are not available in the current field setCrosses Above
crossesAbove(otherField: BaseField): FieldConditionDetects when this field crosses above another field.
Example:
// Cross-field comparisons require technical indicator fields
// which are not available in the current field setCrosses Below
crossesBelow(otherField: BaseField): FieldConditionDetects when this field crosses below another field.
Example:
// Cross-field comparisons require technical indicator fields
// which are not available in the current field setTime Interval Modifiers
With Interval
withInterval(interval: string): FieldWithIntervalApply a time interval to the field.
Parameters:
interval(string): Time interval ('1D', '1W', '1M', '3M', '6M', '1Y')
Returns: FieldWithInterval with all comparison operators
Example:
StockField.PRICE.withInterval('1W') // Weekly price
StockField.RSI.withInterval('1M') // Monthly RSIWith History
withHistory(bars: number): FieldWithHistoryGet historical values for the field.
Parameters:
bars(number): Number of historical bars to retrieve
Returns: FieldWithHistory with all comparison operators
Example:
StockField.PRICE.withHistory(30) // Last 30 bars
StockField.VOLUME.withHistory(10) // Last 10 barsStatic Methods
Search Fields
static search(query: string): BaseField[]Search for fields by name or label.
Example:
const fields = StockField.search('dividend');
// Returns: DIVIDEND_YIELD_FWD, DIVIDENDS_YIELD_FY, DPS_COMMON_STOCK_PRIM_ISSUE_TTM
const priceFields = StockField.search('price');
// Returns: PRICE, PRICE_TO_EARNINGS_RATIO_TTM, PRICE_SALES_CURRENT, etc.By Format
static byFormat(format: FieldFormat): BaseField[]Get all fields with a specific format.
Example:
const currencyFields = StockField.byFormat('currency');
const percentFields = StockField.byFormat('percent');Technical Indicators
static technicals(): BaseField[]Get all technical indicator fields.
Example:
const indicators = StockField.technicals();
// Returns: RSI, ATR, etc.Recommendations
static recommendations(): BaseField[]Get all recommendation fields.
Example:
// Recommendation fields are not available in the current field set
const recs = StockField.recommendations();FieldWithInterval Class
Extended field with time interval.
class FieldWithInterval extends BaseField {
readonly baseField: BaseField;
readonly interval: string;
// Inherits all comparison operators from BaseField
}Example:
const weeklyRSI = StockField.RSI.withInterval('1W');
screener.where(weeklyRSI.between(30, 70));FieldWithHistory Class
Extended field with historical data.
class FieldWithHistory extends BaseField {
readonly baseField: BaseField;
readonly bars: number;
// Inherits all comparison operators from BaseField
}Example:
const last10Prices = StockField.PRICE.withHistory(10);
screener.where(last10Prices.gt(100));Field Formats
type FieldFormat =
| 'currency' // $1,234.56
| 'percent' // 12.34%
| 'float' // 123.46
| 'round' // 123
| 'number_group' // 1,234,567
| 'text' // Raw text
| 'date' // Date string
| 'bool' // true/false
| 'rating' // Strong Buy, Buy, Hold, Sell, Strong Sell
| 'recommendation' // Similar to rating
| 'computed_recommendation'; // Technical recommendationAvailable Fields
Stock Fields
// Price & Volume
StockField.PRICE
StockField.VOLUME
StockField.CHANGE
StockField.CHANGE_PERCENT
// Market Data
StockField.MARKET_CAPITALIZATION
StockField.NAME
StockField.DESCRIPTION
// Valuation
StockField.PRICE_TO_EARNINGS_RATIO_TTM
StockField.PRICE_TO_BOOK_MRQ
StockField.PRICE_SALES_CURRENT
StockField.ENTERPRISE_VALUE_EBITDA_TTM
StockField.PRICE_EARNINGS_GROWTH_TTM
// Dividends
StockField.DIVIDEND_YIELD_FWD
StockField.DIVIDENDS_YIELD_FY
StockField.DPS_COMMON_STOCK_PRIM_ISSUE_TTM
// Financial Performance
StockField.REVENUE_TTM
StockField.REVENUE_TTM_YOY_GROWTH
StockField.NET_INCOME_TTM
StockField.EARNINGS_PER_SHARE_DILUTED_TTM
// Technical Indicators
StockField.RSI
StockField.ATR
// Total: 21 available fieldsCrypto Fields
CryptoField.PRICE
CryptoField.CHANGE_PERCENT
CryptoField.MARKET_CAPITALIZATION
CryptoField.VOLUME
CryptoField.RSI
// Note: Limited crypto fields availableBest Practices
1. Use Type-Safe Comparisons
// Good: Type-safe
StockField.PRICE.gt(100)
// Bad: Not type-safe
StockField.PRICE.gt('expensive') // TypeScript error2. Store Reusable Conditions
// Good: Reusable
const largeCap = StockField.MARKET_CAPITALIZATION.gt(10e9);
screener1.where(largeCap);
screener2.where(largeCap);
// Less efficient: Recreate each time
screener1.where(StockField.MARKET_CAPITALIZATION.gt(10e9));
screener2.where(StockField.MARKET_CAPITALIZATION.gt(10e9));3. Chain Modifiers Correctly
// Good: Apply interval first
const weeklyRSI = StockField.RSI.withInterval('1W');
screener.where(weeklyRSI.lt(30));
// Works: Inline
screener.where(StockField.RSI.withInterval('1W').lt(30));4. Search Before Using
// Good: Search for available fields
const dividendFields = StockField.search('dividend');
console.log(dividendFields.map(f => f.name));
// Then use the correct field
screener.where(StockField.DIVIDEND_YIELD_FWD.gte(3));Examples
Basic Filtering
screener
.where(StockField.PRICE.gt(10))
.where(StockField.PRICE.lt(500))
.where(StockField.VOLUME.gte(100_000));Range Filtering
screener
.where(StockField.MARKET_CAPITALIZATION.between(1e9, 10e9))
.where(StockField.RSI.between(30, 70));List Filtering
screener
.where(StockField.NAME.match('.*Inc.*'))
.where(StockField.DESCRIPTION.notMatch('.*penny.*'));Cross-Field Comparison
// Cross-field comparisons require technical indicator fields
// which are not available in the current field set
// Use standard numeric comparisons instead:
screener
.where(StockField.PRICE.gt(100))
.where(StockField.RSI.lt(70));Time Intervals
screener
.where(StockField.CHANGE_PERCENT.withInterval('1W').gt(10))
.where(StockField.RSI.withInterval('1M').between(40, 60));Field Discovery
// Search for fields
const fields = StockField.search('revenue');
fields.forEach(f => {
console.log(`${f.name}: ${f.metadata.label}`);
});
// Get all percent fields
const percentFields = StockField.byFormat('percent');
// Get technical indicators
const technicals = StockField.technicals();Next Steps
- Filter API - Filter system reference
- Enums - Enumeration types
- BaseScreener - Screener class