mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-22 23:16:48 +00:00
FTX: Margin lending/borrow rate history (#981)
* Adds lending rates/borrows to FTX and the command * Movements, renames, rpc test * Fleshing out rpc response * Allows rpcserver to calculate offline (but not gctcli). Expands tests * rn structs. add exchange_wrapper_issues support * Adds a nice yearly rate * Surprise yearly borrow rate! * Rn+Mv to margin package. Fixes some serious whoopsies * Adds average lend/borrow rates instead of sum * rm oopsie whoopsie * This is what the linter was having an issue with * re-gen * lintl * niteroos
This commit is contained in:
67
exchanges/margin/margin_types.go
Normal file
67
exchanges/margin/margin_types.go
Normal file
@@ -0,0 +1,67 @@
|
||||
package margin
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/shopspring/decimal"
|
||||
"github.com/thrasher-corp/gocryptotrader/currency"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/asset"
|
||||
)
|
||||
|
||||
// RateHistoryRequest is used to request a funding rate
|
||||
type RateHistoryRequest struct {
|
||||
Exchange string
|
||||
Asset asset.Item
|
||||
Currency currency.Code
|
||||
StartDate time.Time
|
||||
EndDate time.Time
|
||||
GetPredictedRate bool
|
||||
GetLendingPayments bool
|
||||
GetBorrowRates bool
|
||||
GetBorrowCosts bool
|
||||
|
||||
// CalculateOffline allows for the borrow rate, lending payment amount
|
||||
// and borrow costs to be calculated offline. It requires the takerfeerate
|
||||
// and existing rates
|
||||
CalculateOffline bool
|
||||
TakeFeeRate decimal.Decimal
|
||||
// Rates is used when calculating offline and determiningPayments
|
||||
// Each Rate must have the Rate and Size fields populated
|
||||
Rates []Rate
|
||||
}
|
||||
|
||||
// RateHistoryResponse has the funding rate details
|
||||
type RateHistoryResponse struct {
|
||||
Rates []Rate
|
||||
SumBorrowCosts decimal.Decimal
|
||||
AverageBorrowSize decimal.Decimal
|
||||
SumLendingPayments decimal.Decimal
|
||||
AverageLendingSize decimal.Decimal
|
||||
PredictedRate Rate
|
||||
TakerFeeRate decimal.Decimal
|
||||
}
|
||||
|
||||
// Rate has the funding rate details
|
||||
// and optionally the borrow rate
|
||||
type Rate struct {
|
||||
Time time.Time
|
||||
MarketBorrowSize decimal.Decimal
|
||||
HourlyRate decimal.Decimal
|
||||
YearlyRate decimal.Decimal
|
||||
HourlyBorrowRate decimal.Decimal
|
||||
YearlyBorrowRate decimal.Decimal
|
||||
LendingPayment LendingPayment
|
||||
BorrowCost BorrowCost
|
||||
}
|
||||
|
||||
// LendingPayment contains a lending rate payment
|
||||
type LendingPayment struct {
|
||||
Payment decimal.Decimal
|
||||
Size decimal.Decimal
|
||||
}
|
||||
|
||||
// BorrowCost contains the borrow rate costs
|
||||
type BorrowCost struct {
|
||||
Cost decimal.Decimal
|
||||
Size decimal.Decimal
|
||||
}
|
||||
Reference in New Issue
Block a user