-
-
Notifications
You must be signed in to change notification settings - Fork 301
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1874 from c9s/c9s/binance/margin-next-hourly-inte…
…rest-rate FEATURE: [binance] margin next hourly interest rate support
- Loading branch information
Showing
5 changed files
with
277 additions
and
0 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
34 changes: 34 additions & 0 deletions
34
pkg/exchange/binance/binanceapi/get_margin_future_hourly_interest_rate_request.go
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,34 @@ | ||
package binanceapi | ||
|
||
import ( | ||
"math" | ||
|
||
"github.com/c9s/requestgen" | ||
|
||
"github.com/c9s/bbgo/pkg/fixedpoint" | ||
) | ||
|
||
type HourlyInterestRate struct { | ||
Asset string `json:"asset"` | ||
NextHourlyInterestRate fixedpoint.Value `json:"nextHourlyInterestRate"` | ||
} | ||
|
||
func (r *HourlyInterestRate) GetAnnualizedInterestRate() fixedpoint.Value { | ||
rf := r.NextHourlyInterestRate.Float64() | ||
return fixedpoint.NewFromFloat(math.Pow(rf+1.0, 24*365) - 1.0) | ||
} | ||
|
||
//go:generate requestgen -method GET -url "/sapi/v1/margin/next-hourly-interest-rate" -type GetMarginFutureHourlyInterestRateRequest -responseType []HourlyInterestRate | ||
type GetMarginFutureHourlyInterestRateRequest struct { | ||
client requestgen.AuthenticatedAPIClient | ||
|
||
// assets: List of assets, separated by commas, up to 20 | ||
assets string `param:"assets"` | ||
|
||
// isIsolated: for isolated margin or not, "TRUE", "FALSE" | ||
isIsolated string `param:"isIsolated"` // TRUE or FALSE | ||
} | ||
|
||
func (c *RestClient) NewGetMarginFutureHourlyInterestRateRequest() *GetMarginFutureHourlyInterestRateRequest { | ||
return &GetMarginFutureHourlyInterestRateRequest{client: c} | ||
} |
190 changes: 190 additions & 0 deletions
190
pkg/exchange/binance/binanceapi/get_margin_future_hourly_interest_rate_request_requestgen.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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