use rust_decimal::Decimal;
use crate::constants::{UNSET_DOUBLE, UNSET_INTEGER};
use crate::enums::{OptionExerciseType, TriggerMethod};
pub type TickerId = i32;
pub type OrderId = i32;
pub type FaDataType = i32;
#[derive(Debug, Clone, Default, PartialEq, Eq)]
pub struct TagValue {
pub tag: String,
pub value: String,
}
#[derive(Debug, Clone, Default, PartialEq, Eq)]
pub struct SoftDollarTier {
pub name: String,
pub value: String,
pub display_name: String,
}
#[derive(Debug, Clone, Default, PartialEq, Eq)]
pub struct IneligibilityReason {
pub id: String,
pub description: String,
}
#[derive(Debug, Clone, Default, PartialEq, Eq)]
pub struct DepthMarketDataDescription {
pub exchange: String,
pub security_type: String,
pub listing_exchange: String,
pub service_data_type: String,
pub aggregate_group: i32,
}
#[derive(Debug, Clone, Copy, Default, PartialEq)]
pub struct PriceIncrement {
pub low_edge: f64,
pub increment: f64,
}
#[derive(Debug, Clone, Default, PartialEq)]
pub struct HistogramEntry {
pub price: f64,
pub size: Decimal,
}
#[derive(Debug, Clone, Default, PartialEq, Eq)]
pub struct FamilyCode {
pub account_id: String,
pub family_code: String,
}
#[derive(Debug, Clone, Default, PartialEq, Eq)]
pub struct NewsProvider {
pub code: String,
pub name: String,
}
#[derive(Debug, Clone, Default, PartialEq, Eq)]
pub struct WshEventData {
pub req_id: i32,
pub con_id: i32,
pub filter: String,
pub fill_watchlist: bool,
pub fill_portfolio: bool,
pub fill_position: bool,
pub fill_account: bool,
pub data_json: String,
}
impl WshEventData {
pub fn from_json(req_id: i32, data_json: impl Into<String>) -> Self {
let data_json = data_json.into();
#[derive(serde::Deserialize, Default)]
struct Raw {
#[serde(rename = "conId", default)]
con_id: i32,
#[serde(default)]
filter: String,
#[serde(rename = "fillWatchlist", default)]
fill_watchlist: bool,
#[serde(rename = "fillPortfolio", default)]
fill_portfolio: bool,
#[serde(rename = "fillPosition", default)]
fill_position: bool,
#[serde(rename = "fillAccount", default)]
fill_account: bool,
}
let raw = serde_json::from_str::<Raw>(&data_json).unwrap_or_default();
Self {
req_id,
con_id: raw.con_id,
filter: raw.filter,
fill_watchlist: raw.fill_watchlist,
fill_portfolio: raw.fill_portfolio,
fill_position: raw.fill_position,
fill_account: raw.fill_account,
data_json,
}
}
}
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
#[repr(i32)]
pub enum LegOpenClose {
#[default]
SamePosition = 0,
OpenPosition = 1,
ClosePosition = 2,
Unknown = 3,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ComboLeg {
pub con_id: i32,
pub ratio: i32,
pub action: String,
pub exchange: String,
pub open_close: LegOpenClose,
pub short_sale_slot: i32,
pub designated_location: String,
pub exempt_code: i32,
}
impl Default for ComboLeg {
fn default() -> Self {
Self {
con_id: 0,
ratio: 0,
action: String::new(),
exchange: String::new(),
open_close: LegOpenClose::SamePosition,
short_sale_slot: 0,
designated_location: String::new(),
exempt_code: -1,
}
}
}
#[derive(Debug, Clone, Default, PartialEq)]
pub struct DeltaNeutralContract {
pub con_id: i32,
pub delta: f64,
pub price: f64,
}
#[derive(Debug, Clone, PartialEq)]
pub struct Contract {
pub con_id: i32,
pub symbol: String,
pub sec_type: String,
pub last_trade_date_or_contract_month: String,
pub last_trade_date: String,
pub strike: f64,
pub right: String,
pub multiplier: String,
pub exchange: String,
pub primary_exchange: String,
pub currency: String,
pub local_symbol: String,
pub trading_class: String,
pub include_expired: bool,
pub sec_id_type: String,
pub sec_id: String,
pub description: String,
pub issuer_id: String,
pub combo_legs_description: String,
pub combo_legs: Vec<ComboLeg>,
pub delta_neutral_contract: Option<DeltaNeutralContract>,
}
impl Default for Contract {
fn default() -> Self {
Self {
con_id: 0,
symbol: String::new(),
sec_type: String::new(),
last_trade_date_or_contract_month: String::new(),
last_trade_date: String::new(),
strike: UNSET_DOUBLE,
right: String::new(),
multiplier: String::new(),
exchange: String::new(),
primary_exchange: String::new(),
currency: String::new(),
local_symbol: String::new(),
trading_class: String::new(),
include_expired: false,
sec_id_type: String::new(),
sec_id: String::new(),
description: String::new(),
issuer_id: String::new(),
combo_legs_description: String::new(),
combo_legs: Vec::new(),
delta_neutral_contract: None,
}
}
}
#[derive(Debug, Clone, Default, PartialEq)]
pub struct ContractDetails {
pub contract: Contract,
pub market_name: String,
pub min_tick: f64,
pub order_types: String,
pub valid_exchanges: String,
pub price_magnifier: i32,
pub under_con_id: i32,
pub long_name: String,
pub contract_month: String,
pub industry: String,
pub category: String,
pub subcategory: String,
pub time_zone_id: String,
pub trading_hours: String,
pub liquid_hours: String,
pub ev_rule: String,
pub ev_multiplier: f64,
pub sec_id_list: Vec<TagValue>,
pub aggregate_group: i32,
pub under_symbol: String,
pub under_sec_type: String,
pub market_rule_ids: String,
pub cusip: String,
pub issue_date: String,
pub ratings: String,
pub bond_type: String,
pub coupon: f64,
pub coupon_type: String,
pub convertible: bool,
pub callable: bool,
pub puttable: bool,
pub desc_append: String,
pub next_option_date: String,
pub next_option_type: String,
pub next_option_partial: bool,
pub bond_notes: String,
pub real_expiration_date: String,
pub stock_type: String,
pub min_size: Decimal,
pub size_increment: Decimal,
pub suggested_size_increment: Decimal,
pub fund_name: String,
pub fund_family: String,
pub fund_type: String,
pub fund_front_load: String,
pub fund_back_load: String,
pub fund_back_load_time_interval: String,
pub fund_management_fee: String,
pub fund_closed: bool,
pub fund_closed_for_new_investors: bool,
pub fund_closed_for_new_money: bool,
pub fund_notify_amount: String,
pub fund_minimum_initial_purchase: String,
pub fund_minimum_subsequent_purchase: String,
pub fund_blue_sky_states: String,
pub fund_blue_sky_territories: String,
pub fund_distribution_policy_indicator: String,
pub fund_asset_type: String,
pub ineligibility_reason_list: Vec<IneligibilityReason>,
pub event_contract1: String,
pub event_contract_description1: String,
pub event_contract_description2: String,
pub min_algo_size: Decimal,
pub last_price_precision: Decimal,
pub last_size_precision: Decimal,
}
#[derive(Debug, Clone, PartialEq)]
pub struct OrderComboLeg {
pub price: f64,
}
impl Default for OrderComboLeg {
fn default() -> Self {
Self {
price: UNSET_DOUBLE,
}
}
}
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
#[repr(i32)]
pub enum Origin {
#[default]
Customer = 0,
Firm = 1,
Unknown = 2,
}
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
#[repr(i32)]
pub enum AuctionStrategy {
#[default]
Unset = 0,
Match = 1,
Improvement = 2,
Transparent = 3,
}
#[derive(Debug, Clone, PartialEq)]
pub struct Order {
pub soft_dollar_tier: SoftDollarTier,
pub order_id: i32,
pub client_id: i32,
pub perm_id: i64,
pub action: String,
pub total_quantity: Decimal,
pub order_type: String,
pub limit_price: f64,
pub aux_price: f64,
pub tif: String,
pub active_start_time: String,
pub active_stop_time: String,
pub oca_group: String,
pub oca_type: i32,
pub order_ref: String,
pub transmit: bool,
pub parent_id: i32,
pub block_order: bool,
pub sweep_to_fill: bool,
pub display_size: i32,
pub trigger_method: i32,
pub outside_rth: bool,
pub hidden: bool,
pub good_after_time: String,
pub good_till_date: String,
pub rule80a: String,
pub all_or_none: bool,
pub min_qty: i32,
pub percent_offset: f64,
pub override_percentage_constraints: bool,
pub trail_stop_price: f64,
pub trailing_percent: f64,
pub fa_group: String,
pub fa_method: String,
pub fa_percentage: String,
pub designated_location: String,
pub open_close: String,
pub origin: Origin,
pub short_sale_slot: i32,
pub exempt_code: i32,
pub discretionary_amount: f64,
pub opt_out_smart_routing: bool,
pub auction_strategy: AuctionStrategy,
pub starting_price: f64,
pub stock_ref_price: f64,
pub delta: f64,
pub stock_range_lower: f64,
pub stock_range_upper: f64,
pub randomize_price: bool,
pub randomize_size: bool,
pub volatility: f64,
pub volatility_type: i32,
pub delta_neutral_order_type: String,
pub delta_neutral_aux_price: f64,
pub delta_neutral_con_id: i32,
pub delta_neutral_settling_firm: String,
pub delta_neutral_clearing_account: String,
pub delta_neutral_clearing_intent: String,
pub delta_neutral_open_close: String,
pub delta_neutral_short_sale: bool,
pub delta_neutral_short_sale_slot: i32,
pub delta_neutral_designated_location: String,
pub continuous_update: bool,
pub reference_price_type: i32,
pub basis_points: f64,
pub basis_points_type: i32,
pub scale_init_level_size: i32,
pub scale_subs_level_size: i32,
pub scale_price_increment: f64,
pub scale_price_adjust_value: f64,
pub scale_price_adjust_interval: i32,
pub scale_profit_offset: f64,
pub scale_auto_reset: bool,
pub scale_init_position: i32,
pub scale_init_fill_qty: i32,
pub scale_random_percent: bool,
pub scale_table: String,
pub hedge_type: String,
pub hedge_param: String,
pub hedge_max_size: i32,
pub account: String,
pub settling_firm: String,
pub clearing_account: String,
pub clearing_intent: String,
pub model_code: String,
pub algo_strategy: String,
pub algo_params: Vec<TagValue>,
pub smart_combo_routing_params: Vec<TagValue>,
pub algo_id: String,
pub what_if: bool,
pub not_held: bool,
pub solicited: bool,
pub order_combo_legs: Vec<OrderComboLeg>,
pub order_misc_options: Vec<TagValue>,
pub reference_contract_id: i32,
pub pegged_change_amount: f64,
pub is_pegged_change_amount_decrease: bool,
pub reference_change_amount: f64,
pub reference_exchange_id: String,
pub adjusted_order_type: String,
pub trigger_price: f64,
pub adjusted_stop_price: f64,
pub adjusted_stop_limit_price: f64,
pub adjusted_trailing_amount: f64,
pub adjustable_trailing_unit: i32,
pub limit_price_offset: f64,
pub conditions: Vec<OrderCondition>,
pub conditions_cancel_order: bool,
pub conditions_ignore_rth: bool,
pub ext_operator: String,
pub cash_qty: f64,
pub mifid2_decision_maker: String,
pub mifid2_decision_algo: String,
pub mifid2_execution_trader: String,
pub mifid2_execution_algo: String,
pub dont_use_auto_price_for_hedge: bool,
pub is_oms_container: bool,
pub discretionary_up_to_limit_price: bool,
pub auto_cancel_date: String,
pub filled_quantity: Decimal,
pub ref_futures_con_id: i32,
pub auto_cancel_parent: bool,
pub shareholder: String,
pub imbalance_only: bool,
pub route_marketable_to_bbo: i32,
pub parent_perm_id: i64,
pub use_price_mgmt_algo: i32,
pub duration: i32,
pub post_to_ats: i32,
pub advanced_error_override: String,
pub manual_order_time: String,
pub min_trade_qty: i32,
pub min_compete_size: i32,
pub compete_against_best_offset: f64,
pub mid_offset_at_whole: f64,
pub mid_offset_at_half: f64,
pub customer_account: String,
pub professional_customer: bool,
pub bond_accrued_interest: String,
pub include_overnight: bool,
pub manual_order_indicator: i32,
pub submitter: String,
pub post_only: bool,
pub allow_pre_open: bool,
pub ignore_open_auction: bool,
pub deactivate: bool,
pub seek_price_improvement: i32,
pub what_if_type: i32,
pub stop_loss_order_id: i32,
pub stop_loss_order_type: String,
pub profit_taker_order_id: i32,
pub profit_taker_order_type: String,
}
impl Default for Order {
fn default() -> Self {
Self {
soft_dollar_tier: SoftDollarTier::default(),
order_id: 0,
client_id: 0,
perm_id: 0,
action: String::new(),
total_quantity: Decimal::from_i128_with_scale(0, 0),
order_type: String::new(),
limit_price: UNSET_DOUBLE,
aux_price: UNSET_DOUBLE,
tif: String::new(),
active_start_time: String::new(),
active_stop_time: String::new(),
oca_group: String::new(),
oca_type: 0,
order_ref: String::new(),
transmit: true,
parent_id: 0,
block_order: false,
sweep_to_fill: false,
display_size: 0,
trigger_method: 0,
outside_rth: false,
hidden: false,
good_after_time: String::new(),
good_till_date: String::new(),
rule80a: String::new(),
all_or_none: false,
min_qty: UNSET_INTEGER,
percent_offset: UNSET_DOUBLE,
override_percentage_constraints: false,
trail_stop_price: UNSET_DOUBLE,
trailing_percent: UNSET_DOUBLE,
fa_group: String::new(),
fa_method: String::new(),
fa_percentage: String::new(),
designated_location: String::new(),
open_close: String::new(),
origin: Origin::Customer,
short_sale_slot: 0,
exempt_code: -1,
discretionary_amount: 0.0,
opt_out_smart_routing: false,
auction_strategy: AuctionStrategy::Unset,
starting_price: UNSET_DOUBLE,
stock_ref_price: UNSET_DOUBLE,
delta: UNSET_DOUBLE,
stock_range_lower: UNSET_DOUBLE,
stock_range_upper: UNSET_DOUBLE,
randomize_price: false,
randomize_size: false,
volatility: UNSET_DOUBLE,
volatility_type: UNSET_INTEGER,
delta_neutral_order_type: String::new(),
delta_neutral_aux_price: UNSET_DOUBLE,
delta_neutral_con_id: 0,
delta_neutral_settling_firm: String::new(),
delta_neutral_clearing_account: String::new(),
delta_neutral_clearing_intent: String::new(),
delta_neutral_open_close: String::new(),
delta_neutral_short_sale: false,
delta_neutral_short_sale_slot: 0,
delta_neutral_designated_location: String::new(),
continuous_update: false,
reference_price_type: UNSET_INTEGER,
basis_points: UNSET_DOUBLE,
basis_points_type: UNSET_INTEGER,
scale_init_level_size: UNSET_INTEGER,
scale_subs_level_size: UNSET_INTEGER,
scale_price_increment: UNSET_DOUBLE,
scale_price_adjust_value: UNSET_DOUBLE,
scale_price_adjust_interval: UNSET_INTEGER,
scale_profit_offset: UNSET_DOUBLE,
scale_auto_reset: false,
scale_init_position: UNSET_INTEGER,
scale_init_fill_qty: UNSET_INTEGER,
scale_random_percent: false,
scale_table: String::new(),
hedge_type: String::new(),
hedge_param: String::new(),
hedge_max_size: UNSET_INTEGER,
account: String::new(),
settling_firm: String::new(),
clearing_account: String::new(),
clearing_intent: String::new(),
model_code: String::new(),
algo_strategy: String::new(),
algo_params: Vec::new(),
smart_combo_routing_params: Vec::new(),
algo_id: String::new(),
what_if: false,
not_held: false,
solicited: false,
order_combo_legs: Vec::new(),
order_misc_options: Vec::new(),
reference_contract_id: 0,
pegged_change_amount: 0.0,
is_pegged_change_amount_decrease: false,
reference_change_amount: 0.0,
reference_exchange_id: String::new(),
adjusted_order_type: String::new(),
trigger_price: UNSET_DOUBLE,
adjusted_stop_price: UNSET_DOUBLE,
adjusted_stop_limit_price: UNSET_DOUBLE,
adjusted_trailing_amount: UNSET_DOUBLE,
adjustable_trailing_unit: 0,
limit_price_offset: UNSET_DOUBLE,
conditions: Vec::new(),
conditions_cancel_order: false,
conditions_ignore_rth: false,
ext_operator: String::new(),
cash_qty: UNSET_DOUBLE,
mifid2_decision_maker: String::new(),
mifid2_decision_algo: String::new(),
mifid2_execution_trader: String::new(),
mifid2_execution_algo: String::new(),
dont_use_auto_price_for_hedge: false,
is_oms_container: false,
discretionary_up_to_limit_price: false,
auto_cancel_date: String::new(),
filled_quantity: Decimal::from_i128_with_scale(0, 0),
ref_futures_con_id: 0,
auto_cancel_parent: false,
shareholder: String::new(),
imbalance_only: false,
route_marketable_to_bbo: UNSET_INTEGER,
parent_perm_id: 0,
use_price_mgmt_algo: UNSET_INTEGER,
duration: UNSET_INTEGER,
post_to_ats: UNSET_INTEGER,
advanced_error_override: String::new(),
manual_order_time: String::new(),
min_trade_qty: UNSET_INTEGER,
min_compete_size: UNSET_INTEGER,
compete_against_best_offset: UNSET_DOUBLE,
mid_offset_at_whole: UNSET_DOUBLE,
mid_offset_at_half: UNSET_DOUBLE,
customer_account: String::new(),
professional_customer: false,
bond_accrued_interest: String::new(),
include_overnight: false,
manual_order_indicator: UNSET_INTEGER,
submitter: String::new(),
post_only: false,
allow_pre_open: false,
ignore_open_auction: false,
deactivate: false,
seek_price_improvement: UNSET_INTEGER,
what_if_type: UNSET_INTEGER,
stop_loss_order_id: UNSET_INTEGER,
stop_loss_order_type: String::new(),
profit_taker_order_id: UNSET_INTEGER,
profit_taker_order_type: String::new(),
}
}
}
#[derive(Debug, Clone, Default, PartialEq, Eq)]
pub struct OrderCancel {
pub manual_order_cancel_time: String,
pub ext_operator: String,
pub manual_order_indicator: i32,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ExecutionFilter {
pub client_id: i32,
pub acct_code: String,
pub time: String,
pub symbol: String,
pub sec_type: String,
pub exchange: String,
pub side: String,
pub last_n_days: i32,
pub specific_dates: Vec<i32>,
}
impl Default for ExecutionFilter {
fn default() -> Self {
Self {
client_id: 0,
acct_code: String::new(),
time: String::new(),
symbol: String::new(),
sec_type: String::new(),
exchange: String::new(),
side: String::new(),
last_n_days: UNSET_INTEGER,
specific_dates: Vec::new(),
}
}
}
#[derive(Debug, Clone, Default, PartialEq)]
pub struct Execution {
pub order_id: i32,
pub exec_id: String,
pub time: String,
pub acct_number: String,
pub exchange: String,
pub side: String,
pub shares: Decimal,
pub price: f64,
pub perm_id: i64,
pub client_id: i32,
pub liquidation: i32,
pub cum_qty: Decimal,
pub avg_price: f64,
pub order_ref: String,
pub ev_rule: String,
pub ev_multiplier: f64,
pub model_code: String,
pub last_liquidity: i32,
pub pending_price_revision: bool,
pub submitter: String,
pub opt_exercise_or_lapse_type: i32,
}
#[derive(Debug, Clone, Default, PartialEq)]
pub struct OrderAllocation {
pub account: String,
pub position: Decimal,
pub position_desired: Decimal,
pub position_after: Decimal,
pub desired_alloc_qty: Decimal,
pub allowed_alloc_qty: Decimal,
pub is_monetary: bool,
}
#[derive(Debug, Clone, Default, PartialEq)]
pub struct OrderState {
pub status: String,
pub init_margin_before: f64,
pub maint_margin_before: f64,
pub equity_with_loan_before: f64,
pub init_margin_change: f64,
pub maint_margin_change: f64,
pub equity_with_loan_change: f64,
pub init_margin_after: f64,
pub maint_margin_after: f64,
pub equity_with_loan_after: f64,
pub commission_and_fees: f64,
pub min_commission_and_fees: f64,
pub max_commission_and_fees: f64,
pub commission_and_fees_currency: String,
pub margin_currency: String,
pub init_margin_before_outside_rth: f64,
pub maint_margin_before_outside_rth: f64,
pub equity_with_loan_before_outside_rth: f64,
pub init_margin_change_outside_rth: f64,
pub maint_margin_change_outside_rth: f64,
pub equity_with_loan_change_outside_rth: f64,
pub init_margin_after_outside_rth: f64,
pub maint_margin_after_outside_rth: f64,
pub equity_with_loan_after_outside_rth: f64,
pub suggested_size: String,
pub reject_reason: String,
pub order_allocations: Vec<OrderAllocation>,
pub warning_text: String,
pub completed_time: String,
pub completed_status: String,
}
#[derive(Debug, Clone, Default, PartialEq)]
pub struct CommissionAndFeesReport {
pub exec_id: String,
pub commission_and_fees: f64,
pub currency: String,
pub realized_pnl: f64,
pub bond_yield: f64,
pub yield_redemption_date: String,
}
#[derive(Debug, Clone, Default, PartialEq)]
pub struct ContractDescription {
pub contract: Contract,
pub derivative_sec_types: Vec<String>,
}
#[derive(Debug, Clone, Default, PartialEq, Eq)]
pub struct SmartComponent {
pub bit_number: i32,
pub exchange: String,
pub exchange_letter: String,
}
#[derive(Debug, Clone, Default, PartialEq, Eq)]
pub struct HistoricalSession {
pub start_date_time: String,
pub end_date_time: String,
pub ref_date: String,
}
#[derive(Debug, Clone, Default, PartialEq)]
pub struct HistoricalTick {
pub time: i64,
pub price: f64,
pub size: Decimal,
}
#[derive(Debug, Clone, Default, PartialEq, Eq)]
pub struct TickAttribBidAsk {
pub bid_past_low: bool,
pub ask_past_high: bool,
}
#[derive(Debug, Clone, Default, PartialEq, Eq)]
pub struct TickAttribLast {
pub past_limit: bool,
pub unreported: bool,
}
#[derive(Debug, Clone, Default, PartialEq)]
pub struct HistoricalTickBidAsk {
pub time: i64,
pub tick_attrib_bid_ask: TickAttribBidAsk,
pub price_bid: f64,
pub price_ask: f64,
pub size_bid: Decimal,
pub size_ask: Decimal,
}
#[derive(Debug, Clone, Default, PartialEq)]
pub struct HistoricalTickLast {
pub time: i64,
pub tick_attrib_last: TickAttribLast,
pub price: f64,
pub size: Decimal,
pub exchange: String,
pub special_conditions: String,
}
#[derive(Debug, Clone, PartialEq)]
pub enum TickByTick {
Last(HistoricalTickLast),
BidAsk(HistoricalTickBidAsk),
MidPoint(HistoricalTick),
}
#[derive(Debug, Clone, Default, PartialEq)]
pub struct ScannerSubscription {
pub number_of_rows: i32,
pub instrument: String,
pub location_code: String,
pub scan_code: String,
pub above_price: f64,
pub below_price: f64,
pub above_volume: i32,
pub market_cap_above: f64,
pub market_cap_below: f64,
pub moody_rating_above: String,
pub moody_rating_below: String,
pub sp_rating_above: String,
pub sp_rating_below: String,
pub maturity_date_above: String,
pub maturity_date_below: String,
pub coupon_rate_above: f64,
pub coupon_rate_below: f64,
pub exclude_convertible: bool,
pub average_option_volume_above: i32,
pub scanner_setting_pairs: String,
pub stock_type_filter: String,
}
#[derive(Debug, Clone, PartialEq)]
pub enum OrderCondition {
Price {
is_conjunction_connection: bool,
trigger_method: i32,
con_id: i32,
exchange: String,
is_more: bool,
price: f64,
},
Time {
is_conjunction_connection: bool,
is_more: bool,
time: String,
},
Margin {
is_conjunction_connection: bool,
is_more: bool,
percent: f64,
},
Execution {
is_conjunction_connection: bool,
sec_type: String,
exchange: String,
symbol: String,
},
Volume {
is_conjunction_connection: bool,
con_id: i32,
exchange: String,
is_more: bool,
volume: i32,
},
PercentChange {
is_conjunction_connection: bool,
con_id: i32,
exchange: String,
is_more: bool,
change_percent: f64,
},
}
impl OrderCondition {
pub fn trigger_method(&self) -> Option<TriggerMethod> {
match self {
Self::Price { trigger_method, .. } => Some(TriggerMethod::from_i32(*trigger_method)),
_ => None,
}
}
}
impl Execution {
pub const fn option_exercise_type(&self) -> OptionExerciseType {
OptionExerciseType::from_i32(self.opt_exercise_or_lapse_type)
}
pub const fn liquidity(&self) -> crate::enums::Liquidities {
crate::enums::Liquidities::from_i32(self.last_liquidity)
}
}
#[derive(Debug, Clone, Default, PartialEq)]
pub struct BarData {
pub date: String,
pub open: f64,
pub high: f64,
pub low: f64,
pub close: f64,
pub volume: Decimal,
pub wap: Decimal,
pub bar_count: i32,
}
#[derive(Debug, Clone, Default, PartialEq)]
pub struct RealTimeBar {
pub time: i64,
pub end_time: i64,
pub open: f64,
pub high: f64,
pub low: f64,
pub close: f64,
pub volume: Decimal,
pub wap: Decimal,
pub count: i32,
}