Skip to content
プロジェクト

saniales/golang-crypto-trading-bot

GitHubで見る

概要

暗号資産取引所向けのコンソールベースのトレーディングボットをGoで実装したものです

ビジネス・金融

この数値の測り方

計測したスター増加

24時間
0
7日間
0
15日間
0
1か月
+1

期間ごとの純増数です。期間は重複しており、日別の値ではありません。未計測の値は空欄です。スター数は注目度の指標であり、品質の保証ではありません。

Listed on Awesome Go Develop Branch Build Status Godoc reference Last Release License Goreportcard

Golang Crypto Trading Bot

A golang implementation of a console-based trading bot for cryptocurrency exchanges.

Usage

Download a release or directly build the code from this repository.

go get github.com/saniales/golang-crypto-trading-bot

If you need to, you can create a strategy and bind it to the bot:

import bot "github.com/saniales/golang-crypto-trading-bot/cmd"

func main() {
    bot.AddCustomStrategy(examples.MyStrategy)
    bot.Execute()
}

For strategy reference see the Godoc documentation.

Strategies can cancel an open order with wrapper.CancelOrder(market, orderID), using the ID returned by the order placement method. Cancellation errors are returned to the caller, including when an order is no longer open. The HitBTC and KuCoin clients and the unimplemented Bittrex V2 wrapper cannot safely cancel individual orders and return exchanges.ErrCancelOrderNotSupported. In simulation mode, market orders are filled immediately and limit orders are not simulated, so there are no open simulated orders to cancel. Kraken placement IDs may contain multiple transaction IDs; cancel each ID separately if that occurs.

External logging

Applications embedding the bot can attach a logger before calling Execute:

import (
    "log/slog"
    "os"

    bot "github.com/saniales/golang-crypto-trading-bot/cmd"
)

func main() {
    bot.SetLogger(slog.New(slog.NewJSONHandler(os.Stderr, nil)))
    bot.Execute()
}

SetLogger accepts any concurrency-safe implementation of the logging.Logger interface (Info and Error methods with slog-style key/value arguments). For example, use a slog handler that exports to OpenTelemetry, or adapt another logger to the interface. Bot lifecycle, strategy failures and exchange feed errors are logged; interactive CLI output and custom strategy logging remain the responsibility of the application. Passing nil restores the default Logrus logger. Interrupts are logged before the process exits, rather than as normal bot or strategy stop events. Do not include credentials in custom log messages or attributes.

Simulation Mode

If enabled, the bot will do paper trading, as it will execute fake orders in a sandbox environment.

A Fake balance for each coin must be specified for each exchange if simulation mode is enabled.

Supported Exchanges

Exchange Name REST Supported Websocket Support
Bittrex Yes No
Poloniex Yes Yes
Kraken Yes (no withdraw) No
Bitfinex Yes Yes
Binance Yes Yes
Kucoin Yes No
HitBtc Yes Yes

Configuration file template

Create a configuration file from this example or run the init command of the compiled executable.

simulation_mode: true # if you want to enable simulation mode.
exchange_configs:
  - exchange: bitfinex
    public_key: bitfinex_public_key
    secret_key: bitfinex_secret_key
    deposit_addresses:
      BTC: bitfinex_deposit_address_btc
      ETH: bitfinex_deposit_address_eth
      ZEC: bitfinex_deposit_address_zec
    fake_balances: # used only if simulation mode is enabled, can be omitted if not enabled.
      BTC: 100
      ETH: 100
      ZEC: 100
      ETC: 100
  - exchange: hitbtc
    public_key: hitbtc_public_key
    secret_key: hitbtc_secret_key
    deposit_addresses:
      BTC : hitbtc_deposit_address_btc
      ETH: hitbtc_deposit_address_eth
      ZEC: hitbtc_deposit_address_zec
    fake_balances:
      BTC: 100
      ETH: 100
      ZEC: 100
      ETC: 100
strategies:
  - strategy: strategy_name
    markets:
      - market: ETH-BTC
        bindings:
        - exchange: bitfinex
          market_name: ETHBTC
        - exchange: hitbtc
          market_name: ETHBTC
      - market: ZEC-BTC
        bindings:
        - exchange: bitfinex
          market_name: ZECBTC
        - exchange: hitbtc
          market_name: ZECBTC
      - market: ETC-BTC
        bindings:
        - exchange: bitfinex
          market_name: ETCBTC
        - exchange: hitbtc
          market_name: ETCBTC

Donate

Feel free to donate:

METHOD ADDRESS
Paypal https://paypal.me/AlessandroSanino
BTC 1DVgmv6jkUiGrnuEv1swdGRyhQsZjX9MT3
XVG DFstPiWFXjX8UCyUCxfeVpk6JkgaLBSNvS
ETH 0x2fe7bd8a41e91e9284aada0055dbb15ecececf02
USDT 18obCEVmbT6MHXDcPoFwnUuCmkttLbK5Xo

関連プロジェクトを探す

読み込み中…