Skip to main content

urisafe_instrument_id

Function urisafe_instrument_id 

Source
pub fn urisafe_instrument_id(instrument_id: &str) -> String
Expand description

Converts an instrument ID to a URI-safe format by removing forward slashes and replacing carets with underscores.

Some instrument IDs contain forward slashes (e.g., “BTC/USD”) which are not suitable for use in file paths. This function transforms these characters to create a safe directory name.

§Parameters

  • instrument_id: The original instrument ID string.

§Returns

A URI-safe version of the instrument ID with forward slashes removed and carets replaced.

§Examples

assert_eq!(urisafe_instrument_id("BTC/USD"), "BTCUSD");
assert_eq!(urisafe_instrument_id("EUR-USD"), "EUR-USD");
assert_eq!(urisafe_instrument_id("^SPX.CBOE"), "_SPX.CBOE");