-
Notifications
You must be signed in to change notification settings - Fork 316
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pcli: support
--limit-order
flag for tx orders
- Loading branch information
Showing
1 changed file
with
18 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -92,6 +92,9 @@ pub enum OrderCmd { | |
/// Only spend funds originally received by the given address index. | ||
#[clap(long, default_value = "0")] | ||
source: u32, | ||
/// When set, tags the position as being a limit-sell order. | ||
#[clap(long)] | ||
limit_order: bool, | ||
}, | ||
Sell { | ||
/// The desired sale, formatted as a string, e.g. `[email protected]` would attempt | ||
|
@@ -106,6 +109,9 @@ pub enum OrderCmd { | |
/// Only spend funds originally received by the given address index. | ||
#[clap(long, default_value = "0")] | ||
source: u32, | ||
/// When set, tags the position as being a limit-sell order. | ||
#[clap(long)] | ||
limit_order: bool, | ||
}, | ||
} | ||
|
||
|
@@ -124,13 +130,20 @@ impl OrderCmd { | |
} | ||
} | ||
|
||
pub fn limit_order(&self) -> bool { | ||
match self { | ||
OrderCmd::Buy { limit_order, .. } => *limit_order, | ||
OrderCmd::Sell { limit_order, .. } => *limit_order, | ||
} | ||
} | ||
|
||
pub fn into_position<R: CryptoRngCore>( | ||
&self, | ||
// Preserved since we'll need it after denom metadata refactor | ||
_asset_cache: &asset::Cache, | ||
rng: R, | ||
) -> Result<Position> { | ||
let position = match self { | ||
let mut position = match self { | ||
OrderCmd::Buy { buy_order, .. } => { | ||
tracing::info!(?buy_order, "parsing buy order"); | ||
let order = BuyOrder::parse_str(&buy_order)?; | ||
|
@@ -144,6 +157,10 @@ impl OrderCmd { | |
}; | ||
tracing::info!(?position); | ||
|
||
if self.limit_order() { | ||
position.close_on_fill = true; | ||
} | ||
|
||
Ok(position) | ||
} | ||
} |