okex

package
v0.0.0-...-82d0e4a Latest Latest
Warning

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

Go to latest
Published: May 4, 2022 License: GPL-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BaseURL string
View Source
var TableName string

Functions

func GetOKexResults

func GetOKexResults() (string, error)

過去3日分の利益を取得する関数

func SyncOkexBuyOrders

func SyncOkexBuyOrders(exchange string, orders *[]OkexOrderEvent)

OKEXからデータを取得して、DBと同期するメソッド

func SyncOkexSellOrders

func SyncOkexSellOrders(orders *[]OkexOrderEvent)

func UpdateCancelledOrder

func UpdateCancelledOrder(order_id string) error

func UpdateOkexSellOrders

func UpdateOkexSellOrders(order_id, sell_order_id string, sell_price, sell_size float64)

売り注文を発注した際にDBのレコードをアップデートする

Types

type APIClient

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

func New

func New(key, secret, passphrase, exchange string) *APIClient

func (*APIClient) CancelOrder

func (apiClient *APIClient) CancelOrder(orderID, pair string) (*OrderResponse, error)

Cancel an Order

func (*APIClient) GetBlance

func (apiClient *APIClient) GetBlance(currency string) (*Balance, error)

GetBalance

func (*APIClient) GetOkexTicker

func (apiClient *APIClient) GetOkexTicker(productCode string) (*Ticker, error)

GetTickerInfo

func (*APIClient) GetOrderList

func (apiClient *APIClient) GetOrderList(productCode, state string) (*[]Order, error)

GetOrderList

func (*APIClient) PlaceOrder

func (apiClient *APIClient) PlaceOrder(order *Order) (*OrderResponse, error)

Place an Order

type Balance

type Balance struct {
	Balance   string `json:"balance"`
	Hold      string `json:"hold"`
	Available string `json:"available"`
	Currency  string `json:"currency"`
	ID        string `json:"id"`
}

type BuyOrder

type BuyOrder struct {
	ID             uint    `gorm:"primary_key"`
	OrderID        string  `json:"order_id"`
	Pair           string  `json:"pair"`
	Price          float64 `json:"price"`
	Size           float64 `json:"size"`
	Exchange       string  `json:"exchange"`
	State          int     `json:"state"`
	SellOrderID    string  `json:"sell_order_id"`
	SellOrderState string  `json:"sell_order_state"`
	SellPrice      float64 `json:"sell_price"`
	Side           string  `json:"side"`
	Timestamp      string  `json:"timestamp"`
	Updatetime     string  `json:"updatetime"`
}

TODO structを整理すること TODO timestampはstring以外の型にすること

func GetCancelledOrders

func GetCancelledOrders() ([]BuyOrder, error)

type OkexFilledBuyOrder

type OkexFilledBuyOrder struct {
	OrderID string  `json:"order_id"`
	Price   float64 `json:"price"`
	Size    float64 `json:"size"`
}

func GetSoldBuyOrderList

func GetSoldBuyOrderList(pair string) []OkexFilledBuyOrder

type OkexOrderEvent

type OkexOrderEvent struct {
	OrderID      string    `json:"order_id"`
	ClientOid    string    `json:"client_oid"`
	Type         string    `json:"type"`
	Side         string    `json:"side"`
	InstrumentID string    `json:"instrument_id"`
	OrderType    string    `json:"order_type"`
	Price        string    `json:"price"`
	Size         string    `json:"size"`
	State        string    `json:"state"`
	Timestamp    time.Time `json:"time"`
}

type OkjBuyOrder

type OkjBuyOrder struct {
	ID             uint    `gorm:"primary_key"`
	OrderID        string  `json:"order_id"`
	Pair           string  `json:"pair"`
	Price          float64 `json:"price"`
	Size           float64 `json:"size"`
	Exchange       string  `json:"exchange"`
	State          int     `json:"state"`
	SellOrderID    string  `json:"sell_order_id"`
	SellOrderState string  `json:"sell_order_state"`
	SellPrice      float64 `json:"sell_price"`
	Side           string  `json:"side"`
	Timestamp      string  `json:"timestamp"`
	Updatetime     string  `json:"updatetime"`
}

func GetOKJCancelledOrders

func GetOKJCancelledOrders() ([]OkjBuyOrder, error)

func (*OkjBuyOrder) ConverToBuyOrder

func (o *OkjBuyOrder) ConverToBuyOrder() *BuyOrder

type Order

type Order struct {
	OrderID      string `json:"order_id"`
	ClientOid    string `json:"client_oid"`
	Type         string `json:"type"`
	Side         string `json:"side"`
	InstrumentID string `json:"instrument_id"`
	OrderType    string `json:"order_type"`
	Price        string `json:"price"`
	Size         string `json:"size"`
	State        string `json:"state"`
	Timestamp    string `json:"timestamp"`
}

type OrderResponse

type OrderResponse struct {
	OrderId   string `json:"order_id"`
	ClientOid string `json:"client_oid"`
	Result    bool   `json:"result"`
	ErrorCode string `json:"error_code"`
	ErrorMsg  string `json:"error_message"`
}

type Ticker

type Ticker struct {
	BestAsk string `json:"best_ask"`
	BestBid string `json:"best_bid"`
	Ltp     string `json:"last"`
	High    string `json:"high_24h"`
	Low     string `json:"low_24h"`
}

Jump to

Keyboard shortcuts

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