Thanks to visit codestin.com
Credit goes to github.com

Skip to content

`bitbankutil_rs` is a Rust library with asynchronous programming support for API traders of the crypto exchange bitbank. This library allows various processes to be performed in a concise manner.

License

Notifications You must be signed in to change notification settings

Harui-i/bitbankutil_rs

Repository files navigation

GitHub Repo stars dependency status

日本語

bitbankutil_rs

bitbankutil_rsは、RustでbitbankのAPI処理を複数サポートしたライブラリクレートです。 bitbankutil_rsを使うことで、以下のようなことが簡単に実現できます。

Examples

bitbankのPrivate APIを利用した処理(現在の残高の取得など)

src/bitbank_private.rsで定義されている、BitbankPrivateApiClientを使用することで、次のように簡単に実行することができます。

    let bitbank_key = env::var("BITBANK_API_KEY").unwrap();
    let bitbank_secret = env::var("BITBANK_API_SECRET").unwrap();

    let bb_client = BitbankPrivateApiClient::new(bitbank_key, bitbank_secret, None)
    let assets = bb_client.get_assets().await;
    println!("{:?}", assets);

bitbankのPublic APIを利用した処理(ティッカーの取得など)

src/bitbank_public.rsで定義されているBitbankPublicApiClientを使用することで、簡単に実装できます。

    let public_client = BitbankPublicApiClient::new();
    let res = public_client.get_tickers().await;
    log::debug!("{:?}", res);

以上のような処理には、取引所のjson形式のAPIレスポンスをRustで扱えるようにするためにserde_jsonなどを使ってデシリアライズする必要がありますが、そういった処理はsrc/bitbank_structs.rsで実装されているため、簡単に利用できます。

bitbankのWebSocketでの約定や板情報の更新などに応じた非同期イベント駆動botの制作

bitbank_bot.rsで定義されているBitbankBotBuilderBotStrategyを利用すると、 WebSocketイベントを扱う際に状態を自前で受け渡す必要がなくなり、取引ロジックに 集中できます。BotContext::event_senderを使えば、ログのリプレイや他取引所の 情報などユーザー独自のデータソースも同じランタイムに流し込めます。

examples/best_mm.rsは非同期イベント駆動で、best価格に指値注文をし続けるbotのサンプルコードです。実際に実行するには cargo run --example best_mm mona_jpy 0.001 8000 0.001 0.002 のようにしてください。ここで、mona_jpy以降の引数の意味は、examples/best_mm.rsに書いてあるとおり、 ペア,ティックサイズ(呼び値)、 注文を入れ替える感覚(ミリ秒)、 一回の注文のサイズ、 最大保有数となっています。

API カバレッジ

Public API (Doc)

エンドポイント 実装状況
GET /{pair}/ticker
GET /tickers
GET /tickers_jpy
GET /{pair}/depth
GET /{pair}/transactions/{YYYYMMDD}
GET /{pair}/candlestick/{candle-type}/{YYYY}
GET /{pair}/circuit_break_info

REST API (Doc)

エンドポイント 実装状況
GET /user/assets
GET /user/spot/order
POST /user/spot/order
POST /user/spot/cancel_order
POST /user/spot/cancel_orders
POST /user/spot/orders_info ❌️
GET /user/spot/active_orders
GET /user/margin/positions ❌️
GET /user/spot/trade_history
GET /user/deposit_history ❌️
GET /user/unconfirmed_deposits ❌️
GET /user/deposit_originators ❌️
POST /user/confirm_deposits ❌️
POST /user/confirm_deposits_all ❌️
GET /user/withdrawal_account ❌️
POST /user/request_withdrawal ❌️
GET /user/withdrawal_history ❌️
GET /spot/status ️✅
GET /spot/pairs ❌️
GET /user/subscribe

Public Stream API

チャンネル 実装状況
ticker_{pair}
transactions_{pair}
depth_diff_{pair}
depth_whole_{pair}
circuit_break_info_{pair}

今後の実装予定

  • Private Streaming APIへの対応

使い方

Cargo.toml[dependencies]の欄に

bitbankutil_rs = {git = "https://github.com/Harui-i/bitbankutil_rs" }

などと追加してください。

連絡先

Twitter: @Harui_botter

注意

このライブラリクレートやサンプルプログラムの利用によって生じたいかなる損失についても、当プロジェクトの開発者は責任を負いかねます。自己責任でご利用ください。

About

`bitbankutil_rs` is a Rust library with asynchronous programming support for API traders of the crypto exchange bitbank. This library allows various processes to be performed in a concise manner.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages