Struct Chart

Source
pub struct Chart { /* private fields */ }
Expand description

Aggregation of instrument id, timeframe and bars.

§ru

График - хранит идентификатора инструмента, таймфрейм и бары.

Implementations§

Source§

impl Chart

Source

pub fn new(iid: &Iid, tf: &TimeFrame, bars: Vec<Bar>) -> Chart

Create new chart.

§ru

Конструктор.

§Examples
use avin_core::{Manager, TimeFrame, Bar, Chart};

let iid = Manager::find_iid("moex_share_sber").unwrap();
let tf = TimeFrame::Day;

let b1 = Bar::new(123456789, 320.5, 321.2, 320.1, 320.8, 10, None);
let b2 = Bar::new(123456789, 320.5, 321.2, 320.1, 320.8, 10, None);
let bars = vec![b1, b2];

let chart = Chart::new(&iid, &tf, bars);

assert_eq!(chart.ticker(), "SBER");
Source

pub fn empty(iid: &Iid, tf: &TimeFrame) -> Chart

Create new chart without bars.

§ru

Создает пустой график, без баров. Используется в тестере.

Source

pub fn load( iid: &Iid, tf: &TimeFrame, begin: &DateTime<Utc>, end: &DateTime<Utc>, ) -> Result<Chart, AvinError>

Loading chart with bars from half-open interval [begin, end) market data must be available in [CFG.dir.data()].

§ru

Загружает график с барами в полуоткрытом в интервале [begin, end). Данные должны быть доступны в папке указанной в конфиге пользователя. Рыночные данные можно загрузить воспользовавшись модулем avin_data написанном на python, доступен в том же репозитарии, и на PyPl: “pip install avin_data”. Так же есть консольная утилита avin-data см. репозитарий проекта.

Source

pub fn iid(&self) -> &Iid

Return chart instrument id.

§ru

Возвращает ссылку на идентификатор инструмента.

Source

pub fn ticker(&self) -> &String

Return ticker.

§ru

Возвращает ссылку на строку с тикером.

Source

pub fn tf(&self) -> &TimeFrame

Return chart timeframe.

§ru

Возвращает ссылку на таймфрейм.

Source

pub fn bars(&self) -> &Vec<Bar>

Return bars of chart.

§ru

Возвращает cсылку на вектор исторических баров в графике.

Source

pub fn bar(&self, ts: i64) -> Option<&Bar>

Return bar of time == ts_nanos.

§ru

Возвращает ссылку на бар с заданным timestamp или None, если такой отсутствует.

Source

pub fn first(&self) -> Option<&Bar>

Return fist historical bar of chart.

§ru

Возвращает ссылку на первый исторический бар или None, если график не содержит баров.

Source

pub fn last(&self) -> Option<&Bar>

Return last historical bar of chart

§ru

Возвращает ссылку на последний исторический бар или None, если график не содержит баров.

Source

pub fn now(&self) -> Option<&Bar>

Return real-time bar of chart

§ru

Возвращает ссылку на текущий real-time бар или None, если график не содержит баров.

Source

pub fn last_price(&self) -> Option<f64>

Return last price

§ru

Возвращает цену последней сделки реал-тайм бара, если он есть, или последнего исторического бара. Если график не содержит баров, возвращает None.

Source

pub fn select(&self, from: i64, till: i64) -> &[Bar]

Select bars in closed range [from, till].

§ru

Возвращает срез баров в закрытом интервале заданном начальным и конечным timestamp [from, till].

Source

pub fn add_bar(&mut self, new_bar: Bar)

Add new bar Depending on datetime of ‘new_bar’ this function do:

  • only update real-time bar
  • add new historical bar and update real-time
§ru

Добавляет в график новый бар. В зависимости от даты и времени добавляемого бара функция:

  • обновит текущий реал-тайм бар новым баром;
  • сделает текущий реал-тайм бар историческим, а новый поставит текущим;

Trait Implementations§

Source§

impl AsRef<Chart> for Chart

Source§

fn as_ref(&self) -> &Chart

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Debug for Chart

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Chart

§

impl RefUnwindSafe for Chart

§

impl Send for Chart

§

impl Sync for Chart

§

impl Unpin for Chart

§

impl UnwindSafe for Chart

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V