Giter Site home page Giter Site logo

coinbase-pro-rs's Introduction

Build Status Crates.io Docs.rs

Coinbase pro client for Rust

Supports SYNC/ASYNC/Websocket-feed data support

Features

  • private and public API
  • sync and async support
  • websocket-feed support

Examples

Cargo.toml:

[dependencies]
coinbase-pro-rs = "0.5.1"

Async

extern crate hyper;
extern crate tokio;
extern crate coinbase_pro_rs;

use hyper::rt::Future;
use coinbase_pro_rs::{Public, ASync, SANDBOX_URL};

fn main() {
    let client: Public<ASync> = Public::Public::new_with_keep_alive(SANDBOX_URL, false);
    // if keep_alive is not disables - tokio::run will hold the connection without exiting the example
    let f = client.get_time()
        .map_err(|_| ())
        .and_then(|time| {
            println!("Coinbase.time: {}", time.iso);
            Ok(())
        });

    tokio::run(f); // waiting for tokio
}

Sync

extern crate coinbase_pro_rs;

use coinbase_pro_rs::{Public, Sync, SANDBOX_URL};

fn main() {
   let client: Public<Sync> = Public::new(SANDBOX_URL);
   let time = client.get_time().unwrap();
   println!("Coinbase.time: {}", time.iso);
}

Websocket

extern crate futures;
extern crate tokio;
extern crate coinbase_pro_rs;

use futures::{Future, Stream};
use coinbase_pro_rs::{WSFeed, WS_SANDBOX_URL};
use coinbase_pro_rs::structs::wsfeed::*;

fn main() {
    let stream = WSFeed::new(WS_SANDBOX_URL,
        &["BTC-USD"], &[ChannelType::Heartbeat]);

    let f = stream
        .take(10)
        .for_each(|msg| {
        match msg {
            Message::Heartbeat {sequence, last_trade_id, time, ..} => println!("{}: seq:{} id{}",
                                                                               time, sequence, last_trade_id),
            Message::Error {message} => println!("Error: {}", message),
            Message::InternalError(_) => panic!("internal_error"),
            other => println!("{:?}", other)
        }
        Ok(())
    });

    tokio::run(f.map_err(|_| panic!("stream fail")));
}

Api supported:

  • SYNC
  • ASYNC
  • Websocket-Feed

API

  • Requests
  • Pagination
  • Types
  • Private
    • Authentication
    • Accounts
    • Orders
    • Fills
    • Deposits
    • Withdrawals
    • Payment Methods
    • Coinbase Accounts
    • Reports
    • User Account
  • Market Data
    • Products
    • Currencies
    • Time
  • Websocket Feed
    • heartbeat
    • ticker
    • level2
    • user
    • matches
    • full

FIX API

by request

OrderBook

https://github.com/inv2004/orderbook-rs

Tests

cargo test -- --test-threads=1 // to avoid "Rate limit exceeded" error

coinbase-pro-rs's People

Contributors

inv2004 avatar j16r avatar kornelski avatar rschmukler avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.