You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
RustyTrader/src/data/quotes.rs

60 lines
1.8 KiB

use chrono::{Utc, DateTime};
use super::Period;
use super::options::OptionKind;
pub enum AssetIdentifier{
Ticker(String),
Cusip(String),
Other(String)
}
///Information about what this quote it, where it came from and when
///
pub trait QuoteData {
/// Gives the symbol/ticker/cusip of this asset
fn asset_symbol(&self) -> AssetIdentifier;
/// Gives the timestamp of when the quote data is valid
fn quote_time(&self) -> DateTime<Utc>;
/// Gives the timestamp of when the quote was created
fn retrieve_time(&self) ->DateTime<Utc>;
/// Gives the exchange which the data was sources from
fn exchange(&self) -> Option<String>;
// TO DO: Gives the datasource used
}
///Standard volume information
///
pub trait VolumeData {
/// Gives the period over which this volume is valid
fn volume_period(&self) -> Period;
/// Total volume seem in that period
fn total_volume(&self) -> u64;
/// Gives the current bid size of the asset
fn bid_size(&self) -> u64;
// Gives the current as size of the asset
fn ask_size(&self) -> u64;
// Gives the size of the last trade
fn last_size(&self) -> Option<u64>;
}
///Standard information about price spread
///
pub trait PriceSpreadData {
/// Give the bid price of an asset
fn bid(&self) -> f64;
/// Gives the mid price of an asset
fn mid(&self) -> f64;
/// Gives the ask price of an asset
fn ask(&self) -> f64;
}
pub trait Marginable {
/// Gives the margin cost as a yearly interest cost. Returns none if not marginable
fn margin_cost(&self) -> Option<f64>;
/// Returns true if we can use margin on this instrument
fn is_marginable(&self) -> bool;
}
pub trait CryptoData {
fn base_crypto(&self) -> String;
fn quote_crypto(&self) -> String;
}