Documentation ¶
Index ¶
- Constants
- Variables
- type ApiError
- type Balance
- type Bitflyer
- func (bf *Bitflyer) CancelAllChildOrders(productCode string) error
- func (bf *Bitflyer) CancelChildOrder(productCode string, childOrderAcceptanceId string) error
- func (bf *Bitflyer) GetBalance() (*[]Balance, error)
- func (bf *Bitflyer) GetBoard(productCode string) (*Board, error)
- func (bf *Bitflyer) GetBoardState(productCode string) (*BoardState, error)
- func (bf *Bitflyer) GetChildOrders(params map[string]string) ([]ChildOrder, error)
- func (bf *Bitflyer) GetChildOrdersByDate(productCode string, from time.Time, to time.Time) ([]ChildOrder, error)
- func (bf *Bitflyer) GetCollateral() (*Collateral, error)
- func (bf *Bitflyer) GetExecutions(params map[string]string) ([]Execution, error)
- func (bf *Bitflyer) GetHealth(productCode string) (*Health, error)
- func (bf *Bitflyer) GetMarkets() ([]Market, error)
- func (bf *Bitflyer) GetMyExecutions(params map[string]string) ([]MyExecution, error)
- func (bf *Bitflyer) GetMyExecutionsByDate(productCode string, from time.Time, to time.Time) ([]MyExecution, error)
- func (bf *Bitflyer) GetPositions(productCode string) ([]Position, error)
- func (bf *Bitflyer) GetRelatedExecutionByOrder(order ChildOrder) ([]MyExecution, error)
- func (bf *Bitflyer) GetTicker(productCode string) (*Ticker, error)
- func (bf *Bitflyer) SendChildOrder(productCode string, childOrderType string, side string, size float64, ...) (map[string]string, error)
- type Board
- type BoardState
- type Callback
- type ChildOrder
- type ChildOrderEvent
- type Collateral
- type EventTime
- type Execution
- type Health
- type Market
- type MyExecution
- type OHLC
- type OpenDate
- type ParentOrderEvent
- type Position
- type Ticker
- type TickerTime
- type TimeWithSecond
- type WebSocketClient
- func (bf *WebSocketClient) Auth(apiKey string, apiSecret string) error
- func (bf *WebSocketClient) Connect() error
- func (bf *WebSocketClient) Receive()
- func (bf *WebSocketClient) SubscribeBoard(symbol string)
- func (bf *WebSocketClient) SubscribeBoardSnapshot(symbol string)
- func (bf *WebSocketClient) SubscribeChildOrder()
- func (bf *WebSocketClient) SubscribeExecutions(symbol string)
- func (bf *WebSocketClient) SubscribeParentOrder()
- func (bf *WebSocketClient) SubscribeTicker(symbol string)
- func (bf *WebSocketClient) UnsubscribeBoard(symbol string)
- func (bf *WebSocketClient) UnsubscribeBoardSnapshot(symbol string)
- func (bf *WebSocketClient) UnsubscribeChildOrder()
- func (bf *WebSocketClient) UnsubscribeExecutions(symbol string)
- func (bf *WebSocketClient) UnsubscribeParentOrder()
- func (bf *WebSocketClient) UnsubscribeTicker(symbol string)
Constants ¶
const ( // PathGetMyExecutions is path of api to get own executions PathGetMyExecutions = "/me/getexecutions" // PathGetChildOrders is path of api to get own child orders PathGetChildOrders = "/me/getchildorders" // PathGetPositions is path of api to get positions PathGetPositions = "/me/getpositions" // PathGetCollateral is path of api to get collateral PathGetCollateral = "/me/getcollateral" // PathGetBalance is path of api to get balance PathGetBalance = "/me/getbalance" // PathSendChildOrder is path of api to send child order PathSendChildOrder = "/me/sendchildorder" // PathCancelChildOrder is path of api to cancel child order PathCancelChildOrder = "/me/cancelchildorder" // PathCancelAllChildOrders is path of api to cancel all child orders PathCancelAllChildOrders = "/me/cancelallchildorders" )
const ( // PathGetMarkets is path of '/getmarkets' PathGetMarkets = "/getmarkets" // PathGetBoard is path of '/getboard' PathGetBoard = "/getboard" // PathGetTicker is path of '/getticker' PathGetTicker = "/getticker" // PathGetExecutions is path of '/getexecutions' PathGetExecutions = "/getexecutions" // PathGetBoardState is path of '/getboardstate' PathGetBoardState = "/getboardstate" // PathGetHealth is path of '/gethealth' PathGetHealth = "/gethealth" )
const ( HealthNormal = "NORMAL" // health: NORMAL HealthBusy = "BUSY" // health: BUSY HealthVeryBusy = "VERY_BUSY" // health: VERY_BUSY HealthSuperBusy = "SUPER_BUSY" // health: SUPER_BUSY HealthNoOrder = "NO_ORDER" // health: NO_ORDER HealthStop = "STOP" // health: STOP StateRunning = "RUNNING" // state: RUNNING StateClosed = "CLOSED" // state: CLOSED StateStarting = "STARTING" // state: STARTING StatePreopen = "PREOPEN" // state: PREOPEN StateCircuitBreak = "CIRCUIT_BREAK" // state: CIRCUIT_BREAK StateAwatingSq = "AWAITING_SQ" // state: AWAITING_SQ StateMatured = "MATURED" // state: MATURED ChildOrderTypeLimit = "LIMIT" // order type: LIMIT ChildOrderTypeMarket = "MARKET" // order type: MARKET SideBuy = "BUY" // side: BUY SideSell = "SELL" // side: SELL MinimumOrderbleSize = 0.01 // minimum orderable size )
Export const
const ( // ProductCodeBtcJpy is product code of BTC_JPY ProductCodeBtcJpy = "BTC_JPY" // ProductCodeFxBtcJpy is product code of FX_BTC_JPY ProductCodeFxBtcJpy = "FX_BTC_JPY" // ProductCodeEthBtc is product code of ETH_BTC ProductCodeEthBtc = "ETH_BTC" )
Variables ¶
var Logger *log.Logger
Logger is logger.
Functions ¶
This section is empty.
Types ¶
type ApiError ¶
type ApiError struct { Status int `json:"status"` // status ErrorMessage string `json:"error_message"` // error_message Data string `json:"data"` // data }
ApiError is lightning api error.
type Balance ¶
type Balance struct { CurrencyCode string `json:"currency_code"` // currency_code Amount float64 `json:"amount"` // amount Available float64 `json:"available"` // available }
Balance is the balance of account.
type Bitflyer ¶
type Bitflyer struct { BaseUrl string // base url ApiVersion string // api version Debug bool // if true, debug mode RetryLimit int // retry limit RetryStatus []int // status to retry RetryInterval time.Duration // retry interval // contains filtered or unexported fields }
Bitflyer is bitFlyer api client.
func NewBitflyer ¶
func NewBitflyer( apiKey string, apiSecret string, retryStatus []int, retryLimit int, retryInterval time.Duration) *Bitflyer
NewBitflyer creates Bitflyer instance.
func (*Bitflyer) CancelAllChildOrders ¶
CancelAllChildOrders cancels all child orders.
func (*Bitflyer) CancelChildOrder ¶
CancelChildOrder cancels child orders.
func (*Bitflyer) GetBalance ¶
GetBalance gets balance.
func (*Bitflyer) GetBoardState ¶
func (bf *Bitflyer) GetBoardState(productCode string) (*BoardState, error)
GetBoardState gets board state of spefied product_code.
func (*Bitflyer) GetChildOrders ¶
func (bf *Bitflyer) GetChildOrders(params map[string]string) ([]ChildOrder, error)
GetChildOrders gets own child orders.
Required parameters - product_code
func (*Bitflyer) GetChildOrdersByDate ¶
func (*Bitflyer) GetCollateral ¶
func (bf *Bitflyer) GetCollateral() (*Collateral, error)
GetCollateral gets collateral.
func (*Bitflyer) GetExecutions ¶
GetExecutions gets executions.
func (*Bitflyer) GetMarkets ¶
GetMarkets gets market information.
func (*Bitflyer) GetMyExecutions ¶
func (bf *Bitflyer) GetMyExecutions(params map[string]string) ([]MyExecution, error)
GetMyExecutions gets own executions.
func (*Bitflyer) GetMyExecutionsByDate ¶
func (*Bitflyer) GetPositions ¶
GetPositions gets positions.
func (*Bitflyer) GetRelatedExecutionByOrder ¶
func (bf *Bitflyer) GetRelatedExecutionByOrder(order ChildOrder) ([]MyExecution, error)
type Board ¶
type Board struct { Time time.Time `json:"time"` // time MidPrice float64 `json:"mid_price"` // mid_price Bids map[float64]float64 `json:"bids"` // bids Asks map[float64]float64 `json:"asks"` // asks }
Board is board.
type BoardState ¶
type BoardState struct { Health string `json:"health"` // health State string `json:"state"` // state Data map[string]float64 `json:"data"` // data }
BoardState is board's state.
type Callback ¶ added in v1.3.0
type Callback interface { // OnReceiveBoard is the callbck when board is received from websocket. OnReceiveBoard(channelName string, board *Board) // OnReceiveBoardSnapshot is the callbck when board snapshot is received from websocket. OnReceiveBoardSnapshot(channelName string, board *Board) // OnReceiveExecutions is the callbck when executions is received from websocket. OnReceiveExecutions(channelName string, executions []Execution) // OnReceiveTicker is the callbck when ticker is received from websocket. OnReceiveTicker(channelName string, ticker *Ticker) // OnReceiveChildOrderEvents is the callbck when child order event is received from websocket. OnReceiveChildOrderEvents(channelName string, event []ChildOrderEvent) // OnReceiveParentOrderEvents is the callbck when board is received from websocket. OnReceiveParentOrderEvents(channelName string, event []ParentOrderEvent) // OnErrorOccur is the callbck when error is occurred during receiving stream data. OnErrorOccur(channelName string, err error) }
Callback is the callback functions when receiving data from websocket.
type ChildOrder ¶
type ChildOrder struct { Id int64 `json:"id"` // id ChildOrderId string `json:"child_order_id"` // child_order_id ProductCode string `json:"product_code"` // product_code Side string `json:"side"` // side ChildOrderType string `json:"child_order_type"` // child_order_type Price float64 `json:"price"` // price AveragePrice float64 `json:"average_price"` // average_price Size float64 `json:"size"` // size ChildOrderState string `json:"child_order_state"` // child_order_state ExpireDate TimeWithSecond `json:"expire_date"` // expire_date ChildOrderDate TimeWithSecond `json:"child_order_date"` // child_order_date ChildOrderAcceptanceId string `json:"child_order_acceptance_id"` // child_order_acceptance_id OutstandingSize float64 `json:"outstanding_size"` // outstanding_size CancelSize float64 `json:"cancel_size"` // cancel_size ExecutedSize float64 `json:"executed_size"` // executed_size TotalCommission float64 `json:"total_commission"` // total_commission Executions []MyExecution }
ChildOrder is own child orders.
type ChildOrderEvent ¶
type ChildOrderEvent struct { ProductCode string `json:"product_code"` // product_code ChildOrderId string `json:"child_order_id"` // child_order_id ChildOrderAcceptanceId string `json:"child_order_acceptance_id"` // child_order_acceptance_id EventDate EventTime `json:"event_date"` // event_date EventType string `json:"event_type"` // event_type ChildOrderType string `json:"child_order_type"` // child_order_type ExpireDate TimeWithSecond `json:"expire_date"` // expire_date Reason string `json:"reason"` // reason ExecId int `json:"exec_id"` // exec_id Side string `json:"side"` // side Price int `json:"price"` // price Size float64 `json:"size"` // size Commission float64 `json:"commission"` // commission Sfd float64 `json:"sfd"` // sfd }
ChildOrderEvent is type of child order event receiving from websocket.
func (*ChildOrderEvent) String ¶
func (t *ChildOrderEvent) String() string
String converts all fields value to one string.
type Collateral ¶
type Collateral struct { Collateral float64 `json:"collateral"` // collateral OpenPositionPnl float64 `json:"open_position_pnl"` // open_position_pnl RequireCollateral float64 `json:"require_collateral"` // require_collateral KeepRate float64 `json:"keep_rate"` // keep_rate }
Collateral is the collateral of account.
type EventTime ¶
func (*EventTime) UnmarshalJSON ¶
UnmarshalJSON converts json data to EventTime.
type Execution ¶
type Execution struct { Id int64 `json:"id"` // id ExecDate time.Time `json:"exec_date"` // exec_date Price float64 `json:"price"` // price Size float64 `json:"size"` // size Side string `json:"side"` // side BuyChildOrderAcceptanceId string `json:"buy_child_order_acceptance_id"` // buy_child_order_acceptance_id SellChildOrderAcceptanceId string `json:"sell_child_order_acceptance_id"` // sell_child_order_acceptance_id ReceivedTime time.Time `json:receivedTime` // receivedTime }
Execution is one of the execution history
type Health ¶
type Health struct {
Status string `json:"status"` // status
}
Health is market health state.
type Market ¶
type Market struct { ProductCode string `json:"product_code"` // product_code MarketType string `json:"market_type"` // market_type Alias string `json:"alias"` // alias }
Market is the return value of '/getmarkets' API.
type MyExecution ¶
type MyExecution struct { Id int64 `json:"id"` // id ChildOrderId string `json:"child_order_id"` // child_order_id Side string `json:"side"` // side Price float64 `json:"price"` // price Size float64 `json:"size"` // size Commission float64 `json:"commission"` // commission ExecDate TickerTime `json:"exec_date"` // exec_date ChildOrderAcceptanceId string `json:"child_order_acceptance_id"` // child_order_acceptance_id }
MyExecution is executed own history.
type OHLC ¶
type OHLC struct { Time time.Time Open float64 High float64 Low float64 Close float64 Volume float64 Delay time.Duration }
OHLC is four value candle(open, high, low, close).
type OpenDate ¶ added in v1.3.10
OpenDate is the date created position
func (*OpenDate) UnmarshalJSON ¶ added in v1.3.10
UnmarshalJSON unmarchals json data.
type ParentOrderEvent ¶
type ParentOrderEvent struct { ProductCode string `json:"product_code"` // product_code ParentOrderId string `json:"parent_order_id"` // parent_order_id ParentOrderAcceptanceId string `json:"parent_order_acceptance_id"` // parent_order_acceptance_id EventDate EventTime `json:"event_date"` // event_date EventType string `json:"event_type"` // event_type ParentOrderType string `json:"parent_order_type"` // parent_order_type Reason string `json:"reason"` // reason ChildOrderType string `json:"child_order_type"` // child_order_type ParameterIndex int `json:"parameter_index"` // parameter_index ChildOrderAcceptanceId string `json:"child_order_acceptance_id"` // child_order_acceptance_id Side string `json:"side"` // side Price int `json:"price"` // price Size float64 `json:"size"` // size ExpireDate TimeWithSecond `json:"expire_date"` // expire_date }
Event of parent order happened.
type Position ¶
type Position struct { ProductCode string `json:"product_code"` // product_code Side string `json:"side"` // side Price float64 `json:"price"` // price Size float64 `json:"size"` // size Commission float64 `json:"commission"` // commission SwapPointAccumulate float64 `json:"swap_point_accumulate"` // swap_point_accumulate RequireCollateral float64 `json:"require_collateral"` // require_collateral OpenDate OpenDate `json:"open_date"` // open_date Leverage float64 `json:"leverage"` // leverage Pnl float64 `json:"pnl"` // pnl Std float64 `json:"sfd"` // sfd }
Position is own positions.
type Ticker ¶
type Ticker struct { ProductCode string `json:"product_code"` // product_code Timestamp TickerTime `json:"timestamp"` // timestamp TickId int64 `json:"tick_id"` // tick_id BestBid float64 `json:"best_bid"` // best_bid BestAsk float64 `json:"best_ask"` // best_ask BestBidSize float64 `json:"best_bid_size"` // best_bid_size BestAskSize float64 `json:"best_ask_size"` // best_ask_size TotalBidDepth float64 `json:"total_bid_depth"` // total_bid_depth TotalAskDepth float64 `json:"total_ask_depth"` // total_ask_depth Ltp float64 `json:"ltp"` // ltp Volume float64 `json:"volume"` // volume VolumeByProduct float64 `json:"volume_by_product"` // volume_by_product }
Ticker is the return value of '/getticker' API.
type TickerTime ¶
TickerTime is time of ticker.
func (*TickerTime) UnmarshalJSON ¶
func (tt *TickerTime) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarchals json data.
type TimeWithSecond ¶
TimeWithSecond is time with second as time.Time
func (*TimeWithSecond) UnmarshalJSON ¶
func (tt *TimeWithSecond) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarchals json data.
type WebSocketClient ¶
func (*WebSocketClient) Auth ¶
func (bf *WebSocketClient) Auth(apiKey string, apiSecret string) error
Auth authenticates client to subscribe private channels.
func (*WebSocketClient) Connect ¶
func (bf *WebSocketClient) Connect() error
Connect connects to bitflyer's realtime api server.
func (*WebSocketClient) Receive ¶
func (bf *WebSocketClient) Receive()
Receive start receiving stream data from websocket.
func (*WebSocketClient) SubscribeBoard ¶
func (bf *WebSocketClient) SubscribeBoard(symbol string)
SubscribeBoard subscribes board.
func (*WebSocketClient) SubscribeBoardSnapshot ¶
func (bf *WebSocketClient) SubscribeBoardSnapshot(symbol string)
SubscribeBoardSnapshot subscribes board snapshot.
func (*WebSocketClient) SubscribeChildOrder ¶
func (bf *WebSocketClient) SubscribeChildOrder()
SubscribeChildOrder subscribes child orders.
func (*WebSocketClient) SubscribeExecutions ¶
func (bf *WebSocketClient) SubscribeExecutions(symbol string)
SubscribeExecutions subscribes executions.
func (*WebSocketClient) SubscribeParentOrder ¶
func (bf *WebSocketClient) SubscribeParentOrder()
SubscribeParentOrder subscribes parent orders.
func (*WebSocketClient) SubscribeTicker ¶
func (bf *WebSocketClient) SubscribeTicker(symbol string)
SubscribeTicker subscribes ticker.
func (*WebSocketClient) UnsubscribeBoard ¶
func (bf *WebSocketClient) UnsubscribeBoard(symbol string)
func (*WebSocketClient) UnsubscribeBoardSnapshot ¶
func (bf *WebSocketClient) UnsubscribeBoardSnapshot(symbol string)
func (*WebSocketClient) UnsubscribeChildOrder ¶
func (bf *WebSocketClient) UnsubscribeChildOrder()
func (*WebSocketClient) UnsubscribeExecutions ¶
func (bf *WebSocketClient) UnsubscribeExecutions(symbol string)
UnsubscribeExecutions unsubscribes 'lightning_executions_${symbol}'.
func (*WebSocketClient) UnsubscribeParentOrder ¶
func (bf *WebSocketClient) UnsubscribeParentOrder()
func (*WebSocketClient) UnsubscribeTicker ¶
func (bf *WebSocketClient) UnsubscribeTicker(symbol string)
UnsubscribeTicker unsubscribes 'lightning_ticker_${symbol}'.