Skip to content

Commit

Permalink
Release: v1.0.13-alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
amir-the-h committed Sep 29, 2021
1 parent 33061f3 commit f35cf1f
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 20 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ Changelog
=========
All notable changes to this project will be documented in this file.

v1.0.13-alpha
------------

### Changed

- Fixed requests array typ conversion

v1.0.12-alpha
------------

Expand Down
10 changes: 10 additions & 0 deletions api/rest/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
requests "github.com/amir-the-h/okex/requests/rest/account"
responses "github.com/amir-the-h/okex/responses/account"
"net/http"
"strings"
)

// Account
Expand All @@ -27,6 +28,9 @@ func NewAccount(c *ClientRest) *Account {
func (c *Account) GetBalance(req requests.GetBalance) (response responses.GetBalance, err error) {
p := "/api/v5/account/balance"
m := okex.S2M(req)
if len(req.Ccy) > 0 {
m["ccy"] = strings.Join(req.Ccy, ",")
}
res, err := c.client.Do(http.MethodGet, p, true, m)
if err != nil {
return
Expand All @@ -45,6 +49,9 @@ func (c *Account) GetBalance(req requests.GetBalance) (response responses.GetBal
func (c *Account) GetPositions(req requests.GetPositions) (response responses.GetPositions, err error) {
p := "/api/v5/account/positions"
m := okex.S2M(req)
if len(req.InstID) > 0 {
m["instId"] = strings.Join(req.InstID, ",")
}
res, err := c.client.Do(http.MethodGet, p, true, m)
if err != nil {
return
Expand Down Expand Up @@ -217,6 +224,9 @@ func (c *Account) IncreaseDecreaseMargin(req requests.IncreaseDecreaseMargin) (r
func (c *Account) GetLeverage(req requests.GetLeverage) (response responses.Leverage, err error) {
p := "/api/v5/account/leverage-info"
m := okex.S2M(req)
if len(req.InstID) > 0 {
m["instId"] = strings.Join(req.InstID, ",")
}
res, err := c.client.Do(http.MethodGet, p, true, m)
if err != nil {
return
Expand Down
4 changes: 4 additions & 0 deletions api/rest/funding.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
requests "github.com/amir-the-h/okex/requests/rest/funding"
responses "github.com/amir-the-h/okex/responses/funding"
"net/http"
"strings"
)

// Funding
Expand Down Expand Up @@ -46,6 +47,9 @@ func (c *Funding) GetCurrencies() (response responses.GetCurrencies, err error)
func (c *Funding) GetBalance(req requests.GetBalance) (response responses.GetBalance, err error) {
p := "/api/v5/asset/balances"
m := okex.S2M(req)
if len(req.Ccy) > 0 {
m["ccy"] = strings.Join(req.Ccy, ",")
}

res, err := c.client.Do(http.MethodGet, p, true, m)
if err != nil {
Expand Down
7 changes: 7 additions & 0 deletions api/rest/sub_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
requests "github.com/amir-the-h/okex/requests/rest/subaccount"
responses "github.com/amir-the-h/okex/responses/sub_account"
"net/http"
"strings"
)

// SubAccount
Expand Down Expand Up @@ -45,6 +46,9 @@ func (c *SubAccount) ViewList(req requests.ViewList) (response responses.ViewLis
func (c *SubAccount) CreateAPIKey(req requests.CreateAPIKey) (response responses.APIKey, err error) {
p := "/api/v5/users/subaccount/apikey"
m := okex.S2M(req)
if len(req.IP) > 0 {
m["ip"] = strings.Join(req.IP, ",")
}
res, err := c.client.Do(http.MethodPost, p, true, m)
if err != nil {
return
Expand Down Expand Up @@ -81,6 +85,9 @@ func (c *SubAccount) QueryAPIKey(req requests.QueryAPIKey) (response responses.A
func (c *SubAccount) ResetAPIKey(req requests.CreateAPIKey) (response responses.APIKey, err error) {
p := "/api/v5/users/subaccount/modify-apikey"
m := okex.S2M(req)
if len(req.IP) > 0 {
m["ip"] = strings.Join(req.IP, ",")
}
res, err := c.client.Do(http.MethodPost, p, true, m)
if err != nil {
return
Expand Down
34 changes: 17 additions & 17 deletions models/account/account_models.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,14 @@ type (
ThetaPA okex.JSONFloat64 `json:"thetaPA"`
VegaBS okex.JSONFloat64 `json:"vegaBS"`
VegaPA okex.JSONFloat64 `json:"vegaPA"`
PosSide okex.PositionSide `json:"posSide,string"`
MgnMode okex.MarginMode `json:"mgnMode,string"`
InstType okex.InstrumentType `json:"instType,string"`
PosSide okex.PositionSide `json:"posSide"`
MgnMode okex.MarginMode `json:"mgnMode"`
InstType okex.InstrumentType `json:"instType"`
CTime okex.JSONTime `json:"cTime"`
UTime okex.JSONTime `json:"uTime"`
}
BalanceAndPosition struct {
EventType okex.EventType `json:"eventType,string"`
EventType okex.EventType `json:"eventType"`
PTime okex.JSONTime `json:"pTime"`
UTime okex.JSONTime `json:"uTime"`
PosData []*Position `json:"posData"`
Expand All @@ -105,9 +105,9 @@ type (
NotionalCcy okex.JSONFloat64 `json:"notionalCcy"`
Pos okex.JSONFloat64 `json:"pos"`
NotionalUsd okex.JSONFloat64 `json:"notionalUsd"`
PosSide okex.PositionSide `json:"posSide,string"`
InstType okex.InstrumentType `json:"instType,string"`
MgnMode okex.MarginMode `json:"mgnMode,string"`
PosSide okex.PositionSide `json:"posSide"`
InstType okex.InstrumentType `json:"instType"`
MgnMode okex.MarginMode `json:"mgnMode"`
}
Bill struct {
Ccy string `json:"ccy"`
Expand All @@ -124,10 +124,10 @@ type (
OrdID okex.JSONFloat64 `json:"ordId"`
From okex.AccountType `json:"from,string"`
To okex.AccountType `json:"to,string"`
InstType okex.InstrumentType `json:"instType,string"`
MgnMode okex.MarginMode `json:"MgnMode,string"`
Type okex.BillType `json:"type,string"`
SubType okex.BillSubType `json:"subType,string"`
InstType okex.InstrumentType `json:"instType"`
MgnMode okex.MarginMode `json:"MgnMode"`
Type okex.BillType `json:"type"`
SubType okex.BillSubType `json:"subType"`
TS okex.JSONTime `json:"ts"`
}
Config struct {
Expand All @@ -145,8 +145,8 @@ type (
Leverage struct {
InstID string `json:"instId"`
Lever okex.JSONFloat64 `json:"lever"`
MgnMode okex.MarginMode `json:"mgnMode,string"`
PosSide okex.PositionSide `json:"posSide,string"`
MgnMode okex.MarginMode `json:"mgnMode"`
PosSide okex.PositionSide `json:"posSide"`
}
MaxBuySellAmount struct {
InstID string `json:"instId"`
Expand All @@ -170,7 +170,7 @@ type (
MgnCcy string `json:"mgnCcy"`
Ccy string `json:"ccy"`
MaxLoan okex.JSONFloat64 `json:"maxLoan"`
MgnMode okex.MarginMode `json:"mgnMode,string"`
MgnMode okex.MarginMode `json:"mgnMode"`
Side okex.OrderSide `json:"side,string"`
}
Fee struct {
Expand All @@ -179,8 +179,8 @@ type (
Maker okex.JSONFloat64 `json:"maker"`
Delivery okex.JSONFloat64 `json:"delivery,omitempty"`
Exercise okex.JSONFloat64 `json:"exercise,omitempty"`
Category okex.FeeCategory `json:"category,string"`
InstType okex.InstrumentType `json:"instType,string"`
Category okex.FeeCategory `json:"category"`
InstType okex.InstrumentType `json:"instType"`
TS okex.JSONTime `json:"ts"`
}
InterestAccrued struct {
Expand All @@ -189,7 +189,7 @@ type (
Interest okex.JSONFloat64 `json:"interest"`
InterestRate okex.JSONFloat64 `json:"interestRate"`
Liab okex.JSONFloat64 `json:"liab"`
MgnMode okex.MarginMode `json:"mgnMode,string"`
MgnMode okex.MarginMode `json:"mgnMode"`
TS okex.JSONTime `json:"ts"`
}
InterestRate struct {
Expand Down
6 changes: 3 additions & 3 deletions requests/rest/subaccount/subaccount_requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ type (
SubAcct string `json:"subAcct"`
Label string `json:"label"`
Passphrase string `json:"Passphrase"`
Ip []string `json:"ip,omitempty"`
IP []string `json:"ip,omitempty"`
Perm okex.APIKeyAccess `json:"perm,string,omitempty"`
}
QueryAPIKey struct {
ApiKey string `json:"apiKey"`
APIKey string `json:"apiKey"`
SubAcct string `json:"subAcct"`
}
DeleteAPIKey struct {
Pwd string `json:"pwd"`
ApiKey string `json:"apiKey"`
APIKey string `json:"apiKey"`
SubAcct string `json:"subAcct"`
}
GetBalance struct {
Expand Down

0 comments on commit f35cf1f

Please sign in to comment.