apple-quant-algorithmic 0.1.0

Apple Quant's algorithmic trading api
Documentation
use thiserror::Error;

mod bin;
mod engine;
mod latest_session_start;
mod point;
mod point_trade;
mod provider;
mod range;
mod range_trade;

pub use bin::*;
pub use engine::*;
pub use latest_session_start::*;
pub use point::*;
pub use point_trade::*;
pub use provider::*;
pub use range::*;
pub use range_trade::*;

#[derive(Debug, Error)]
pub enum TimestampError {
	// #[error("BinTimestamp already in use: {0:?}.")]
	// BinTimestampInUse(RuntimeBinTimestamp),

	// #[error(
	// 	"Unable to append {trade:?} with {trade_timestamp:?} older then the youngest {youngest_trade_timestamp:?}."
	// )]
	// TradeToOld {
	// 	trade: RuntimeTrade,
	// 	trade_timestamp: TradeTimestamp,
	// 	youngest_trade_timestamp: TradeTimestamp,
	// },

	// #[error(
	// 	"Unable to append {bar:?} with {bin_timestamp:?} older then the youngest {youngest_bin_timestamp:?}."
	// )]
	// BarToOld {
	// 	bar: RuntimeOHLC,
	// 	bin_timestamp: RuntimeBinTimestamp,
	// 	youngest_bin_timestamp: RuntimeBinTimestamp,
	// },
	#[error("Range is not satisfied. MIN: {min:?} MAX: {max:?}.")]
	RangeNotSatisfied {
		min: Option<TradeTimestamp>,
		max: Option<TradeTimestamp>,
	},
}

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

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

pub trait TimestampedRange {
	fn timestamp_range(&self) -> &TimestampRange;
}

pub trait TradeTimestampedRange {
	fn trade_timestamp_range(&self) -> &TradeTimestampRange;
}