{"modulePath":"github.com/QuantProcessing/exchanges","version":"v0.2.20","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package margin\n\n## Constants\n\n```go\nconst (\n\tBaseURL = \"https://api.binance.com\"\n)\n```\n\n## Functions\n\n```go\nfunc GenerateSignature(secretKey, data string) string\n```\nGenerateSignature generates an HMAC SHA256 signature\n\n```go\nfunc Timestamp() int64\n```\nTimestamp returns the current timestamp in milliseconds\n\n## Types\n\n```go\ntype APIError struct {\n\tCode int    `json:\"code\"`\n\tMsg  string `json:\"msg\"`\n}\n```\n\n```go\nfunc (e *APIError) Error() string\n```\n\n```go\ntype Client struct {\n\tBaseURL    string\n\tAPIKey     string\n\tSecretKey  string\n\tHTTPClient *http.Client\n\tLogger     *zap.SugaredLogger\n}\n```\n\n```go\nfunc NewClient() *Client\n```\n\n```go\nfunc (c *Client) Borrow(ctx context.Context, asset string, amount float64, isIsolated bool, symbol string) (int64, error)\n```\nBorrow borrows an asset from the margin account Endpoint: POST /sapi/v1/margin/loan isIsolated: \"TRUE\" or \"FALSE\" (default \"FALSE\" if empty) symbol: mandatory if isIsolated is \"TRUE\"\n\n```go\nfunc (c *Client) CancelOrder(ctx context.Context, symbol string, orderID int64, origClientOrderID string, isIsolated bool) (*MarginOrder, error)\n```\nCancelOrder excels a margin order Endpoint: DELETE /sapi/v1/margin/order\n\n```go\nfunc (c *Client) Delete(ctx context.Context, endpoint string, params map[string]interface{}, signed bool, result interface{}) error\n```\n\n```go\nfunc (c *Client) Get(ctx context.Context, endpoint string, params map[string]interface{}, signed bool, result interface{}) error\n```\n\n```go\nfunc (c *Client) GetAccount(ctx context.Context) (*MarginAccount, error)\n```\nGetAccount queries the cross margin account details Endpoint: GET /sapi/v1/margin/account\n\n```go\nfunc (c *Client) GetIsolatedAccount(ctx context.Context, symbols string) (*IsolatedMarginAccount, error)\n```\nGetIsolatedAccount queries the isolated margin account details Endpoint: GET /sapi/v1/margin/isolated/account symbols: Optional, max 5 symbols, comma separated (e.g. \"BTCUSDT,ETHUSDT\")\n\n```go\nfunc (c *Client) GetOrder(ctx context.Context, symbol string, orderID int64, origClientOrderID string, isIsolated bool) (*MarginOrder, error)\n```\nGetOrder queries a margin order Endpoint: GET /sapi/v1/margin/order\n\n```go\nfunc (c *Client) PlaceOrder(ctx context.Context, params *PlaceOrderParams) (*OrderResponseFull, error)\n```\nPlaceOrder places a margin order Endpoint: POST /sapi/v1/margin/order\n\n```go\nfunc (c *Client) Post(ctx context.Context, endpoint string, params map[string]interface{}, signed bool, result interface{}) error\n```\n\n```go\nfunc (c *Client) Repay(ctx context.Context, asset string, amount float64, isIsolated bool, symbol string) (int64, error)\n```\nRepay repays a loan for the margin account Endpoint: POST /sapi/v1/margin/repay isIsolated: \"TRUE\" or \"FALSE\" (default \"FALSE\" if empty) symbol: mandatory if isIsolated is \"TRUE\"\n\n```go\nfunc (c *Client) WithBaseURL(url string) *Client\n```\n\n```go\nfunc (c *Client) WithCredentials(apiKey, secretKey string) *Client\n```\n\n```go\ntype IsolatedMarginAccount struct {\n\tAssets              []IsolatedMarginSymbol `json:\"assets\"`\n\tTotalAssetOfBtc     string                 `json:\"totalAssetOfBtc\"`\n\tTotalLiabilityOfBtc string                 `json:\"totalLiabilityOfBtc\"`\n\tTotalNetAssetOfBtc  string                 `json:\"totalNetAssetOfBtc\"`\n}\n```\n\n```go\ntype IsolatedMarginAsset struct {\n\tAsset         string `json:\"asset\"`\n\tBorrowEnabled bool   `json:\"borrowEnabled\"`\n\tBorrowed      string `json:\"borrowed\"`\n\tFree          string `json:\"free\"`\n\tInterest      string `json:\"interest\"`\n\tLocked        string `json:\"locked\"`\n\tNetAsset      string `json:\"netAsset\"`\n\tNetAssetOfBtc string `json:\"netAssetOfBtc\"`\n\tRepayEnabled  bool   `json:\"repayEnabled\"`\n\tTotalAsset    string `json:\"totalAsset\"`\n}\n```\n\n```go\ntype IsolatedMarginSymbol struct {\n\tBaseAsset         IsolatedMarginAsset `json:\"baseAsset\"`\n\tQuoteAsset        IsolatedMarginAsset `json:\"quoteAsset\"`\n\tSymbol            string              `json:\"symbol\"`\n\tIsolatedCreated   bool                `json:\"isolatedCreated\"`\n\tEnabled           bool                `json:\"enabled\"`\n\tMarginLevel       string              `json:\"marginLevel\"`\n\tMarginLevelStatus string              `json:\"marginLevelStatus\"`\n\tMarginRatio       string              `json:\"marginRatio\"`\n\tIndexPrice        string              `json:\"indexPrice\"`\n\tLiquidatePrice    string              `json:\"liquidatePrice\"`\n\tLiquidateRate     string              `json:\"liquidateRate\"`\n\tTradeEnabled      bool                `json:\"tradeEnabled\"`\n}\n```\n\n```go\ntype MarginAccount struct {\n\tBorrowEnabled       bool        `json:\"borrowEnabled\"`\n\tMarginLevel         string      `json:\"marginLevel\"`\n\tTotalAssetOfBtc     string      `json:\"totalAssetOfBtc\"`\n\tTotalLiabilityOfBtc string      `json:\"totalLiabilityOfBtc\"`\n\tTotalNetAssetOfBtc  string      `json:\"totalNetAssetOfBtc\"`\n\tTradeEnabled        bool        `json:\"tradeEnabled\"`\n\tTransferEnabled     bool        `json:\"transferEnabled\"`\n\tUserAssets          []UserAsset `json:\"userAssets\"`\n}\n```\nMarginAccount represents the response from /sapi/v1/margin/account\n\n```go\ntype MarginOrder struct {\n\tSymbol              string `json:\"symbol\"`\n\tOrderID             int64  `json:\"orderId\"`\n\tClientOrderID       string `json:\"clientOrderId\"`\n\tTransactTime        int64  `json:\"transactTime\"`\n\tPrice               string `json:\"price\"`\n\tOrigQty             string `json:\"origQty\"`\n\tExecutedQty         string `json:\"executedQty\"`\n\tCummulativeQuoteQty string `json:\"cummulativeQuoteQty\"`\n\tStatus              string `json:\"status\"`\n\tTimeInForce         string `json:\"timeInForce\"`\n\tType                string `json:\"type\"`\n\tSide                string `json:\"side\"`\n\tIsIsolated          bool   `json:\"isIsolated\"`\n}\n```\nMarginOrder represents the response from order placement\n\n```go\ntype OrderResponseFull struct {\n\tMarginOrder\n\tFills []struct {\n\t\tPrice           string `json:\"price\"`\n\t\tQty             string `json:\"qty\"`\n\t\tCommission      string `json:\"commission\"`\n\t\tCommissionAsset string `json:\"commissionAsset\"`\n\t} `json:\"fills\"`\n}\n```\n\n```go\ntype PlaceOrderParams struct {\n\tSymbol           string\n\tSide             string\n\tType             string\n\tTimeInForce      string // Optional\n\tQuantity         float64\n\tQuoteOrderQty    float64 // Optional\n\tPrice            float64 // Optional\n\tNewClientOrderID string  // Optional\n\tSideEffectType   string  // NO_SIDE_EFFECT, MARGIN_BUY, AUTO_REPAY\n\tIsIsolated       bool\n}\n```\n\n```go\ntype TransactionResult struct {\n\tTranId int64 `json:\"tranId\"`\n}\n```\nTransactionResult represents the response for Borrow/Repay\n\n```go\ntype UserAsset struct {\n\tAsset    string `json:\"asset\"`\n\tBorrowed string `json:\"borrowed\"`\n\tFree     string `json:\"free\"`\n\tInterest string `json:\"interest\"`\n\tLocked   string `json:\"locked\"`\n\tNetAsset string `json:\"netAsset\"`\n}\n```\n\n","path":"github.com/QuantProcessing/exchanges/binance/sdk/margin","name":"margin","synopsis":"","isRedistributable":true}
