mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 23:16:45 +00:00
* adds open interest to exchanges * ADDS TESTING YEAH * New endpoints, BTSE, RPCS, cached * slight design change, begin gateio You will need to get cached for each exchange that supports it * gateio, huobi, rpc * fix up kraken, cache retrieval * okx, gateio * finalising all implementations and tests * definitely my final ever commit on this * Well, well, well * final v2 * quick fix of bug * test coverage, assert notempty, test helper Added a new testhelper for currency management because its very annoying in a parallel test setting which wastes so much space otherwise * minimises REST requests for Open Interest * types.Number merge misses * Minimises Kraken REST calls * len change, value -> pointer receiver * further fixup * fixes gateio, batch calculates open interest * single gateio, lint const fixes * rejig and more thorough oi for huobi * formatting expansion * minor fix for handling expiring contracts * rm unused Binance strings * add bybit support, fix bybit issues * oopsie doopsie, dont look at my whoopsie * Fix issue, remove feature * move an irrelevant function for the pr * mini bybit upgrades * fixes cli request bug
115 lines
2.4 KiB
Go
115 lines
2.4 KiB
Go
package futures
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/shopspring/decimal"
|
|
"github.com/thrasher-corp/gocryptotrader/currency"
|
|
"github.com/thrasher-corp/gocryptotrader/exchanges/asset"
|
|
"github.com/thrasher-corp/gocryptotrader/exchanges/fundingrate"
|
|
)
|
|
|
|
// Contract holds details on futures contracts
|
|
type Contract struct {
|
|
Exchange string
|
|
Name currency.Pair
|
|
Underlying currency.Pair
|
|
Asset asset.Item
|
|
StartDate time.Time
|
|
EndDate time.Time
|
|
IsActive bool
|
|
Status string
|
|
Type ContractType
|
|
SettlementType ContractSettlementType
|
|
// Optional values if the exchange offers them
|
|
SettlementCurrencies currency.Currencies
|
|
MarginCurrency currency.Code
|
|
Multiplier float64
|
|
MaxLeverage float64
|
|
LatestRate fundingrate.Rate
|
|
FundingRateFloor decimal.Decimal
|
|
FundingRateCeiling decimal.Decimal
|
|
}
|
|
|
|
// ContractSettlementType holds the various style of contracts offered by futures exchanges
|
|
type ContractSettlementType uint8
|
|
|
|
// ContractSettlementType definitions
|
|
const (
|
|
UnsetSettlementType ContractSettlementType = iota
|
|
Linear
|
|
Inverse
|
|
Quanto
|
|
LinearOrInverse
|
|
)
|
|
|
|
// String returns the string representation of a contract settlement type
|
|
func (d ContractSettlementType) String() string {
|
|
switch d {
|
|
case UnsetSettlementType:
|
|
return "unset"
|
|
case Linear:
|
|
return "linear"
|
|
case Inverse:
|
|
return "inverse"
|
|
case Quanto:
|
|
return "quanto"
|
|
case LinearOrInverse:
|
|
return "linearOrInverse"
|
|
default:
|
|
return "unknown"
|
|
}
|
|
}
|
|
|
|
// ContractType holds the various style of contracts offered by futures exchanges
|
|
type ContractType uint8
|
|
|
|
// ContractType definitions
|
|
const (
|
|
UnsetContractType ContractType = iota
|
|
Perpetual
|
|
LongDated
|
|
Weekly
|
|
Fortnightly
|
|
ThreeWeekly
|
|
Monthly
|
|
Quarterly
|
|
SemiAnnually
|
|
HalfYearly
|
|
NineMonthly
|
|
Yearly
|
|
Unknown
|
|
)
|
|
|
|
// String returns the string representation of the contract type
|
|
func (c ContractType) String() string {
|
|
switch c {
|
|
case Perpetual:
|
|
return "perpetual"
|
|
case LongDated:
|
|
return "long_dated"
|
|
case Weekly:
|
|
return "weekly"
|
|
case Fortnightly:
|
|
return "fortnightly"
|
|
case ThreeWeekly:
|
|
return "three-weekly"
|
|
case Monthly:
|
|
return "monthly"
|
|
case Quarterly:
|
|
return "quarterly"
|
|
case SemiAnnually:
|
|
return "semi-annually"
|
|
case HalfYearly:
|
|
return "half-yearly"
|
|
case NineMonthly:
|
|
return "nine-monthly"
|
|
case Yearly:
|
|
return "yearly"
|
|
case Unknown:
|
|
return "unknown"
|
|
default:
|
|
return "unset"
|
|
}
|
|
}
|