Skip to main content

price_to_quotation

Function price_to_quotation 

Source
pub fn price_to_quotation(price: Price) -> Result<Quotation, Error>
Expand description

A [Price] as the [Quotation] a request carries, exactly.

§Errors

[Error::Rejected] with code invalid_price when the price has more than 9 decimal places (T-Bank counts in billionths) or does not fit. The price is never rounded in silence.

§Examples

use brokapi_core::Price;
use brokapi_tbank::ids::price_to_quotation;

let q = price_to_quotation("244.30".parse::<Price>()?)?;
assert_eq!((q.units, q.nano), (244, 300_000_000));
assert!(price_to_quotation("0.0000000001".parse::<Price>()?).is_err());