pub struct TradingSummaryGenerator {
pub risk_free_return: Decimal,
pub time_engine_start: DateTime<Utc>,
pub time_engine_now: DateTime<Utc>,
pub instruments: FnvIndexMap<InstrumentNameInternal, TearSheetGenerator>,
pub assets: FnvIndexMap<ExchangeAsset<AssetNameInternal>, TearSheetAssetGenerator>,
}Expand description
Generator for a TradingSummary.
Fields§
§risk_free_return: DecimalTheoretical rate of return of an investment with zero risk.
See docs: https://www.investopedia.com/terms/r/risk-freerate.asp
time_engine_start: DateTime<Utc>Trading session summary start time defined by the Engine clock.
time_engine_now: DateTime<Utc>Trading session summary most recent update time defined by the
Engine clock.
instruments: FnvIndexMap<InstrumentNameInternal, TearSheetGenerator>Instrument TearSheetGenerators.
Note that an Instrument is unique to an exchange, so, for example, Binance btc_usdt_spot
and Okx btc_usdt_spot will be summarised by distinct TearSheets.
assets: FnvIndexMap<ExchangeAsset<AssetNameInternal>, TearSheetAssetGenerator>Implementations§
Source§impl TradingSummaryGenerator
impl TradingSummaryGenerator
pub const fn new( risk_free_return: Decimal, time_engine_start: DateTime<Utc>, time_engine_now: DateTime<Utc>, instruments: FnvIndexMap<InstrumentNameInternal, TearSheetGenerator>, assets: FnvIndexMap<ExchangeAsset<AssetNameInternal>, TearSheetAssetGenerator>, ) -> TradingSummaryGenerator
Source§impl TradingSummaryGenerator
impl TradingSummaryGenerator
Sourcepub fn init<InstrumentData>(
risk_free_return: Decimal,
time_engine_start: DateTime<Utc>,
time_engine_now: DateTime<Utc>,
instruments: &InstrumentStates<InstrumentData>,
assets: &AssetStates,
) -> Self
pub fn init<InstrumentData>( risk_free_return: Decimal, time_engine_start: DateTime<Utc>, time_engine_now: DateTime<Utc>, instruments: &InstrumentStates<InstrumentData>, assets: &AssetStates, ) -> Self
Initialise a TradingSummaryGenerator from a risk_free_return value, and initial
indexed state.
Sourcepub fn update_time_now(&mut self, time_now: DateTime<Utc>)
pub fn update_time_now(&mut self, time_now: DateTime<Utc>)
Update the TradingSummaryGenerator time_now.
Sourcepub fn update_from_position<AssetKey, InstrumentKey>(
&mut self,
position: &PositionExited<AssetKey, InstrumentKey>,
)where
Self: InstrumentTearSheetManager<InstrumentKey>,
pub fn update_from_position<AssetKey, InstrumentKey>(
&mut self,
position: &PositionExited<AssetKey, InstrumentKey>,
)where
Self: InstrumentTearSheetManager<InstrumentKey>,
Update the TradingSummaryGenerator from the next PositionExited.
Sourcepub fn update_from_balance<AssetKey>(
&mut self,
balance: Snapshot<&AssetBalance<AssetKey>>,
)where
Self: AssetTearSheetManager<AssetKey>,
pub fn update_from_balance<AssetKey>(
&mut self,
balance: Snapshot<&AssetBalance<AssetKey>>,
)where
Self: AssetTearSheetManager<AssetKey>,
Update the TradingSummaryGenerator from the next Snapshot AssetBalance.
Sourcepub fn generate<Interval>(
&mut self,
interval: Interval,
) -> TradingSummary<Interval>where
Interval: TimeInterval,
pub fn generate<Interval>(
&mut self,
interval: Interval,
) -> TradingSummary<Interval>where
Interval: TimeInterval,
Generate the latest TradingSummary at the specific TimeInterval.
For example, pass Annual365 to generate a crypto-centric
(24/7 trading) annualised TradingSummary.
Trait Implementations§
Source§impl AssetTearSheetManager<AssetIndex> for TradingSummaryGenerator
impl AssetTearSheetManager<AssetIndex> for TradingSummaryGenerator
fn asset(&self, key: &AssetIndex) -> &TearSheetAssetGenerator
fn asset_mut(&mut self, key: &AssetIndex) -> &mut TearSheetAssetGenerator
Source§impl AssetTearSheetManager<ExchangeAsset<AssetNameInternal>> for TradingSummaryGenerator
impl AssetTearSheetManager<ExchangeAsset<AssetNameInternal>> for TradingSummaryGenerator
fn asset( &self, key: &ExchangeAsset<AssetNameInternal>, ) -> &TearSheetAssetGenerator
fn asset_mut( &mut self, key: &ExchangeAsset<AssetNameInternal>, ) -> &mut TearSheetAssetGenerator
Source§impl Clone for TradingSummaryGenerator
impl Clone for TradingSummaryGenerator
Source§impl Debug for TradingSummaryGenerator
impl Debug for TradingSummaryGenerator
Source§impl<'de> Deserialize<'de> for TradingSummaryGenerator
impl<'de> Deserialize<'de> for TradingSummaryGenerator
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl InstrumentTearSheetManager<InstrumentIndex> for TradingSummaryGenerator
impl InstrumentTearSheetManager<InstrumentIndex> for TradingSummaryGenerator
fn instrument(&self, key: &InstrumentIndex) -> &TearSheetGenerator
fn instrument_mut(&mut self, key: &InstrumentIndex) -> &mut TearSheetGenerator
Source§impl InstrumentTearSheetManager<InstrumentNameInternal> for TradingSummaryGenerator
impl InstrumentTearSheetManager<InstrumentNameInternal> for TradingSummaryGenerator
fn instrument(&self, key: &InstrumentNameInternal) -> &TearSheetGenerator
fn instrument_mut( &mut self, key: &InstrumentNameInternal, ) -> &mut TearSheetGenerator
Source§impl PartialEq for TradingSummaryGenerator
impl PartialEq for TradingSummaryGenerator
Source§impl Serialize for TradingSummaryGenerator
impl Serialize for TradingSummaryGenerator
impl StructuralPartialEq for TradingSummaryGenerator
Auto Trait Implementations§
impl Freeze for TradingSummaryGenerator
impl RefUnwindSafe for TradingSummaryGenerator
impl Send for TradingSummaryGenerator
impl Sync for TradingSummaryGenerator
impl Unpin for TradingSummaryGenerator
impl UnsafeUnpin for TradingSummaryGenerator
impl UnwindSafe for TradingSummaryGenerator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more