UNPKG

tradingview-screener-ts

Version:

TypeScript port of TradingView Screener with 100% Python parity - Based on the original Python library by shner-elmo (https://github.com/shner-elmo/TradingView-Screener)

257 lines 8.93 kB
import { FilterOperationDict } from './types/models'; /** * A Column object represents a field in the TradingView stock screener, * and it's used in SELECT queries and WHERE queries with the `Query` object. * * A `Column` supports all the comparison operations: * `<`, `<=`, `>`, `>=`, `==`, `!=`, and also other methods like `between()`, `isin()`, etc. * * @example * Some of the operations you can do: * ```typescript * new Column('close').gt(2.5) * new Column('High.All').lte('high') * new Column('high').gt('VWAP') * new Column('high').gt(new Column('VWAP')) // same thing as above * new Column('is_primary').eq(true) * new Column('exchange').ne('OTC') * * new Column('close').abovePct('VWAP', 1.03) * new Column('close').abovePct('price_52_week_low', 2.5) * new Column('close').belowPct('VWAP', 1.03) * new Column('close').betweenPct('EMA200', 1.2, 1.5) * new Column('close').notBetweenPct('EMA200', 1.2, 1.5) * * new Column('close').between(2.5, 15) * new Column('close').between('EMA5', 'EMA20') * * new Column('type').isin(['stock', 'fund']) * new Column('exchange').isin(['AMEX', 'NASDAQ', 'NYSE']) * new Column('sector').notIn(['Health Technology', 'Health Services']) * new Column('typespecs').has(['common']) * new Column('typespecs').hasNoneOf(['reit', 'etn', 'etf']) * * new Column('description').like('apple') // the same as `description LIKE '%apple%'` * new Column('premarket_change').notEmpty() // same as `Column('premarket_change') != null` * new Column('earnings_release_next_trading_date_fq').inDayRange(0, 0) // same day * ``` */ export declare class Column { readonly name: string; /** * Creates a new Column instance * @param name - The name of the column/field */ constructor(name: string); /** * Extracts the name from a Column object or returns the value as-is * @param obj - Column instance or any other value * @returns The column name or the original value */ private static extractName; /** * Greater than comparison * @param other - Value or Column to compare against * @returns Filter operation dictionary */ gt(other: any): FilterOperationDict; /** * Greater than or equal comparison * @param other - Value or Column to compare against * @returns Filter operation dictionary */ gte(other: any): FilterOperationDict; /** * Less than comparison * @param other - Value or Column to compare against * @returns Filter operation dictionary */ lt(other: any): FilterOperationDict; /** * Less than or equal comparison * @param other - Value or Column to compare against * @returns Filter operation dictionary */ lte(other: any): FilterOperationDict; /** * Equal comparison * @param other - Value or Column to compare against * @returns Filter operation dictionary */ eq(other: any): FilterOperationDict; /** * Not equal comparison * @param other - Value or Column to compare against * @returns Filter operation dictionary */ ne(other: any): FilterOperationDict; /** * Crosses comparison * @param other - Value or Column to compare against * @returns Filter operation dictionary */ crosses(other: any): FilterOperationDict; /** * Crosses above comparison * @param other - Value or Column to compare against * @returns Filter operation dictionary */ crossesAbove(other: any): FilterOperationDict; /** * Crosses below comparison * @param other - Value or Column to compare against * @returns Filter operation dictionary */ crossesBelow(other: any): FilterOperationDict; /** * Between range comparison * @param left - Lower bound * @param right - Upper bound * @returns Filter operation dictionary */ between(left: any, right: any): FilterOperationDict; /** * Not between range comparison * @param left - Lower bound * @param right - Upper bound * @returns Filter operation dictionary */ notBetween(left: any, right: any): FilterOperationDict; /** * Is in values comparison * @param values - Array of values to check against * @returns Filter operation dictionary */ isin(values: any[]): FilterOperationDict; /** * Not in values comparison * @param values - Array of values to check against * @returns Filter operation dictionary */ notIn(values: any[]): FilterOperationDict; /** * Field contains any of the values * (it's the same as `isin()`, except that it works on fields of type `set`) * @param values - Value or array of values * @returns Filter operation dictionary */ has(values: string | string[]): FilterOperationDict; /** * Field doesn't contain any of the values * (it's the same as `notIn()`, except that it works on fields of type `set`) * @param values - Value or array of values * @returns Filter operation dictionary */ hasNoneOf(values: string | string[]): FilterOperationDict; /** * In day range comparison * @param a - Start day * @param b - End day * @returns Filter operation dictionary */ inDayRange(a: number, b: number): FilterOperationDict; /** * In week range comparison * @param a - Start week * @param b - End week * @returns Filter operation dictionary */ inWeekRange(a: number, b: number): FilterOperationDict; /** * In month range comparison * @param a - Start month * @param b - End month * @returns Filter operation dictionary */ inMonthRange(a: number, b: number): FilterOperationDict; /** * Above percentage comparison * @param column - Column or field name to compare against * @param pct - Percentage threshold * @returns Filter operation dictionary * @example * The closing price is higher than the VWAP by more than 3% * ```typescript * new Column('close').abovePct('VWAP', 1.03) * ``` * * Closing price is above the 52-week-low by more than 150% * ```typescript * new Column('close').abovePct('price_52_week_low', 2.5) * ``` */ abovePct(column: Column | string, pct: number): FilterOperationDict; /** * Below percentage comparison * @param column - Column or field name to compare against * @param pct - Percentage threshold * @returns Filter operation dictionary * @example * The closing price is lower than the VWAP by 3% or more * ```typescript * new Column('close').belowPct('VWAP', 1.03) * ``` */ belowPct(column: Column | string, pct: number): FilterOperationDict; /** * Between percentage comparison * @param column - Column or field name to compare against * @param pct1 - First percentage threshold * @param pct2 - Second percentage threshold (optional) * @returns Filter operation dictionary * @example * The percentage change between the Close and the EMA is between 20% and 50% * ```typescript * new Column('close').betweenPct('EMA200', 1.2, 1.5) * ``` */ betweenPct(column: Column | string, pct1: number, pct2?: number): FilterOperationDict; /** * Not between percentage comparison * @param column - Column or field name to compare against * @param pct1 - First percentage threshold * @param pct2 - Second percentage threshold (optional) * @returns Filter operation dictionary * @example * The percentage change between the Close and the EMA is NOT between 20% and 50% * ```typescript * new Column('close').notBetweenPct('EMA200', 1.2, 1.5) * ``` */ notBetweenPct(column: Column | string, pct1: number, pct2?: number): FilterOperationDict; /** * Like pattern matching * @param other - Pattern to match * @returns Filter operation dictionary */ like(other: any): FilterOperationDict; /** * Not like pattern matching * @param other - Pattern to not match * @returns Filter operation dictionary */ notLike(other: any): FilterOperationDict; /** * Empty check * @returns Filter operation dictionary */ empty(): FilterOperationDict; /** * Not empty check * This method can be used to check if a field is not null/undefined. * @returns Filter operation dictionary */ notEmpty(): FilterOperationDict; /** * String representation of the Column * @returns String representation */ toString(): string; } /** * Short alias for Column constructor for convenience * @param name - The name of the column/field * @returns New Column instance */ export declare const col: (name: string) => Column; //# sourceMappingURL=column.d.ts.map