pkg

package
v0.0.0-...-debd72c Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2023 License: AGPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TgBotApiToken string
	ChatId        int64
	Bot           *tgbotapi.BotAPI
)

Functions

func Binance1

func Binance1(data map[string]interface{}) bool

func Binance2

func Binance2(data map[string]interface{}) bool

func Coinbase1

func Coinbase1(data map[string]interface{}) bool

func InitBot

func InitBot()

func SendMergeMessage

func SendMergeMessage(message string, mediaFiles []string) error

func SendMessage

func SendMessage(name, url, content string, mediaFies []string)

func SendSeparatelyMessage

func SendSeparatelyMessage(url, message string, mediaFiles []string) error

func Upbit1

func Upbit1(data map[string]interface{}) bool

Types

type CanOrder

type CanOrder struct {
	Symbol   string
	Exchange string
}

type Channel

type Channel string

type Config

type Config struct {
	TgBotApiToken string
	TgChatid      int64
	WeiboUid      []int
	MergeMessage  bool
	Interval      int
	SavePicLocal  bool
	SendLivePics  bool
}

type Depth

type Depth string
const (
	DepthLevelFull   Depth = "FULL"
	DepthLevelMedium Depth = "MEDIUM"
	DepthLevel1      Depth = "1"
	DepthLevel5      Depth = "5"
	DepthLevel20     Depth = "20"
)

type Dispatcher

type Dispatcher func(e interface{})

type EndpointCreator

type EndpointCreator func(ctx context.Context) (string, error)

type Kline

type Kline struct {
	E      string `json:"e"`
	E1     int    `json:"E"`
	Symbol string `json:"s"`
	Kline  struct {
		T               int    `json:"t"`
		T1              int    `json:"T"`
		S               string `json:"s"`
		I               string `json:"i"`
		F               int    `json:"f"`
		L               int    `json:"L"`
		Open            string `json:"o"`
		Close           string `json:"c"`
		High            string `json:"h"`
		Low             string `json:"l"`
		Volume          string `json:"v"`
		Number          int    `json:"n"`
		X               bool   `json:"x"`
		Quantity        string `json:"q"`
		TakeBuyVolume   string `json:"V"`
		TakeBuyQuantity string `json:"Q"`
		B               string `json:"B"`
	} `json:"k"`
}

type KlineMessage

type KlineMessage struct {
	Data Kline `json:"data"`
}

type OrderInfo

type OrderInfo struct {
	Symbol   string
	Exchange string
}

type Parser

type Parser func(message []byte) (interface{}, error)

type RuelEngine

type RuelEngine struct {
	Keys []string
	RuleEngine
	CanOrder chan *CanOrder
}

func NewRuelEngine

func NewRuelEngine(co chan *CanOrder) RuelEngine

func (RuelEngine) OrdreNews

func (e RuelEngine) OrdreNews(json []byte)

func (RuelEngine) ParseNews

func (e RuelEngine) ParseNews(json []byte)

func (RuelEngine) TeleNews

func (e RuelEngine) TeleNews(json []byte)

type RuleEngine

type RuleEngine struct {
	Rules  map[string]func(data map[string]interface{}) bool
	Rows   [][]interface{}
	Data   dataframe.DataFrame
	Titles []string
	Time   []string
	Source []string
	Url    []string
}

func NewRule

func NewRule() RuleEngine

func (*RuleEngine) AddRule

func (e *RuleEngine) AddRule(name string, fn func(data map[string]interface{}) bool)

func (*RuleEngine) RunRules

func (e *RuleEngine) RunRules(data map[string]interface{}) (bool, string)

func (*RuleEngine) SaveToCSV

func (e *RuleEngine) SaveToCSV()

type Speed

type Speed string
const (
	SpeedHigh   Speed = "HIGH"
	SpeedMedium Speed = "MEDIUM"
	SpeedLow    Speed = "LOW"
)

type StandardStream

type StandardStream struct {

	// Conn is the websocket connection
	Conn *websocket.Conn

	// ConnCtx is the context of the current websocket connection
	ConnCtx context.Context

	// ConnCancel is the cancel funcion of the current websocket connection
	ConnCancel context.CancelFunc

	// ConnLock is used for locking Conn, ConnCtx and ConnCancel fields.
	// When changing these field values, be sure to call ConnLock
	ConnLock sync.Mutex

	PublicOnly bool

	// ReconnectC is a signal channel for reconnecting
	ReconnectC chan struct{}

	// CloseC is a signal channel for closing stream
	CloseC chan struct{}

	Subscriptions []Subscription
	// contains filtered or unexported fields
}

func NewStandardStream

