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
impl Market
Sourcepub fn new<'m>(api: CryptoMktApi, market_name: &'m str) -> Self
pub fn new<'m>(api: CryptoMktApi, market_name: &'m str) -> Self
Create new instance
Sourcepub fn get_name(&self) -> String
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}Sourcepub fn get_current_ticker(&self) -> Result<Ticker, CryptoMktErrorType>
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}Sourcepub fn get_orders_book(
&self,
orders_type: OrderType,
page: u32,
limit: u32,
) -> Result<Vec<Book>, CryptoMktErrorType>
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}Sourcepub fn get_trades<'m>(
&self,
start: &'m str,
end: &'m str,
page: u32,
limit: u32,
) -> Result<Vec<Trade>, CryptoMktErrorType>
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}Sourcepub fn get_user_orders_by_state(
&self,
state: OrderState,
page: u32,
limit: u32,
) -> Result<Vec<Order>, CryptoMktErrorType>
pub fn get_user_orders_by_state( &self, state: OrderState, page: u32, limit: u32, ) -> Result<Vec<Order>, CryptoMktErrorType>
Get user orders by state
Sourcepub fn create_order(
&self,
order_type: OrderType,
amount: f32,
price: f32,
) -> Result<Vec<Order>, CryptoMktErrorType>
pub fn create_order( &self, order_type: OrderType, amount: f32, price: f32, ) -> Result<Vec<Order>, CryptoMktErrorType>
Create order
Sourcepub fn get_order_status<'m>(
&self,
order_id: &'m str,
) -> Result<Order, CryptoMktErrorType>
pub fn get_order_status<'m>( &self, order_id: &'m str, ) -> Result<Order, CryptoMktErrorType>
Get Order status
Sourcepub fn cancel_order<'m>(
&self,
order_id: &'m str,
) -> Result<Order, CryptoMktErrorType>
pub fn cancel_order<'m>( &self, order_id: &'m str, ) -> Result<Order, CryptoMktErrorType>
Cancel Order
Sourcepub fn get_order_instant(
&self,
order_type: OrderType,
amount: f32,
) -> Result<OrdersInstant, CryptoMktErrorType>
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.
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> 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