apple-quant-algorithmic 0.3.0

Apple Quant's algorithmic library.
use std::fmt::Write;

use databento::dbn::SType;
use smallstr::SmallString;

use crate::instrument::{InstrumentKind, InstrumentTicker};

pub(crate) trait Symbology {
	fn symbol(
		&self,
	) -> (SmallString<[u8; 8]>, SType);
}

impl Symbology for InstrumentTicker {
	fn symbol(
		&self,
	) -> (SmallString<[u8; 8]>, SType) {
		let mut symbol = SmallString::new();

		let stype = match self.instrument_kind() {
			InstrumentKind::Future => {
				write!(symbol, "{}.v.0", self.bare_symbol()).unwrap();
				SType::Continuous
			},
			_ => unimplemented!(),
		};

		(symbol, stype)
	}
}