func NewStandardStream() StandardStream

func (*StandardStream) Close

func (s *StandardStream) Close() error

func (*StandardStream) Connect

func (s *StandardStream) Connect(ctx context.Context) error

Connect starts the stream and create the websocket connection

func (*StandardStream) Dial

func (s *StandardStream) Dial(ctx context.Context, args ...string) (*websocket.Conn, error)

func (*StandardStream) DialAndConnect

func (s *StandardStream) DialAndConnect(ctx context.Context) error

func (*StandardStream) EmitConnect

func (s *StandardStream) EmitConnect()

func (*StandardStream) EmitDisconnect

func (s *StandardStream) EmitDisconnect()

func (*StandardStream) EmitStart

func (s *StandardStream) EmitStart()

func (*StandardStream) GetPublicOnly

func (s *StandardStream) GetPublicOnly() bool

func (*StandardStream) GetSubscriptions

func (s *StandardStream) GetSubscriptions() []Subscription

func (*StandardStream) OnConnect

func (s *StandardStream) OnConnect(cb func())

func (*StandardStream) OnDisconnect

func (s *StandardStream) OnDisconnect(cb func())

func (*StandardStream) OnStart

func (s *StandardStream) OnStart(cb func())

func (*StandardStream) Read

func (s *StandardStream) Read(ctx context.Context, conn *websocket.Conn, cancel context.CancelFunc)

func (*StandardStream) Reconnect

func (s *StandardStream) Reconnect()

func (*StandardStream) SetConn

func (*StandardStream) SetDispatcher

func (s *StandardStream) SetDispatcher(dispatcher Dispatcher)

func (*StandardStream) SetEndpointCreator

func (s *StandardStream) SetEndpointCreator(creator EndpointCreator)

func (*StandardStream) SetParser

func (s *StandardStream) SetParser(parser Parser)

func (*StandardStream) SetPublicOnly

func (s *StandardStream) SetPublicOnly()

func (*StandardStream) Subscribe

func (s *StandardStream) Subscribe(channel Channel, symbol string, options SubscribeOptions)

type StandardStreamEmitter

type StandardStreamEmitter interface {
	Stream
	EmitStart()
	EmitConnect()
	EmitDisconnect()
}

type StandardStreamEventHub

type StandardStreamEventHub interface {
	OnStart(cb func())

	OnConnect(cb func())

	OnDisconnect(cb func())

	OnTradeUpdate(cb func())
}

type Stream

type Stream interface {
	StandardStreamEventHub

	Subscribe(channel Channel, symbol string, options SubscribeOptions)
	GetSubscriptions() []Subscription
	SetPublicOnly()
	GetPublicOnly() bool
	Connect(ctx context.Context) error
	Close() error
}

type SubscribeOptions

type SubscribeOptions struct {
	Depth Depth `json:"depth,omitempty"`
	Speed Speed `json:"speed,omitempty"`
}

SubscribeOptions provides the standard stream options

func (SubscribeOptions) String

func (o SubscribeOptions) String() string

type Subscription

type Subscription struct {
	Symbol  string           `json:"symbol"`
	Channel Channel          `json:"channel"`
	Options SubscribeOptions `json:"options"`
}

type Symbol

type Symbol struct {
	Symbol string `json:"symbol"`
}

type Ticker

type Ticker struct {
	E            string `json:"e"`
	E1           int    `json:"E"`
	Symbol       string `json:"s"`
	P            string `json:"p"`
	P1           string `json:"P"`
	W            string `json:"w"`
	CurrentPrice string `json:"c"`
	Quantity     string `json:"Q"`
	O            string `json:"o"`
	H            string `json:"h"`
	L            string `json:"l"`
	V            string `json:"v"`
	Q1           string `json:"q"`
	O1           int    `json:"O"`
	C1           int    `json:"C"`
	F            int    `json:"F"`
	L1           int    `json:"L"`
	N            int    `json:"n"`
}

type TickerMessage

type TickerMessage struct {
	Data Ticker `json:"data"`
}

type TradeBot

type TradeBot struct {
	NewsStream    *news.Stream
	RuelEngine    *RuelEngine
	BinanceFuture *exchange.BinanceFuture
	CanOrder      chan *CanOrder
}

func NewTradeBot

func NewTradeBot() TradeBot

func (*TradeBot) ListenCreateOrder

func (tb *TradeBot) ListenCreateOrder()

func (*TradeBot) ListenNews

func (tb *TradeBot) ListenNews()

func (*TradeBot) Run

func (tb *TradeBot) Run()

func (*TradeBot) TeleBot

func (tb *TradeBot) TeleBot()

启动电报

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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