pub struct MarginAccount {
pub base: BaseAccount,
pub leverages: HashMap<InstrumentId, f64>,
pub margins: HashMap<InstrumentId, MarginBalance>,
pub default_leverage: f64,
}
Fields§
§base: BaseAccount
§leverages: HashMap<InstrumentId, f64>
§margins: HashMap<InstrumentId, MarginBalance>
§default_leverage: f64
Implementations§
Source§impl MarginAccount
impl MarginAccount
Sourcepub fn new(event: AccountState, calculate_account_state: bool) -> Self
pub fn new(event: AccountState, calculate_account_state: bool) -> Self
Creates a new MarginAccount
instance.
pub fn set_default_leverage(&mut self, leverage: f64)
pub fn set_leverage(&mut self, instrument_id: InstrumentId, leverage: f64)
pub fn get_leverage(&self, instrument_id: &InstrumentId) -> f64
pub fn is_unleveraged(&self, instrument_id: InstrumentId) -> bool
pub fn is_cash_account(&self) -> bool
pub fn is_margin_account(&self) -> bool
pub fn initial_margins(&self) -> HashMap<InstrumentId, Money>
pub fn maintenance_margins(&self) -> HashMap<InstrumentId, Money>
pub fn update_initial_margin( &mut self, instrument_id: InstrumentId, margin_init: Money, )
pub fn initial_margin(&self, instrument_id: InstrumentId) -> Money
pub fn update_maintenance_margin( &mut self, instrument_id: InstrumentId, margin_maintenance: Money, )
pub fn maintenance_margin(&self, instrument_id: InstrumentId) -> Money
pub fn calculate_initial_margin<T: Instrument>( &mut self, instrument: T, quantity: Quantity, price: Price, use_quote_for_inverse: Option<bool>, ) -> Money
pub fn calculate_maintenance_margin<T: Instrument>( &mut self, instrument: T, quantity: Quantity, price: Price, use_quote_for_inverse: Option<bool>, ) -> Money
pub fn recalculate_balance(&mut self, currency: Currency)
Source§impl MarginAccount
impl MarginAccount
pub fn py_calculate_initial_margin( &mut self, instrument: PyObject, quantity: Quantity, price: Price, use_quote_for_inverse: Option<bool>, py: Python<'_>, ) -> PyResult<Money>
pub fn py_calculate_maintenance_margin( &mut self, instrument: PyObject, quantity: Quantity, price: Price, use_quote_for_inverse: Option<bool>, py: Python<'_>, ) -> PyResult<Money>
Methods from Deref<Target = BaseAccount>§
pub fn base_balance_total(&self, currency: Option<Currency>) -> Option<Money>
pub fn base_balances_total(&self) -> HashMap<Currency, Money>
pub fn base_balance_free(&self, currency: Option<Currency>) -> Option<Money>
pub fn base_balances_free(&self) -> HashMap<Currency, Money>
pub fn base_balance_locked(&self, currency: Option<Currency>) -> Option<Money>
pub fn base_balances_locked(&self) -> HashMap<Currency, Money>
pub fn base_last_event(&self) -> Option<AccountState>
pub fn update_balances(&mut self, balances: Vec<AccountBalance>)
pub fn base_apply(&mut self, event: AccountState)
pub 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_pnls( &self, instrument: InstrumentAny, fill: OrderFilled, position: Option<Position>, ) -> Result<Vec<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 MarginAccount
impl Account for MarginAccount
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 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 calculate_balance_locked( &mut self, instrument: InstrumentAny, side: OrderSide, quantity: Quantity, price: Price, use_quote_for_inverse: Option<bool>, ) -> Result<Money>
fn calculate_pnls( &self, instrument: InstrumentAny, fill: OrderFilled, position: Option<Position>, ) -> Result<Vec<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 MarginAccount
impl Clone for MarginAccount
Source§fn clone(&self) -> MarginAccount
fn clone(&self) -> MarginAccount
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for MarginAccount
impl Debug for MarginAccount
Source§impl Deref for MarginAccount
impl Deref for MarginAccount
Source§impl DerefMut for MarginAccount
impl DerefMut for MarginAccount
Source§impl<'de> Deserialize<'de> for MarginAccount
impl<'de> Deserialize<'de> for MarginAccount
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>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for MarginAccount
impl Display for MarginAccount
Source§impl Hash for MarginAccount
impl Hash for MarginAccount
Source§impl IntoPy<Py<PyAny>> for MarginAccount
impl IntoPy<Py<PyAny>> for MarginAccount
Source§impl PartialEq for MarginAccount
impl PartialEq for MarginAccount
Source§impl PyClass for MarginAccount
impl PyClass for MarginAccount
Source§impl PyClassImpl for MarginAccount
impl PyClassImpl for MarginAccount
Source§const IS_BASETYPE: bool = false
const IS_BASETYPE: bool = false
#[pyclass(subclass)]
Source§const IS_SUBCLASS: bool = false
const IS_SUBCLASS: bool = false
#[pyclass(extends=…)]
Source§const IS_MAPPING: bool = false
const IS_MAPPING: bool = false
#[pyclass(mapping)]
Source§const IS_SEQUENCE: bool = false
const IS_SEQUENCE: bool = false
#[pyclass(sequence)]
Source§type ThreadChecker = SendablePyClass<MarginAccount>
type ThreadChecker = SendablePyClass<MarginAccount>
This handles following two situations: Read more
Source§type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
Immutable or mutable
Source§type BaseNativeType = PyAny
type BaseNativeType = PyAny
The closest native ancestor. This is
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<MarginAccount> for PyClassImplCollector<MarginAccount>
impl PyClassNewTextSignature<MarginAccount> for PyClassImplCollector<MarginAccount>
fn new_text_signature(self) -> Option<&'static str>
Source§impl<'a, 'py> PyFunctionArgument<'a, 'py> for &'a MarginAccount
impl<'a, 'py> PyFunctionArgument<'a, 'py> for &'a MarginAccount
Source§impl<'a, 'py> PyFunctionArgument<'a, 'py> for &'a mut MarginAccount
impl<'a, 'py> PyFunctionArgument<'a, 'py> for &'a mut MarginAccount
Source§impl PyMethods<MarginAccount> for PyClassImplCollector<MarginAccount>
impl PyMethods<MarginAccount> for PyClassImplCollector<MarginAccount>
fn py_methods(self) -> &'static PyClassItems
Source§impl PyTypeInfo for MarginAccount
impl PyTypeInfo for MarginAccount
Source§fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
Returns the PyTypeObject instance for this type.
§fn type_object_bound(py: Python<'_>) -> Bound<'_, PyType>
fn type_object_bound(py: Python<'_>) -> Bound<'_, PyType>
Returns the safe abstraction over the type object.
§fn is_type_of_bound(object: &Bound<'_, PyAny>) -> bool
fn is_type_of_bound(object: &Bound<'_, PyAny>) -> bool
Checks if
object
is an instance of this type or a subclass of this type.§fn is_exact_type_of_bound(object: &Bound<'_, PyAny>) -> bool
fn is_exact_type_of_bound(object: &Bound<'_, PyAny>) -> bool
Checks if
object
is an instance of this type.Source§impl Serialize for MarginAccount
impl Serialize for MarginAccount
impl DerefToPyAny for MarginAccount
impl Eq for MarginAccount
Auto Trait Implementations§
impl Freeze for MarginAccount
impl RefUnwindSafe for MarginAccount
impl Send for MarginAccount
impl Sync for MarginAccount
impl Unpin for MarginAccount
impl UnwindSafe for MarginAccount
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
Mutably borrows from an owned value. Read more
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
Checks if this value is equivalent to the given key. Read more
§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
Compare self to
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<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
Adds separators according to the given
SeparatorPolicy
. Read moreSource§fn separate_with_commas(&self) -> String
fn separate_with_commas(&self) -> String
Inserts a comma every three digits from the right. Read more
Source§fn separate_with_spaces(&self) -> String
fn separate_with_spaces(&self) -> String
Inserts a space every three digits from the right. Read more
Source§fn separate_with_dots(&self) -> String
fn separate_with_dots(&self) -> String
Inserts a period every three digits from the right. Read more
Source§fn separate_with_underscores(&self) -> String
fn separate_with_underscores(&self) -> String
Inserts an underscore every three digits from the right. Read more