Files
gocryptotrader/exchanges/futures/contract.go
Scott 7f0faf7850 futures: add GetFuturesContractDetails wrapper function (#1274)
* all in a days work

* cleanup

* cleanup for real, also stop it binance.json

* minor coverage

* adds gateio to the slurry

* cleanup of types

* verbose verbose verbose verbose verbose verbose

* fixes huobi parsing issue

* fix bybit contract identification

* cleanup

* merge fixes

* addresses many big problems raised by SHAZ

* tracking errors and fixes

* funding rate if avail, fixes currency formatting

* Addresses nits and sneaks in extra fixes

* lint

* minor fixes after rebase

* better contract splitter for currencies like T-USDT

* forgot to add the exchange name like a fool

* merge fixes x1

* kucoin, direction, contract size

* rn direction, fix kucoin time

* WHOOPS

* Update exchanges/kucoin/kucoin_wrapper.go

Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>

* misdirection

---------

Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>
2023-10-03 16:04:45 +11:00

109 lines
2.2 KiB
Go

package futures
import (
"time"
"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
}
// 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
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 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"
}
}