Skip to content

Commit

Permalink
cleanup warnings (#114)
Browse files Browse the repository at this point in the history
Co-authored-by: Wil Boayue <wboayue@gmail.com>
  • Loading branch information
wboayue and Wil Boayue committed May 21, 2024
1 parent 463daf9 commit ee926a1
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 30 deletions.
2 changes: 1 addition & 1 deletion src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -993,7 +993,7 @@ fn parse_connection_time(connection_time: &str) -> (Option<OffsetDateTime>, Opti
},
Err(err) => {
error!("could not parse connection time from {date_str}: {err}");
return (None, Some(timezone));
(None, Some(timezone))
}
}
}
Expand Down
60 changes: 33 additions & 27 deletions src/orders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -600,14 +600,16 @@ impl ToField for Action {
}
}

impl ToString for Action {
fn to_string(&self) -> String {
match self {
Action::Buy => String::from("BUY"),
Action::Sell => String::from("SELL"),
Action::SellShort => String::from("SSHORT"),
Action::SellLong => String::from("SLONG"),
}
impl std::fmt::Display for Action {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let text = match self {
Action::Buy => "BUY",
Action::Sell => "SELL",
Action::SellShort => "SSHORT",
Action::SellLong => "SLONG",
};

write!(f, "{text}")
}
}

Expand Down Expand Up @@ -657,19 +659,21 @@ impl ToField for Option<Rule80A> {
}
}

impl ToString for Rule80A {
fn to_string(&self) -> String {
match self {
Rule80A::Individual => String::from('I'),
Rule80A::Agency => String::from('A'),
Rule80A::AgentOtherMember => String::from('W'),
Rule80A::IndividualPTIA => String::from('J'),
Rule80A::AgencyPTIA => String::from('U'),
Rule80A::AgentOtherMemberPTIA => String::from('M'),
Rule80A::IndividualPT => String::from('K'),
Rule80A::AgencyPT => String::from('Y'),
Rule80A::AgentOtherMemberPT => String::from('N'),
}
impl std::fmt::Display for Rule80A {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let text = match self {
Rule80A::Individual => "I",
Rule80A::Agency => "A",
Rule80A::AgentOtherMember => "W",
Rule80A::IndividualPTIA => "J",
Rule80A::AgencyPTIA => "U",
Rule80A::AgentOtherMemberPTIA => "M",
Rule80A::IndividualPT => "K",
Rule80A::AgencyPT => "Y",
Rule80A::AgentOtherMemberPT => "N",
};

write!(f, "{text}")
}
}

Expand Down Expand Up @@ -816,12 +820,14 @@ impl ToField for Option<OrderOpenClose> {
}
}

impl ToString for OrderOpenClose {
fn to_string(&self) -> String {
match self {
OrderOpenClose::Open => String::from("O"),
OrderOpenClose::Close => String::from("C"),
}
impl std::fmt::Display for OrderOpenClose {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let text = match self {
OrderOpenClose::Open => "O",
OrderOpenClose::Close => "C",
};

write!(f, "{text}")
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/orders/order_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,7 @@ pub fn attach_adjustable_to_trail(

order.parent_id = parent.order_id;
order.trigger_price = Some(trigger_price); // When trigger price is penetrated
order.adjusted_order_type = "TRAIL".to_owned(); // The parent order will be turned into a TRAIL order
"TRAIL".clone_into(&mut order.adjusted_order_type); // The parent order will be turned into a TRAIL order
order.adjusted_stop_price = Some(adjusted_stop_price); // With a stop price of ...
order.adjustable_trailing_unit = trail_unit; // trailing by and amount (0) or a percent (100) ...
order.adjusted_trailing_amount = Some(adjusted_trail_amount); // of ...
Expand Down Expand Up @@ -915,7 +915,7 @@ pub fn limit_ibkrats(action: Action, quantity: f64, limit_price: f64) -> Order {

pub fn limit_order_with_manual_order_time(action: Action, quantity: f64, limit_price: f64, manual_order_time: &str) -> Order {
let mut order = limit_order(action, quantity, limit_price);
order.manual_order_time = manual_order_time.to_owned();
manual_order_time.clone_into(&mut order.manual_order_time);

order
}
Expand Down

0 comments on commit ee926a1

Please sign in to comment.