Expand description
Client order id codec
Finam’s client_order_id holds at most 20 characters (alphabet not documented) and a UUID is
128 bits, so a UUID cannot be carried there losslessly. The order comment (“order label”,
up to 128 characters) can, and Finam echoes the whole Order in order state and the same label
in AccountTrade.comment. So:
- the lossless, reversible form (this codec) goes into
comment:bc1:<32 hex>; client_order_idcarries a 20-hex-char tag derived from the UUID (80 bits). It is not reversible, it is a secondary key used when the comment is missing in an echo.
That the comment is echoed back unchanged is not verified against the live API.
§Examples
use brokapi_core::{CidCodec, ClientOrderId};
use brokapi_finam::FinamCidCodec;
let codec = FinamCidCodec;
let cid = ClientOrderId::new_v4();
// The comment carries the whole id and decodes back to it.
let comment = codec.encode(cid).unwrap();
assert!(comment.as_str().starts_with("bc1:"));
assert_eq!(codec.decode(&comment), Some(cid));
// The `client_order_id` tag is short and cannot be decoded.
assert_eq!(codec.client_order_id(cid).len(), 20);Structs§
- Finam
CidCodec - Codec between the library’s client order id (a UUID) and the fields Finam stores on an order.
Constants§
- CLIENT_
ORDER_ ID_ MAX - Documented limit of
Order.client_order_id. - COMMENT_
MAX - Documented limit of
Order.comment. - COMMENT_
PREFIX - Marks a comment written by this library:
bc1:followed by 32 hex characters.