wvietor / ibkr_rust

A Rust port of the Interactive Brokers TWS API.
Apache License 2.0
8 stars 3 forks source link

Impl scanner #3

Open 7jrxt42BxFZo4iAnN4CX opened 2 months ago

7jrxt42BxFZo4iAnN4CX commented 2 months ago

Fix "MSK" time zone. Fix Reader.run() to receive large messages. Before this, the message(scanner_parameters) was split into three messages.

Scanner parameters:

  • req_scanner_parameters()
  • decode scanner_parameters
  • parsing xml
  • creating input data for macros
  • created macros for selecting from the desired options on ScannerSubscription.

Scanner subscriptions:

  • ScannerSubscription builder
  • req_scanner_subscription()
  • decode scanner_data

Refused scannerSubscriptionOptions and scannerSubscriptionFilterOptions, leaving only the ScannerSubscription builder (Instrument -> location -> ScanCode -> Filters).

/// # Example
///
/// let scanner_wo_filters = ScannerSubscription::us_stocks().us_major().top_perc_gain();
/// let scanner_w_filters = scanner_wo_filters.clone().market_cap_above1e6(1000.0).price_below(100.0);
///
/// client.req_scanner_subscription(scanner_w_filters).await;

I decode the contract from scanner_data_msg and create the structure:

pub struct ScannerContract {
pub result_number: i32, // remove?
pub contract_id: ContractId,
pub symbol: String,
pub sec_type: ContractType,
pub expiration_date: String,
pub strike: String,
pub class: String, // right
pub exchange: Routing,
pub currency: Currency,
pub local_symbol: String,
pub market_name: String,
pub trading_class: String,

pub distance: String,
pub benchmark: String,
pub projection: String,
pub legs_str: String,
}

Question: should we create another structure, like Contract(enum)? p.s There is also a scanner for native combos (with legs).

Limiters: In progress..

wvietor commented 1 month ago

Will try to merge this soon

7jrxt42BxFZo4iAnN4CX commented 1 month ago

It works. You can merge.