Module formatter

Module formatter 

Source
Expand description

Symbol formatter implementation

This module provides formatting functionality for converting ParsedSymbol structures back into unified symbol strings.

§Symbol Format

The unified symbol format follows the CCXT standard:

  • Spot: BASE/QUOTE (e.g., “BTC/USDT”)
  • Perpetual Swap: BASE/QUOTE:SETTLE (e.g., “BTC/USDT:USDT”)
  • Futures: BASE/QUOTE:SETTLE-YYMMDD (e.g., “BTC/USDT:USDT-241231”)

§Example

use ccxt_core::symbol::{ParsedSymbol, SymbolFormatter};
use ccxt_core::types::symbol::ExpiryDate;

// Format a spot symbol
let spot = ParsedSymbol::spot("BTC".to_string(), "USDT".to_string());
assert_eq!(SymbolFormatter::format(&spot), "BTC/USDT");

// Format a swap symbol
let swap = ParsedSymbol::linear_swap("BTC".to_string(), "USDT".to_string());
assert_eq!(SymbolFormatter::format(&swap), "BTC/USDT:USDT");

// Format a futures symbol
let expiry = ExpiryDate::new(24, 12, 31).unwrap();
let futures = ParsedSymbol::futures("BTC".to_string(), "USDT".to_string(), "USDT".to_string(), expiry);
assert_eq!(SymbolFormatter::format(&futures), "BTC/USDT:USDT-241231");

Structs§

SymbolFormatter
Symbol formatter for converting ParsedSymbol to unified symbol strings