-
-
Notifications
You must be signed in to change notification settings - Fork 302
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pkg/exchange: generate place order request by requestgen
- Loading branch information
1 parent
08fa1e9
commit fcd897b
Showing
6 changed files
with
421 additions
and
258 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package okexapi | ||
|
||
import "github.com/c9s/requestgen" | ||
|
||
type TradeMode string | ||
|
||
const ( | ||
TradeModeCash TradeMode = "cash" | ||
TradeModeIsolated TradeMode = "isolated" | ||
TradeModeCross TradeMode = "cross" | ||
) | ||
|
||
type TargetCurrency string | ||
|
||
const ( | ||
TargetCurrencyBase TargetCurrency = "base_ccy" | ||
TargetCurrencyQuote TargetCurrency = "quote_ccy" | ||
) | ||
|
||
//go:generate -command GetRequest requestgen -method GET -responseType .APIResponse -responseDataField Data | ||
//go:generate -command PostRequest requestgen -method POST -responseType .APIResponse -responseDataField Data | ||
|
||
type OrderResponse struct { | ||
OrderID string `json:"ordId"` | ||
ClientOrderID string `json:"clOrdId"` | ||
Tag string `json:"tag"` | ||
Code string `json:"sCode"` | ||
Message string `json:"sMsg"` | ||
} | ||
|
||
//go:generate PostRequest -url "/api/v5/trade/order" -type PlaceOrderRequest -responseDataType []OrderResponse | ||
type PlaceOrderRequest struct { | ||
client requestgen.AuthenticatedAPIClient | ||
|
||
instrumentID string `param:"instId"` | ||
|
||
// tdMode | ||
// margin mode: "cross", "isolated" | ||
// non-margin mode cash | ||
tradeMode TradeMode `param:"tdMode" validValues:"cross,isolated,cash"` | ||
|
||
// A combination of case-sensitive alphanumerics, all numbers, or all letters of up to 32 characters. | ||
clientOrderID *string `param:"clOrdId"` | ||
|
||
// A combination of case-sensitive alphanumerics, all numbers, or all letters of up to 8 characters. | ||
tag *string `param:"tag"` | ||
|
||
// "buy" or "sell" | ||
side SideType `param:"side" validValues:"buy,sell"` | ||
|
||
orderType OrderType `param:"ordType"` | ||
|
||
size string `param:"sz"` | ||
|
||
// price | ||
price *string `param:"px"` | ||
|
||
// Whether the target currency uses the quote or base currency. | ||
// base_ccy: Base currency ,quote_ccy: Quote currency | ||
// Only applicable to SPOT Market Orders | ||
// Default is quote_ccy for buy, base_ccy for sell | ||
targetCurrency *TargetCurrency `param:"tgtCcy" validValues:"quote_ccy,base_ccy"` | ||
} | ||
|
||
func (c *RestClient) NewPlaceOrderRequest() *PlaceOrderRequest { | ||
return &PlaceOrderRequest{client: c} | ||
} |
151 changes: 0 additions & 151 deletions
151
pkg/exchange/okex/okexapi/place_order_request_accessors.go
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.