exchanges: Use singular futures settlement currency (#2092)

* Change settlement to singular currency

* whoops.go

* bitmex fix

* minor updates

* 64 divided by 2

* whoops2.go

* ROBOT ROCK

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* ROCK ROCK ROCK ROCK ROBOT

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* shazNit

* currencies unmarshal and code use

* Update currency/currencies.go

Co-authored-by: Gareth Kirwan <gbjkirwan@gmail.com>

* Update exchanges/btse/btse_wrapper.go

Co-authored-by: Gareth Kirwan <gbjkirwan@gmail.com>

* reuse comment for better clarity

* collapses entire thing

* shazLint

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Gareth Kirwan <gbjkirwan@gmail.com>
This commit is contained in:
Scott
2025-11-10 13:21:54 +11:00
committed by GitHub
parent 9441f33f42
commit 61d720b72f
19 changed files with 399 additions and 471 deletions

View File

@@ -533,10 +533,9 @@ func (e *Exchange) GetHistoricTrades(ctx context.Context, p currency.Pair, asset
if err != nil {
return nil, err
}
limit := 1000
req := &GenericRequestParams{
Symbol: p.String(),
Count: int32(limit),
Count: countLimit,
EndTime: timestampEnd.UTC().Format("2006-01-02T15:04:05.000Z"),
}
ts := timestampStart
@@ -581,7 +580,7 @@ allTrades:
ts = tradeData[i].Timestamp
}
}
if len(tradeData) != limit {
if len(tradeData) != int(countLimit) {
break allTrades
}
}
@@ -984,25 +983,18 @@ func (e *Exchange) GetFuturesContractDetails(ctx context.Context, item asset.Ite
if !e.SupportsAsset(item) || item == asset.Index {
return nil, fmt.Errorf("%w %v", asset.ErrNotSupported, item)
}
marketInfo, err := e.GetInstruments(ctx, &GenericRequestParams{Reverse: true, Count: 500})
if err != nil {
return nil, err
}
resp := make([]futures.Contract, 0, len(marketInfo))
var resp []futures.Contract
switch item {
case asset.PerpetualContract:
marketInfo, err := e.GetInstruments(ctx, &GenericRequestParams{
Count: countLimit,
Filter: `{"typ": "` + perpetualContractID + `"}`,
})
if err != nil {
return nil, err
}
for x := range marketInfo {
if marketInfo[x].Typ != perpetualContractID {
continue
}
var cp, underlying currency.Pair
cp, err = currency.NewPairFromStrings(marketInfo[x].RootSymbol, marketInfo[x].QuoteCurrency)
if err != nil {
return nil, err
}
underlying, err = currency.NewPairFromStrings(marketInfo[x].RootSymbol, marketInfo[x].SettlCurrency)
cp, err := currency.NewPairFromStrings(marketInfo[x].RootSymbol, marketInfo[x].QuoteCurrency)
if err != nil {
return nil, err
}
@@ -1023,17 +1015,17 @@ func (e *Exchange) GetFuturesContractDetails(ctx context.Context, item asset.Ite
contractSettlementType = futures.Inverse
}
resp = append(resp, futures.Contract{
Exchange: e.Name,
Name: cp,
Underlying: underlying,
Asset: item,
StartDate: s,
IsActive: marketInfo[x].State == "Open",
Status: marketInfo[x].State,
Type: futures.Perpetual,
SettlementType: contractSettlementType,
SettlementCurrencies: currency.Currencies{currency.NewCode(marketInfo[x].SettlCurrency)},
Multiplier: marketInfo[x].Multiplier,
Exchange: e.Name,
Name: cp,
Underlying: currency.NewPair(cp.Base, marketInfo[x].SettlementCurrency),
Asset: item,
StartDate: s,
IsActive: marketInfo[x].State == "Open",
Status: marketInfo[x].State,
Type: futures.Perpetual,
SettlementType: contractSettlementType,
SettlementCurrency: marketInfo[x].SettlementCurrency,
Multiplier: marketInfo[x].Multiplier,
LatestRate: fundingrate.Rate{
Time: marketInfo[x].FundingTimestamp,
Rate: decimal.NewFromFloat(marketInfo[x].FundingRate),
@@ -1041,16 +1033,16 @@ func (e *Exchange) GetFuturesContractDetails(ctx context.Context, item asset.Ite
})
}
case asset.Futures:
marketInfo, err := e.GetInstruments(ctx, &GenericRequestParams{
Count: countLimit,
Filter: `{"typ": "` + futuresID + `"}`,
})
if err != nil {
return nil, err
}
for x := range marketInfo {
if marketInfo[x].Typ != futuresID {
continue
}
var cp, underlying currency.Pair
cp, err = currency.NewPairFromStrings(marketInfo[x].RootSymbol, marketInfo[x].Symbol[len(marketInfo[x].RootSymbol):])
if err != nil {
return nil, err
}
underlying, err = currency.NewPairFromStrings(marketInfo[x].RootSymbol, marketInfo[x].SettlCurrency)
cp, err := currency.NewPairFromStrings(marketInfo[x].RootSymbol, marketInfo[x].Symbol[len(marketInfo[x].RootSymbol):])
if err != nil {
return nil, err
}
@@ -1093,18 +1085,18 @@ func (e *Exchange) GetFuturesContractDetails(ctx context.Context, item asset.Ite
contractSettlementType = futures.Quanto
}
resp = append(resp, futures.Contract{
Exchange: e.Name,
Name: cp,
Underlying: underlying,
Asset: item,
StartDate: startTime,
EndDate: endTime,
IsActive: marketInfo[x].State == "Open",
Status: marketInfo[x].State,
Type: ct,
SettlementCurrencies: currency.Currencies{currency.NewCode(marketInfo[x].SettlCurrency)},
Multiplier: marketInfo[x].Multiplier,
SettlementType: contractSettlementType,
Exchange: e.Name,
Name: cp,
Underlying: currency.NewPair(cp.Base, marketInfo[x].SettlementCurrency),
Asset: item,
StartDate: startTime,
EndDate: endTime,
IsActive: marketInfo[x].State == "Open",
Status: marketInfo[x].State,
Type: ct,
SettlementCurrency: marketInfo[x].SettlementCurrency,
Multiplier: marketInfo[x].Multiplier,
SettlementType: contractSettlementType,
})
}
}