Struct Market

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

Market

Through this class you access the functionalities offered by the market, either create purchase order, choose the state of the market, etc …

Implementations§

Source§

impl Market

Source

pub fn new<'m>(api: CryptoMktApi, market_name: &'m str) -> Self

Create new instance

Source

pub fn get_name(&self) -> String

Get the market name (Ej ETHCLP)

Examples found in repository?
examples/simple.rs (line 17)
11fn main() {
12    let client = CryptoMktClient::new(API_KEY, API_SECRET);
13
14    // Get all markets available
15    let markets = client.get_markets();
16    for m in markets.iter() {
17        println!("{}", m.get_name());
18
19        // Get the current ticker for the market
20        match m.get_current_ticker() {
21            Ok(ticker) => {
22                println!("{:?}", ticker);
23            }
24            Err(e) => {
25                println!("{:?}", e);
26            }
27        }
28
29        println!("------- Orders ------");
30        match m.get_orders_book(OrderType::Buy, 0, 20) {
31            Ok(orders) => {
32                println!("{:?}", orders);
33            }
34            Err(e) => {
35                println!("{:?}", e);
36            }
37        }
38
39        println!("------- Trades ------");
40        match m.get_trades("2018-05-15", "2018-05-16", 0, 20) {
41            Ok(trades) => {
42                println!("{:?}", trades);
43            }
44            Err(e) => {
45                println!("{:?}", e);
46            }
47        }
48    }
49}
Source

pub fn get_current_ticker(&self) -> Result<Ticker, CryptoMktErrorType>

Get the current ticker

Examples found in repository?
examples/simple.rs (line 20)
11fn main() {
12    let client = CryptoMktClient::new(API_KEY, API_SECRET);
13
14    // Get all markets available
15    let markets = client.get_markets();
16    for m in markets.iter() {
17        println!("{}", m.get_name());
18
19        // Get the current ticker for the market
20        match m.get_current_ticker() {
21            Ok(ticker) => {
22                println!("{:?}", ticker);
23            }
24            Err(e) => {
25                println!("{:?}", e);
26            }
27        }
28
29        println!("------- Orders ------");
30        match m.get_orders_book(OrderType::Buy, 0, 20) {
31            Ok(orders) => {
32                println!("{:?}", orders);
33            }
34            Err(e) => {
35                println!("{:?}", e);
36            }
37        }
38
39        println!("------- Trades ------");
40        match m.get_trades("2018-05-15", "2018-05-16", 0, 20) {
41            Ok(trades) => {
42                println!("{:?}", trades);
43            }
44            Err(e) => {
45                println!("{:?}", e);
46            }
47        }
48    }
49}
Source

pub fn get_orders_book( &self, orders_type: OrderType, page: u32, limit: u32, ) -> Result<Vec<Book>, CryptoMktErrorType>

Get the order books

Examples found in repository?
examples/simple.rs (line 30)
11fn main() {
12    let client = CryptoMktClient::new(API_KEY, API_SECRET);
13
14    // Get all markets available
15    let markets = client.get_markets();
16    for m in markets.iter() {
17        println!("{}", m.get_name());
18
19        // Get the current ticker for the market
20        match m.get_current_ticker() {
21            Ok(ticker) => {
22                println!("{:?}", ticker);
23            }
24            Err(e) => {
25                println!("{:?}", e);
26            }
27        }
28
29        println!("------- Orders ------");
30        match m.get_orders_book(OrderType::Buy, 0, 20) {
31            Ok(orders) => {
32                println!("{:?}", orders);
33            }
34            Err(e) => {
35                println!("{:?}", e);
36            }
37        }
38
39        println!("------- Trades ------");
40        match m.get_trades("2018-05-15", "2018-05-16", 0, 20) {
41            Ok(trades) => {
42                println!("{:?}", trades);
43            }
44            Err(e) => {
45                println!("{:?}", e);
46            }
47        }
48    }
49}
Source

pub fn get_trades<'m>( &self, start: &'m str, end: &'m str, page: u32, limit: u32, ) -> Result<Vec<Trade>, CryptoMktErrorType>

Get Trades

Examples found in repository?
examples/simple.rs (line 40)
11fn main() {
12    let client = CryptoMktClient::new(API_KEY, API_SECRET);
13
14    // Get all markets available
15    let markets = client.get_markets();
16    for m in markets.iter() {
17        println!("{}", m.get_name());
18
19        // Get the current ticker for the market
20        match m.get_current_ticker() {
21            Ok(ticker) => {
22                println!("{:?}", ticker);
23            }
24            Err(e) => {
25                println!("{:?}", e);
26            }
27        }
28
29        println!("------- Orders ------");
30        match m.get_orders_book(OrderType::Buy, 0, 20) {
31            Ok(orders) => {
32                println!("{:?}", orders);
33            }
34            Err(e) => {
35                println!("{:?}", e);
36            }
37        }
38
39        println!("------- Trades ------");
40        match m.get_trades("2018-05-15", "2018-05-16", 0, 20) {
41            Ok(trades) => {
42                println!("{:?}", trades);
43            }
44            Err(e) => {
45                println!("{:?}", e);
46            }
47        }
48    }
49}
Source

pub fn get_user_orders_by_state( &self, state: OrderState, page: u32, limit: u32, ) -> Result<Vec<Order>, CryptoMktErrorType>

Get user orders by state

Source

pub fn create_order( &self, order_type: OrderType, amount: f32, price: f32, ) -> Result<Vec<Order>, CryptoMktErrorType>

Create order

Source

pub fn get_order_status<'m>( &self, order_id: &'m str, ) -> Result<Order, CryptoMktErrorType>

Get Order status

Source

pub fn cancel_order<'m>( &self, order_id: &'m str, ) -> Result<Order, CryptoMktErrorType>

Cancel Order

Source

pub fn get_order_instant( &self, order_type: OrderType, amount: f32, ) -> Result<OrdersInstant, CryptoMktErrorType>

Get order instant

An instant order corresponds to a purchase or sale request within the Instant Exchange of CryptoMarket.

Source

pub fn create_order_instant( &self, order_type: OrderType, amount: f32, ) -> Result<String, CryptoMktErrorType>

Create an instant order in the Instant Exchange of CryptoMarket

Auto Trait Implementations§

§

impl Freeze for Market

§

impl !RefUnwindSafe for Market

§

impl Send for Market

§

impl Sync for Market

§

impl Unpin for Market

§

impl !UnwindSafe for Market

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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, 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<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,