collector

package
v0.0.0-...-80fbd55 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 10, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ENDPOINT       = "wss://stream.binance.com:9443/stream?streams="
	DATA_DIRECTORY = "./Data/"
)
View Source
const DATAKEY_LEN = 7
View Source
const STREAM_BYTE_N = 11
View Source
const UINT_BASE = 10

Variables

View Source
var DATAKEY = [7]byte{'"', 'd', 'a', 't', 'a', '"', ':'}
View Source
var STREAMS = map[string]string{"!miniTicker@arr": "miniTickers"}
View Source
var SYMBOLS = map[string]string{
	"ETHBTC":  "ethbtc",
	"BTCUSDT": "btcusdt",
}
View Source
var Tables = map[string]*Table{
	"ticker": &Table{
		"24hrTicker",

		[]string{"Timestamp TIMESTAMP",
			"Symbol TEXT",
			"Price FLOAT",
			"Close FLOAT",
			"Open FLOAT",
			"Price_Change FLOAT",
			"Price_Change_Percent FLOAT",
			"Last_Quantity FLOAT",
			"Last_Price FLOAT",
			"Weighted_Average_Price FLOAT",
			"First_Trade_Price FLOAT",
		},
		"",
	},

	"miniTicker": &Table{
		"miniTicker",

		[]string{"Timestamp TIMESTAMP",
			"Symbol TEXT",
			"Price FLOAT",
			"Close FLOAT",
			"Open FLOAT",
			"Price_Change FLOAT",
			"Price_Change_Percent FLOAT",
			"Last_Quantity FLOAT",
			"Last_Price FLOAT",
			"Weighted_Average_Price FLOAT",
			"First_Trade_Price FLOAT",
		},
		"",
	},
}

Functions

func CheckErr

func CheckErr(err error) bool

func FilterStream

func FilterStream(raw []byte) ([]byte, error)

func NewCollector

func NewCollector(err chan error, dir string, format string) (*collector, error)

Types

type AggTrade

type AggTrade struct {
	Event_Type     string `json:"e"`
	Event_Time     uint64 `json:"E"`
	Symbol         string `json:"s"`
	Trade_ID       uint64 `json:"t"`
	Price          string `json:"p"`
	Quantity       string `json:"q"`
	First_Trade_ID uint64 `json:"b"`
	Last_Trade_ID  uint64 `json:"a"`
	Trade_Time     uint64 `json:"T"`
	Market_Maker   bool   `json:"m"`
	Ignore         bool   `json:"M"`
}

type Depth

type Depth struct {
	Event_Type               string     `json:"e"`
	Event_Time               uint64     `json:"E"`
	Symbol                   string     `json:"s"`
	First_Update_ID_In_Event uint64     `json:"U"`
	Final_Update_ID_In_Event uint64     `json:"u"`
	Bids_To_Be_Updated       [][]string `json:"b"`
	Asks_To_Be_Updated       [][]string `json:"a"`
}

type Filer

type Filer struct {
	Format    string
	Directory string
	ErrorChan chan error
	Collector *collector
}

func (*Filer) File

func (f *Filer) File(raw []byte)

func (*Filer) FileArray

func (f *Filer) FileArray(raw []byte)

func (*Filer) Save

func (f *Filer) Save(filepath string, time string, data *[]byte, b ...bool)

type MiniTicker

type MiniTicker struct {
	Event_Type                      string `json:"e"`
	Event_Time                      uint64 `json:"E"`
	Symbol                          string `json:"s"`
	Close_Price                     string `json:"c"`
	Open_Price                      string `json:"o"`
	High                            string `json:"h"`
	Low                             string `json:"l"`
	Total_Traded_Base_Asset_Volume  string `json:"v"`
	Total_Traded_Quote_Asset_Volume string `json:"q"`
}

type Options

type Options struct {
	Format    string
	Directory string
}

type Stream

type Stream struct {
	Name string      `json:"stream"`
	Data interface{} `json:"data"`
}

type Table

type Table struct {
	Name   string
	Fields []string
	Values string
}

func (*Table) GetFields

func (t *Table) GetFields() string

func (*Table) GetValues

func (t *Table) GetValues() string

type Ticker

type Ticker struct {
	Event_Type                      string `json:"e"`
	Event_Time                      uint64 `json:"E"`
	Symbol                          string `json:"s"`
	Price_Change                    string `json:"p"`
	Price_Change_Percent            string `json:"P"`
	Weighted_Average_Price          string `json:"w"`
	First_Trade_Price               string `json:"x"`
	Last_Trade_Price                string `json:"c"`
	Last_Quantity                   string `json:"Q"`
	Best_Bid_Price                  string `json:"b"`
	Best_Bid_Quantity               string `json:"B"`
	Best_Ask_Price                  string `json:"a"`
	Best_Ask_Quantity               string `json:"A"`
	Open_Price                      string `json:"o"`
	High                            string `json:"h"`
	Low                             string `json:"l"`
	Total_Traded_Base_Asset_Volume  string `json:"v"`
	Total_Traded_Quote_Asset_Volume string `json:"q"`
	Statistics_Open_Time            uint64 `json:"O"`
	Statistics_Close_Time           uint64 `json:"C"`
	First_Trade_ID                  uint64 `json:"F"`
	Last_Trade_ID                   uint64 `json:"L"`
	Total_Number_Of_Trades          uint64 `json:"n"`
}

type Trade

type Trade struct {
	Event_Type      string `json:"e"`
	Event_Time      uint64 `json:"E"`
	Symbol          string `json:"s"`
	Trade_ID        uint64 `json:"t"`
	Price           string `json:"p"`
	Quantity        string `json:"q"`
	Buyer_Order_ID  uint64 `json:"b"`
	Seller_Order_ID uint64 `json:"a"`
	Trade_Time      uint64 `json:"T"`
	Market_Maker    bool   `json:"m"`
	Ignore          bool   `json:"M"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL