Skip to content

Commit

Permalink
add test coverage for contract functions and minor fix on wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
samuael committed Jan 14, 2025
1 parent 86b6a9c commit 087b420
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
40 changes: 40 additions & 0 deletions exchanges/futures/contract_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,43 @@ func TestStringToContractSettlementType(t *testing.T) {
assert.ErrorIs(t, err, contractSettlementTypesMap[x].Error)
}
}

func TestContractSettlementTypeString(t *testing.T) {
t.Parallel()
contractSettlementTypeToStringMap := map[ContractSettlementType]string{
UnsetSettlementType: "unset",
Linear: "linear",
Inverse: "inverse",
Quanto: "quanto",
LinearOrInverse: "linearOrInverse",
Hybrid: "hybrid",
ContractSettlementType(200): "unknown",
}
for k := range contractSettlementTypeToStringMap {
assert.Equal(t, k.String(), contractSettlementTypeToStringMap[k])
}
}

func TestContractTypeToString(t *testing.T) {
t.Parallel()
contractTypeToStringMap := map[ContractType]string{
Daily: "day",
Perpetual: "perpetual",
LongDated: "long_dated",
Weekly: "weekly",
Fortnightly: "fortnightly",
ThreeWeekly: "three-weekly",
Monthly: "monthly",
Quarterly: "quarterly",
SemiAnnually: "semi-annually",
HalfYearly: "half-yearly",
NineMonthly: "nine-monthly",
Yearly: "yearly",
Unknown: "unknown",
UnsetContractType: "unset",
ContractType(200): "unset",
}
for k := range contractTypeToStringMap {
assert.Equal(t, k.String(), contractTypeToStringMap[k])
}
}
2 changes: 0 additions & 2 deletions exchanges/okx/okx_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -2864,8 +2864,6 @@ func (ok *Okx) GetFuturesContractDetails(ctx context.Context, item asset.Item) (
Type: futures.LongDated,
SettlementType: contractSettlementType,
MarginCurrency: currency.NewCode(results[s].QuoteCurrency),
Multiplier: results[s].TickSize.Float64(),
MaxLeverage: results[s].LotSize.Float64(),
}
}
return resp, nil
Expand Down

0 comments on commit 087b420

Please sign in to comment.