Files
gocryptotrader/common/key/key.go
Scott 85403fe801 exchange/order/limits: Migrate to new package and integrate with exchanges (#1860)
* move limits, transition to key gen

* rollout NewExchangePairAssetKey everywhere

* test improvements

* self-review fixes

* ok, lets go

* fix merge issue

* slower value func,assertify,drop IsValidPairString

* remove binance reference for backtesting test

* Redundant nil checks removed due to redundancy

* Update order_test.go

* Move limits back into /exchanges/

* puts limits in a different box again

* SHAZBERT SPECIAL SUGGESTIONS

* Update gateio_wrapper.go

* fixes all build issues

* Many niteroos!

* something has gone awry

* bugfix

* gk's everywhere nits

* lint

* extra lint

* re-remove IsValidPairString

* lint fix

* standardise test

* revert some bads

* dupe rm

* another revert 360 mcgee

* un-in-revertify

* Update exchange/order/limits/levels_test.go

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

* fix

* Update exchanges/binance/binance_test.go

HERE'S HOPING GITHUB FORMATS THIS CORRECTLY!

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

* update text

* rn func, same line err gk4202000

---------

Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>
Co-authored-by: Gareth Kirwan <gbjkirwan@gmail.com>
2025-08-26 12:30:21 +10:00

71 lines
2.0 KiB
Go

package key
import (
"github.com/thrasher-corp/gocryptotrader/currency"
"github.com/thrasher-corp/gocryptotrader/exchanges/asset"
)
// ExchangeAssetPair is a unique map key signature for exchange, currency pair and asset
type ExchangeAssetPair struct {
Exchange string
Asset asset.Item
Base *currency.Item
Quote *currency.Item
}
// NewExchangeAssetPair is a helper function to expand a Pair into an ExchangeAssetPair
func NewExchangeAssetPair(exch string, a asset.Item, cp currency.Pair) ExchangeAssetPair {
return ExchangeAssetPair{
Exchange: exch,
Base: cp.Base.Item,
Quote: cp.Quote.Item,
Asset: a,
}
}
// Pair combines the base and quote into a pair
func (k ExchangeAssetPair) Pair() currency.Pair {
return currency.NewPair(k.Base.Currency(), k.Quote.Currency())
}
// MatchesExchangeAsset checks if the key matches the exchange and asset
func (k ExchangeAssetPair) MatchesExchangeAsset(exch string, item asset.Item) bool {
return k.Exchange == exch && k.Asset == item
}
// MatchesPairAsset checks if the key matches the pair and asset
func (k ExchangeAssetPair) MatchesPairAsset(pair currency.Pair, item asset.Item) bool {
return k.Base == pair.Base.Item &&
k.Quote == pair.Quote.Item &&
k.Asset == item
}
// MatchesExchange checks if the exchange matches
func (k ExchangeAssetPair) MatchesExchange(exch string) bool {
return k.Exchange == exch
}
// ExchangeAsset is a unique map key signature for exchange and asset
type ExchangeAsset struct {
Exchange string
Asset asset.Item
}
// PairAsset is a unique map key signature for currency pair and asset
type PairAsset struct {
Base *currency.Item
Quote *currency.Item
Asset asset.Item
}
// Pair combines the base and quote into a pair
func (k PairAsset) Pair() currency.Pair {
return currency.NewPair(k.Base.Currency(), k.Quote.Currency())
}
// SubAccountAsset is a unique map key signature for subaccount and asset
type SubAccountAsset struct {
SubAccount string
Asset asset.Item
}