model

package
v0.0.0-...-df03107 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2020 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SideBuy  = "Buy"
	SideSell = "Sell"
)
View Source
const (
	OrdLimit        = "Limit"           // 限价买入
	OrdMarket       = "Market"          // 市价买入
	OrdStop         = "Stop"            // 止损市价平仓单
	OrdStopLimit    = "StopLimit"       // 止损限价平仓单
	LimitIfTouched  = "LimitIfTouched"  // 止盈限价平仓单
	MarketIfTouched = "MarketIfTouched" // 止盈市价平仓单
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DepthRecord

type DepthRecord struct {
	Symbol string  `json:"symbol"`
	ID     float64 `json:"id"`
	Side   string  `json:"side"`
	Price  float64 `json:"price"`
	Amount float64 `json:"amount"`
}

type Funding

type Funding struct {
	ID          primitive.ObjectID `bson:"_id" json:"id"`
	CreateTime  time.Time          `bson:"createTime" json:"createTime"`
	UpdateTime  time.Time          `bson:"updateTime" json:"updateTime"`
	Symbol      string             `bson:"symbol" json:"symbol"`
	FundingRate float64            `bson:"fundingRate" json:"fundingRate"`
	Timestamp   time.Time          `bson:"timestamp" json:"timestamp"`
}

func NewFunding

func NewFunding() *Funding

type FundingService

type FundingService struct {
	// contains filtered or unexported fields
}

func NewFundingService

func NewFundingService(
	exchange, symbol string, db *storage.MongoProxy) *FundingService

func (*FundingService) BatchInsert

func (service *FundingService) BatchInsert(fl []*Funding) error

func (FundingService) Insert

func (service FundingService) Insert(obj interface{}) (*primitive.ObjectID, error)

type Kline

type Kline struct {
	ID         primitive.ObjectID `bson:"_id" json:"id"`
	CreateTime time.Time          `bson:"createTime" json:"createTime"`
	UpdateTime time.Time          `bson:"updateTime" json:"updateTime"`
	Symbol     string             `bson:"symbol" json:"symbol"`
	Open       float64            `bson:"open" json:"open"`
	Close      float64            `bson:"close" json:"close"`
	High       float64            `bson:"high" json:"high"`
	Low        float64            `bson:"low" json:"low"`
	Vol        float64            `bson:"vol" json:"vol"`
	Timestamp  time.Time          `bson:"timestamp" json:"timestamp"`
}

func CreateKline

func CreateKline() *Kline

func NewKline

func NewKline(t time.Duration, symbol string, price float64) *Kline

func (*Kline) IsInit

func (kline *Kline) IsInit() bool

func (*Kline) String

func (kline *Kline) String() string

func (*Kline) UpdateKline

func (kline *Kline) UpdateKline(data *Trade)

type KlineService

type KlineService struct {
	// contains filtered or unexported fields
}

func NewKlineService

func NewKlineService(
	exchange, symbol string, interval time.Duration,
	db *storage.MongoProxy) *KlineService

func (*KlineService) BatchInsert

func (service *KlineService) BatchInsert(kl []*Kline) error

func (*KlineService) GetKlines

func (service *KlineService) GetKlines(
	limit, offset int64, tsDesc bool) ([]*Kline, error)

func (*KlineService) GetKlinesByTs

func (service *KlineService) GetKlinesByTs(
	tsDesc bool, start, end time.Time) ([]*Kline, error)

func (KlineService) Insert

func (service KlineService) Insert(obj interface{}) (*primitive.ObjectID, error)

func (*KlineService) Merge

func (service *KlineService) Merge(kl []*Kline) *Kline

type Liquidation

type Liquidation struct {
	ID         primitive.ObjectID `bson:"_id" json:"id"`
	CreateTime time.Time          `bson:"createTime" json:"createTime"`
	UpdateTime time.Time          `bson:"updateTime" json:"updateTime"`
	Symbol     string             `bson:"symbol" json:"symbol"`
	Side       string             `bson:"side" json:"side"`
	Price      float64            `bson:"price" json:"price"`
	Volume     float64            `bson:"volume" json:"volume"`
}

func NewLiquidation

func NewLiquidation() *Liquidation

type LiquidationService

type LiquidationService struct {
	// contains filtered or unexported fields
}

func NewLiquidationService

func NewLiquidationService(
	exchange, symbol string, db *storage.MongoProxy) *LiquidationService

func (LiquidationService) BatchInsert

func (service LiquidationService) BatchInsert(objs []interface{}) error

func (LiquidationService) Insert

func (service LiquidationService) Insert(obj interface{}) (*primitive.ObjectID, error)

type Order

type Order struct {
	Symbol       string    `json:"symbol"`
	OrderID      string    `json:"orderID"`
	ClOrdID      string    `json:"clOrdID"`
	OrdType      string    `json:"ordType"`
	Price        float64   `json:"price"`
	AvgPrice     float64   `json:"avgPrice"`
	Amount       float64   `json:"amount"`
	FilledAmount float64   `json:"filledAmount"`
	Side         string    `json:"side"`
	OrdStatus    string    `json:"ordStatus"`
	Timestamp    time.Time `json:"timestamp"`
}

type Position

type Position struct {
	Account        float64 `json:"account"`
	Symbol         string  `json:"symbol"`
	Currency       string  `json:"currency"`
	LeverRate      float64 `json:"leverRate"`      // 杠杆率
	ForceLiquPrice float64 `json:"forceLiquPrice"` //预估爆仓价

	SellAmount       float64 `json:"sellAmount"`       // 空单量
	SellAvailable    float64 `json:"sellAvailable"`    // 可用空单量
	SellPriceAvg     float64 `json:"sellPriceAvg"`     // 空单开仓均价
	SellPriceCost    float64 `json:"sellPriceCost"`    // 空单持仓金额
	SellProfitReal   float64 `json:"sellProfitReal"`   // 空单浮盈
	OpenOrderSellQty float64 `json:"openOrderSellQty"` // 委托空单平仓数量

	BuyAmount       float64 `json:"buyAmount"`       // 多单量
	BuyAvailable    float64 `json:"buyAvailable"`    // 可用多单量
	BuyPriceAvg     float64 `json:"buyPriceAvg"`     // 多单开仓均价
	BuyPriceCost    float64 `json:"buyPriceCost"`    // 多餐持仓金额
	BuyProfitReal   float64 `json:"buyProfitReal"`   // 多单浮盈
	OpenOrderBuyQty float64 `json:"openOrderBuyQty"` // 委托多单平仓数量
}

type Quote

type Quote struct {
	Symbol    string    `json:"symbol"`
	BidSize   float64   `json:"bidSize"`
	BidPrice  float64   `json:"bidPrice"`
	AskSize   float64   `json:"askSize"`
	AskPrice  float64   `json:"askPrice"`
	Timestamp time.Time `json:"timestamp"`
}

type Trade

type Trade struct {
	ID         primitive.ObjectID `bson:"_id" json:"id"`
	CreateTime time.Time          `bson:"createTime" json:"createTime"`
	UpdateTime time.Time          `bson:"updateTime" json:"updateTime"`
	Symbol     string             `bson:"symbol" json:"symbol"`
	TID        string             `bson:"tid" json:"tid"`
	Side       string             `bson:"side" json:"side"`
	Price      float64            `bson:"price" json:"price"`
	Amount     float64            `bson:"amount" json:"amount"`
	Timestamp  time.Time          `bson:"timestamp" json:"timestamp"`
}

func NewTrade

func NewTrade() *Trade

type TradeService

type TradeService struct {
	// contains filtered or unexported fields
}

func NewTradeService

func NewTradeService(
	exchange, symbol string, db *storage.MongoProxy) *TradeService

func (TradeService) BatchInsert

func (service TradeService) BatchInsert(objs []interface{}) error

func (TradeService) Insert

func (service TradeService) Insert(obj interface{}) (*primitive.ObjectID, error)

Jump to

Keyboard shortcuts

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