pub struct CashAccount {
pub base: BaseAccount,
}
Fields§
§base: BaseAccount
Implementations§
Source§impl CashAccount
impl CashAccount
Sourcepub fn new(event: AccountState, calculate_account_state: bool) -> Self
pub fn new(event: AccountState, calculate_account_state: bool) -> Self
Creates a new CashAccount
instance.
pub fn is_cash_account(&self) -> bool
pub fn is_margin_account(&self) -> bool
pub const fn is_unleveraged(&self) -> bool
Sourcepub fn recalculate_balance(&mut self, currency: Currency)
pub fn recalculate_balance(&mut self, currency: Currency)
Recalculates the account balance for the specified currency based on current margins.
§Panics
Panics if conversion from Decimal
to f64
fails during balance update.
Source§impl CashAccount
impl CashAccount
pub fn py_new(event: AccountState, calculate_account_state: bool) -> Self
Methods from Deref<Target = BaseAccount>§
Sourcepub fn base_balance(
&self,
currency: Option<Currency>,
) -> Option<&AccountBalance>
pub fn base_balance( &self, currency: Option<Currency>, ) -> Option<&AccountBalance>
Returns a reference to the AccountBalance
for the specified currency, or None
if absent.
§Panics
Panics if currency
is None
and self.base_currency
is None
.
Sourcepub fn base_balance_total(&self, currency: Option<Currency>) -> Option<Money>
pub fn base_balance_total(&self, currency: Option<Currency>) -> Option<Money>
Returns the total Money
balance for the specified currency, or None
if absent.
§Panics
Panics if currency
is None
and self.base_currency
is None
.
pub fn base_balances_total(&self) -> HashMap<Currency, Money>
Sourcepub fn base_balance_free(&self, currency: Option<Currency>) -> Option<Money>
pub fn base_balance_free(&self, currency: Option<Currency>) -> Option<Money>
Returns the free Money
balance for the specified currency, or None
if absent.
§Panics
Panics if currency
is None
and self.base_currency
is None
.
pub fn base_balances_free(&self) -> HashMap<Currency, Money>
Sourcepub fn base_balance_locked(&self, currency: Option<Currency>) -> Option<Money>
pub fn base_balance_locked(&self, currency: Option<Currency>) -> Option<Money>
Returns the locked Money
balance for the specified currency, or None
if absent.
§Panics
Panics if currency
is None
and self.base_currency
is None
.
pub fn base_balances_locked(&self) -> HashMap<Currency, Money>
pub fn base_last_event(&self) -> Option<AccountState>
Sourcepub fn update_balances(&mut self, balances: Vec<AccountBalance>)
pub fn update_balances(&mut self, balances: Vec<AccountBalance>)
Updates the account balances with the provided list of AccountBalance
instances.
§Panics
Panics if any updated AccountBalance
has a total less than zero.
pub fn update_commissions(&mut self, commission: Money)
pub fn base_apply(&mut self, event: AccountState)
Sourcepub fn base_purge_account_events(
&mut self,
ts_now: UnixNanos,
lookback_secs: u64,
)
pub fn base_purge_account_events( &mut self, ts_now: UnixNanos, lookback_secs: u64, )
Purges all account state events which are outside the lookback window.
Guaranteed to retain at least the latest event.
§Panics
Panics if the purging implementation is changed and all events are purged.
Sourcepub fn base_calculate_balance_locked(
&mut self,
instrument: InstrumentAny,
side: OrderSide,
quantity: Quantity,
price: Price,
use_quote_for_inverse: Option<bool>,
) -> Result<Money>
pub fn base_calculate_balance_locked( &mut self, instrument: InstrumentAny, side: OrderSide, quantity: Quantity, price: Price, use_quote_for_inverse: Option<bool>, ) -> Result<Money>
Calculates the amount of balance to lock for a new order based on the given side, quantity, and price.
§Errors
This function never returns an error (TBD).
§Panics
Panics if side
is not OrderSide::Buy
or OrderSide::Sell
.
Sourcepub fn base_calculate_pnls(
&self,
instrument: InstrumentAny,
fill: OrderFilled,
position: Option<Position>,
) -> Result<Vec<Money>>
pub fn base_calculate_pnls( &self, instrument: InstrumentAny, fill: OrderFilled, position: Option<Position>, ) -> Result<Vec<Money>>
Calculates profit and loss amounts for a filled order.
§Errors
This function never returns an error (TBD).
§Panics
Panics if fill.order_side
is neither OrderSide::Buy
nor OrderSide::Sell
.
Sourcepub fn base_calculate_commission(
&self,
instrument: InstrumentAny,
last_qty: Quantity,
last_px: Price,
liquidity_side: LiquiditySide,
use_quote_for_inverse: Option<bool>,
) -> Result<Money>
pub fn base_calculate_commission( &self, instrument: InstrumentAny, last_qty: Quantity, last_px: Price, liquidity_side: LiquiditySide, use_quote_for_inverse: Option<bool>, ) -> Result<Money>
Trait Implementations§
Source§impl Account for CashAccount
impl Account for CashAccount
fn id(&self) -> AccountId
fn account_type(&self) -> AccountType
fn base_currency(&self) -> Option<Currency>
fn is_cash_account(&self) -> bool
fn is_margin_account(&self) -> bool
fn calculated_account_state(&self) -> bool
fn balance_total(&self, currency: Option<Currency>) -> Option<Money>
fn balances_total(&self) -> HashMap<Currency, Money>
fn balance_free(&self, currency: Option<Currency>) -> Option<Money>
fn balances_free(&self) -> HashMap<Currency, Money>
fn balance_locked(&self, currency: Option<Currency>) -> Option<Money>
fn balances_locked(&self) -> HashMap<Currency, Money>
fn balance(&self, currency: Option<Currency>) -> Option<&AccountBalance>
fn last_event(&self) -> Option<AccountState>
fn events(&self) -> Vec<AccountState>
fn event_count(&self) -> usize
fn currencies(&self) -> Vec<Currency>
fn starting_balances(&self) -> HashMap<Currency, Money>
fn balances(&self) -> HashMap<Currency, AccountBalance>
fn apply(&mut self, event: AccountState)
fn purge_account_events(&mut self, ts_now: UnixNanos, lookback_secs: u64)
Source§fn calculate_balance_locked(
&mut self,
instrument: InstrumentAny,
side: OrderSide,
quantity: Quantity,
price: Price,
use_quote_for_inverse: Option<bool>,
) -> Result<Money>
fn calculate_balance_locked( &mut self, instrument: InstrumentAny, side: OrderSide, quantity: Quantity, price: Price, use_quote_for_inverse: Option<bool>, ) -> Result<Money>
Source§fn calculate_pnls(
&self,
instrument: InstrumentAny,
fill: OrderFilled,
position: Option<Position>,
) -> Result<Vec<Money>>
fn calculate_pnls( &self, instrument: InstrumentAny, fill: OrderFilled, position: Option<Position>, ) -> Result<Vec<Money>>
Source§fn calculate_commission(
&self,
instrument: InstrumentAny,
last_qty: Quantity,
last_px: Price,
liquidity_side: LiquiditySide,
use_quote_for_inverse: Option<bool>,
) -> Result<Money>
fn calculate_commission( &self, instrument: InstrumentAny, last_qty: Quantity, last_px: Price, liquidity_side: LiquiditySide, use_quote_for_inverse: Option<bool>, ) -> Result<Money>
Source§impl Clone for CashAccount
impl Clone for CashAccount
Source§fn clone(&self) -> CashAccount
fn clone(&self) -> CashAccount
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for CashAccount
impl Debug for CashAccount
Source§impl Default for CashAccount
impl Default for CashAccount
Source§fn default() -> Self
fn default() -> Self
Creates a new default CashAccount
instance.
Source§impl Deref for CashAccount
impl Deref for CashAccount
Source§impl DerefMut for CashAccount
impl DerefMut for CashAccount
Source§impl<'de> Deserialize<'de> for CashAccount
impl<'de> Deserialize<'de> for CashAccount
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 Display for CashAccount
impl Display for CashAccount
Source§impl From<CashAccount> for AccountAny
impl From<CashAccount> for AccountAny
Source§fn from(v: CashAccount) -> AccountAny
fn from(v: CashAccount) -> AccountAny
Source§impl IntoPy<Py<PyAny>> for CashAccount
impl IntoPy<Py<PyAny>> for CashAccount
Source§impl<'py> IntoPyObject<'py> for CashAccount
impl<'py> IntoPyObject<'py> for CashAccount
Source§type Target = CashAccount
type Target = CashAccount
Source§type Output = Bound<'py, <CashAccount as IntoPyObject<'py>>::Target>
type Output = Bound<'py, <CashAccount as IntoPyObject<'py>>::Target>
Source§fn into_pyobject(
self,
py: Python<'py>,
) -> Result<<Self as IntoPyObject<'_>>::Output, <Self as IntoPyObject<'_>>::Error>
fn into_pyobject( self, py: Python<'py>, ) -> Result<<Self as IntoPyObject<'_>>::Output, <Self as IntoPyObject<'_>>::Error>
Source§impl PartialEq for CashAccount
impl PartialEq for CashAccount
Source§impl PyClass for CashAccount
impl PyClass for CashAccount
Source§impl PyClassImpl for CashAccount
impl PyClassImpl for CashAccount
Source§const IS_BASETYPE: bool = false
const IS_BASETYPE: bool = false
Source§const IS_SUBCLASS: bool = false
const IS_SUBCLASS: bool = false
Source§const IS_MAPPING: bool = false
const IS_MAPPING: bool = false
Source§const IS_SEQUENCE: bool = false
const IS_SEQUENCE: bool = false
Source§type ThreadChecker = SendablePyClass<CashAccount>
type ThreadChecker = SendablePyClass<CashAccount>
Source§type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
Source§type BaseNativeType = PyAny
type BaseNativeType = PyAny
PyAny
by default, and when you declare
#[pyclass(extends=PyDict)]
, it’s PyDict
.fn items_iter() -> PyClassItemsIter
fn lazy_type_object() -> &'static LazyTypeObject<Self>
fn dict_offset() -> Option<isize>
fn weaklist_offset() -> Option<isize>
Source§impl PyClassNewTextSignature<CashAccount> for PyClassImplCollector<CashAccount>
impl PyClassNewTextSignature<CashAccount> for PyClassImplCollector<CashAccount>
fn new_text_signature(self) -> Option<&'static str>
Source§impl<'a, 'py> PyFunctionArgument<'a, 'py, false> for &'a CashAccount
impl<'a, 'py> PyFunctionArgument<'a, 'py, false> for &'a CashAccount
Source§impl<'a, 'py> PyFunctionArgument<'a, 'py, false> for &'a mut CashAccount
impl<'a, 'py> PyFunctionArgument<'a, 'py, false> for &'a mut CashAccount
Source§impl PyMethods<CashAccount> for PyClassImplCollector<CashAccount>
impl PyMethods<CashAccount> for PyClassImplCollector<CashAccount>
fn py_methods(self) -> &'static PyClassItems
Source§impl PyTypeInfo for CashAccount
impl PyTypeInfo for CashAccount
Source§fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
§fn type_object(py: Python<'_>) -> Bound<'_, PyType>
fn type_object(py: Python<'_>) -> Bound<'_, PyType>
§fn type_object_bound(py: Python<'_>) -> Bound<'_, PyType>
fn type_object_bound(py: Python<'_>) -> Bound<'_, PyType>
PyTypeInfo::type_object
PyTypeInfo::type_object
].§fn is_type_of(object: &Bound<'_, PyAny>) -> bool
fn is_type_of(object: &Bound<'_, PyAny>) -> bool
object
is an instance of this type or a subclass of this type.§fn is_type_of_bound(object: &Bound<'_, PyAny>) -> bool
fn is_type_of_bound(object: &Bound<'_, PyAny>) -> bool
PyTypeInfo::is_type_of
PyTypeInfo::is_type_of
].§fn is_exact_type_of(object: &Bound<'_, PyAny>) -> bool
fn is_exact_type_of(object: &Bound<'_, PyAny>) -> bool
object
is an instance of this type.§fn is_exact_type_of_bound(object: &Bound<'_, PyAny>) -> bool
fn is_exact_type_of_bound(object: &Bound<'_, PyAny>) -> bool
PyTypeInfo::is_exact_type_of
PyTypeInfo::is_exact_type_of
].Source§impl Serialize for CashAccount
impl Serialize for CashAccount
Source§impl TryInto<CashAccount> for AccountAny
impl TryInto<CashAccount> for AccountAny
impl DerefToPyAny for CashAccount
impl Eq for CashAccount
Auto Trait Implementations§
impl Freeze for CashAccount
impl RefUnwindSafe for CashAccount
impl Send for CashAccount
impl Sync for CashAccount
impl Unpin for CashAccount
impl UnwindSafe for CashAccount
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<T> FromPyObject<'_> for Twhere
T: PyClass + Clone,
impl<T> FromPyObject<'_> for Twhere
T: PyClass + Clone,
§fn extract_bound(obj: &Bound<'_, PyAny>) -> Result<T, PyErr>
fn extract_bound(obj: &Bound<'_, PyAny>) -> Result<T, PyErr>
§impl<'py, T> FromPyObjectBound<'_, 'py> for Twhere
T: FromPyObject<'py>,
impl<'py, T> FromPyObjectBound<'_, 'py> for Twhere
T: FromPyObject<'py>,
§fn from_py_object_bound(ob: Borrowed<'_, 'py, PyAny>) -> Result<T, PyErr>
fn from_py_object_bound(ob: Borrowed<'_, 'py, PyAny>) -> Result<T, PyErr>
§impl<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
impl<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
§fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>
fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>
self
into an owned Python object, dropping type information.§fn into_py_any(self, py: Python<'py>) -> Result<Py<PyAny>, PyErr>
fn into_py_any(self, py: Python<'py>) -> Result<Py<PyAny>, PyErr>
self
into an owned Python object, dropping type information and unbinding it
from the 'py
lifetime.§fn into_pyobject_or_pyerr(self, py: Python<'py>) -> Result<Self::Output, PyErr>
fn into_pyobject_or_pyerr(self, py: Python<'py>) -> Result<Self::Output, PyErr>
self
into a Python object. Read moreSource§impl<'py, T> IntoPyObjectNautilusExt<'py> for Twhere
T: IntoPyObjectExt<'py>,
impl<'py, T> IntoPyObjectNautilusExt<'py> for Twhere
T: IntoPyObjectExt<'py>,
fn into_py_any_unwrap(self, py: Python<'py>) -> Py<PyAny>
§impl<T> PyErrArguments for T
impl<T> PyErrArguments for T
§impl<T> PyTypeCheck for Twhere
T: PyTypeInfo,
impl<T> PyTypeCheck for Twhere
T: PyTypeInfo,
Source§impl<T> Separable for Twhere
T: Display,
impl<T> Separable for Twhere
T: Display,
Source§fn separate_by_policy(&self, policy: SeparatorPolicy<'_>) -> String
fn separate_by_policy(&self, policy: SeparatorPolicy<'_>) -> String
SeparatorPolicy
. Read more