apple-quant-algorithmic 0.3.0

Apple Quant's algorithmic library.
mod bin;
mod current_session_start;
mod engine;
mod point;
mod point_trade;
mod provider;
mod range;
mod range_trade;
mod tick;
mod utc_ns;

use thiserror::Error;
pub use bin::*;
pub use current_session_start::*;
pub use engine::*;
pub use point::*;
pub use point_trade::*;
pub use provider::*;
pub use range::*;
pub use range_trade::*;
pub use tick::*;
pub use utc_ns::*;

#[derive(Debug, Error)]
pub enum TimestampError {
	#[error("Range is not satisfied. Min: `{min:?}` max: `{max:?}`.")]
	RangeNotSatisfied {
		min: Option<TradeTimestamp>,
		max: Option<TradeTimestamp>,
	},
}

#[cfg(not(feature = "timestamp-u64"))]
pub type TimestampType = i128;

#[cfg(feature = "timestamp-u64")]
pub type TimestampType = u64;

pub trait Timestamped {
	fn timestamp(
		&self,
	) -> Timestamp;
}

pub trait TradeTimestamped {
	fn trade_timestamp(
		&self,
	) -> TradeTimestamp;
}

pub trait TimestampRangeIncluded {
	fn timestamp_range_inclusive(
		&self,
	) -> TimestampRangeInclusive;
}

pub trait TimestampRangeExcluded {
	fn timestamp_range_exclusive(
		&self,
	) -> TimestampRangeExclusive;
}

pub trait TradeTimestampRangeIncluded {
	fn trade_timestamp_range_inclusive(
		&self,
	) -> TradeTimestampRangeInclusive;
}

pub trait TradeTimestampRangeExcluded {
	fn trade_timestamp_range_exclusive(
		&self,
	) -> TradeTimestampRangeExclusive;
}