Skip to content

globophobe/go-quant-tick

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

143 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

What?

Go Quant Tick aggregates high frequency tick data from WebSockets.

How?

Sequences of trades that have equal symbol, timestamp, and tick rule are aggregated. Aggregating trades in this way can increase information, as they are either orders of size or stop loss cascades.

As well, the number of messages can be reduced by 30-50%

By filtering aggregated messages, for example only emitting a message when an aggregated trade is greater than or equal to a SIGNIFICANT_TRADE_FILTER, the number of messages can be reduced more.

Example

The following are two sequential aggregated trades by timestamp, nanoseconds, and tick rule.

As it was aggregated from 4 raw trades, the second trade has ticks 4.

[
    {
        "timestamp": 1620000915.31424,
        "price": "57064.01",
        "volume": "566.6479018604",
        "notional": "0.00993004",
        "tickRule": -1,
        "ticks": 1
    },
    {
        "timestamp": 1620000915.885381,
        "price": "57071.2",
        "volume": "9376.6869202914",
        "notional": "0.16429813",
        "tickRule": 1,
        "ticks": 4
    }
]

An example filtered message, emitted because SIGNIFICANT_TRADE_FILTER is 1000.

Information related to the first trade is aggregated with the second.

[
    {
        "timestamp": 1620000915.885381,
        "price": "57071.2",
        "volume": "9376.6869202914",
        "notional": "0.16429813",
        "tickRule": 1,
        "ticks": 4,
        "high": "57071.2",
        "low": "57064.01",
        "totalBuyVolume": "9376.6869202914",
        "totalVolume": "9943.3348221518",
        "totalBuyNotional": "0.16429813",
        "totalNotional": "0.17422817",
        "totalBuyTicks": 4,
        "totalTicks": 5
    }
]

If no significant trade occurs in a minute window, a context tick is emitted with volume, notional, tickRule, and ticks omitted.

Settings

For local JSON-lines output:

go run ./cmd/quanttick -publisher=stdout

Environment variables:

BINANCE_SYMBOLS=BTCUSDT=10000
BINANCE_FUTURES_SYMBOLS=BTCUSDT
BITFINEX_SYMBOLS=tBTCF0:USTF0
BITMEX_SYMBOLS=XBTUSD
COINBASE_SYMBOLS=BTC-USD
HYPERLIQUID_SYMBOLS=BTC
WEBSOCKET_DATA_STREAMS=significant-trades
SIGNIFICANT_TRADE_FILTER=1000

Symbol lists are comma-separated. A symbol can include an optional significant trade threshold as SYMBOL=THRESHOLD; symbols without an override use SIGNIFICANT_TRADE_FILTER.

WEBSOCKET_DATA_STREAMS accepts:

raw-trades,aggregated-trades,significant-trades

Example scripts

Each example prints significant-trade JSON lines until interrupted:

go run ./examples/binance
go run ./examples/binance-futures
go run ./examples/coinbase
go run ./examples/bitfinex
go run ./examples/bitmex
go run ./examples/hyperliquid

Example with a BTCUSDT threshold of 10000:

BINANCE_SYMBOLS=BTCUSDT=10000 go run ./examples/binance

Supported exchanges

βœ… Binance

βœ… Bitfinex

βœ… BitMEX

βœ… Coinbase

βœ… Hyperliquid

Tests

Run tests with:

go test ./...
go test -race ./...

About

πŸ”Œ Aggregate high frequency tick data from WebSockets

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors