Skip to content

yzimhao/trading_engine

Repository files navigation

贡献代码

全新重构,希望更多开源爱好者能加入共同开发练手,共同进步,请联系下方wx

撮合

    go get github.com/yzimhao/trading_engine/v2/pkg/matching

pkg example

    ctx := context.Background()
    opts := []matching.Option{
        matching.WithPriceDecimals(2),
        matching.WithQuantityDecimals(2),
    }
    btcusdt = matching.NewEngine(ctx, "btcusdt", opts...)

    //添加订单
    btcusdt.AddItem(...)
    //移除订单
    btcusdt.RemoveItem(...)

    //监听事件结果
    btcusdt.OnTradeResult(func(result types.TradeResult) {
        //TODO
    })
    btcusdt.OnRemoveResult(func(result types.RemoveResult) {
        //TODO
    })

    //获取深度
    btcusdt.GetAskOrderBook(10) // [][2]string [["1.01","4.00"],["1.10","2.00"]]
    btcusdt.GetBidOrderBook(10)

交流

Star History

Star History Chart

Visitor's Count

Releases

No releases published

Packages

No packages published