pub struct ScreenerQuery<F: ScreenerField = EquityField> {
pub size: u32,
pub offset: u32,
pub sort_type: SortType,
pub sort_field: F,
pub include_fields: Vec<F>,
pub top_operator: LogicalOperator,
pub query: QueryGroup<F>,
pub quote_type: QuoteType,
}Expand description
A typed custom screener query for Yahoo Finance.
The type parameter F determines which field set is valid for this query.
Use the type aliases for the common cases:
EquityScreenerQuery— for stock screenersFundScreenerQuery— for mutual fund screeners
§Example
use finance_query::{EquityField, EquityScreenerQuery, ScreenerFieldExt};
// Find US large-cap value stocks
let query = EquityScreenerQuery::new()
.size(25)
.sort_by(EquityField::IntradayMarketCap, false)
.add_condition(EquityField::Region.eq_str("us"))
.add_condition(EquityField::AvgDailyVol3M.gt(200_000.0))
.add_condition(EquityField::PeRatio.between(10.0, 25.0))
.add_condition(EquityField::IntradayMarketCap.gt(10_000_000_000.0))
.include_fields(vec![
EquityField::Ticker,
EquityField::CompanyShortName,
EquityField::IntradayPrice,
EquityField::PeRatio,
EquityField::IntradayMarketCap,
]);Fields§
§size: u32Number of results to return (default: 25, max: 250).
offset: u32Starting offset for pagination (default: 0).
sort_type: SortTypeSort direction.
sort_field: FField to sort by.
include_fields: Vec<F>Fields to include in the response.
top_operator: LogicalOperatorTop-level logical operator combining all conditions.
query: QueryGroup<F>The nested condition tree.
quote_type: QuoteTypeQuote type — determines which Yahoo Finance screener endpoint is used.
Implementations§
Source§impl<F: ScreenerField> ScreenerQuery<F>
impl<F: ScreenerField> ScreenerQuery<F>
Sourcepub fn sort_by(self, field: F, ascending: bool) -> Self
pub fn sort_by(self, field: F, ascending: bool) -> Self
Set the field to sort by and the sort direction.
§Example
use finance_query::{EquityField, EquityScreenerQuery};
let query = EquityScreenerQuery::new()
.sort_by(EquityField::PeRatio, true); // ascending P/ESourcepub fn top_operator(self, op: LogicalOperator) -> Self
pub fn top_operator(self, op: LogicalOperator) -> Self
Set the top-level logical operator (AND or OR).
Sourcepub fn include_fields(self, fields: Vec<F>) -> Self
pub fn include_fields(self, fields: Vec<F>) -> Self
Set which fields to include in the response.
Sourcepub fn add_include_field(self, field: F) -> Self
pub fn add_include_field(self, field: F) -> Self
Add a field to include in the response.
Sourcepub fn add_condition(self, condition: QueryCondition<F>) -> Self
pub fn add_condition(self, condition: QueryCondition<F>) -> Self
Add a typed filter condition to this query (ANDed with all others).
Conditions are added directly as operands of the top-level AND group,
matching the format Yahoo Finance’s screener API expects. Use
add_or_conditions when you need to match
any of several values for the same field.
§Example
use finance_query::{EquityField, EquityScreenerQuery, ScreenerFieldExt};
let query = EquityScreenerQuery::new()
.add_condition(EquityField::Region.eq_str("us"))
.add_condition(EquityField::PeRatio.between(10.0, 25.0))
.add_condition(EquityField::AvgDailyVol3M.gt(200_000.0));Sourcepub fn add_or_conditions(self, conditions: Vec<QueryCondition<F>>) -> Self
pub fn add_or_conditions(self, conditions: Vec<QueryCondition<F>>) -> Self
Add multiple conditions that are OR’d together.
§Example
use finance_query::{EquityField, EquityScreenerQuery, ScreenerFieldExt};
// Accept US or GB region
let query = EquityScreenerQuery::new()
.add_or_conditions(vec![
EquityField::Region.eq_str("us"),
EquityField::Region.eq_str("gb"),
]);Source§impl ScreenerQuery<EquityField>
impl ScreenerQuery<EquityField>
Sourcepub fn most_shorted() -> Self
pub fn most_shorted() -> Self
Preset: US stocks sorted by short interest percentage of float.
Filters: US region, average daily volume > 200K.
use finance_query::{EquityScreenerQuery, finance};
let results = finance::custom_screener(EquityScreenerQuery::most_shorted()).await?;Sourcepub fn high_dividend() -> Self
pub fn high_dividend() -> Self
Preset: US stocks with forward dividend yield > 3%, sorted by yield descending.
Filters: US region, forward dividend yield > 3%, average daily volume > 100K.
use finance_query::{EquityScreenerQuery, finance};
let results = finance::custom_screener(EquityScreenerQuery::high_dividend()).await?;Sourcepub fn large_cap_growth() -> Self
pub fn large_cap_growth() -> Self
Preset: US large-cap stocks with positive EPS growth, sorted by market cap.
Filters: US region, market cap > $10B, positive EPS growth.
use finance_query::{EquityScreenerQuery, finance};
let results = finance::custom_screener(EquityScreenerQuery::large_cap_growth()).await?;Trait Implementations§
Source§impl<F: Clone + ScreenerField> Clone for ScreenerQuery<F>
impl<F: Clone + ScreenerField> Clone for ScreenerQuery<F>
Source§fn clone(&self) -> ScreenerQuery<F>
fn clone(&self) -> ScreenerQuery<F>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<F: Debug + ScreenerField> Debug for ScreenerQuery<F>
impl<F: Debug + ScreenerField> Debug for ScreenerQuery<F>
Source§impl Default for ScreenerQuery<EquityField>
impl Default for ScreenerQuery<EquityField>
Source§impl Default for ScreenerQuery<FundField>
impl Default for ScreenerQuery<FundField>
Source§impl<F> Serialize for ScreenerQuery<F>where
F: Serialize + ScreenerField,
impl<F> Serialize for ScreenerQuery<F>where
F: Serialize + ScreenerField,
Auto Trait Implementations§
impl<F> Freeze for ScreenerQuery<F>where
F: Freeze,
impl<F> RefUnwindSafe for ScreenerQuery<F>where
F: RefUnwindSafe,
impl<F> Send for ScreenerQuery<F>where
F: Send,
impl<F> Sync for ScreenerQuery<F>where
F: Sync,
impl<F> Unpin for ScreenerQuery<F>where
F: Unpin,
impl<F> UnsafeUnpin for ScreenerQuery<F>where
F: UnsafeUnpin,
impl<F> UnwindSafe for ScreenerQuery<F>where
F: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more