-
Notifications
You must be signed in to change notification settings - Fork 793
/
contract.go
117 lines (108 loc) · 2.43 KB
/
contract.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
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
Daily
)
// String returns the string representation of the contract type
func (c ContractType) String() string {
switch c {
case Daily:
return "day"
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"
}
}