mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 23:16:45 +00:00
* Currency: Remove Pair Index formatting/parsing This feature was originally for exchanges with only one pair (e.g. KRW) which made parsing easier. However there's no examples of this left, and we can reduce complexity overall by removing it. * Exchange: Partial assertify tests and fixes * Currency: Fix panic on a delimiterless small currency
46 lines
1.4 KiB
Go
46 lines
1.4 KiB
Go
package currency
|
|
|
|
import (
|
|
"sync"
|
|
|
|
"github.com/thrasher-corp/gocryptotrader/exchanges/asset"
|
|
)
|
|
|
|
// PairsManager manages asset pairs
|
|
type PairsManager struct {
|
|
BypassConfigFormatUpgrades bool `json:"bypassConfigFormatUpgrades"`
|
|
RequestFormat *PairFormat `json:"requestFormat,omitempty"`
|
|
ConfigFormat *PairFormat `json:"configFormat,omitempty"`
|
|
UseGlobalFormat bool `json:"useGlobalFormat,omitempty"`
|
|
LastUpdated int64 `json:"lastUpdated,omitempty"`
|
|
Pairs FullStore `json:"pairs"`
|
|
matcher map[key]*Pair
|
|
mutex sync.RWMutex
|
|
}
|
|
|
|
// FullStore holds all supported asset types with the enabled and available
|
|
// pairs for an exchange.
|
|
type FullStore map[asset.Item]*PairStore
|
|
|
|
// PairStore stores a currency pair store
|
|
type PairStore struct {
|
|
AssetEnabled *bool `json:"assetEnabled"`
|
|
Enabled Pairs `json:"enabled"`
|
|
Available Pairs `json:"available"`
|
|
RequestFormat *PairFormat `json:"requestFormat,omitempty"`
|
|
ConfigFormat *PairFormat `json:"configFormat,omitempty"`
|
|
}
|
|
|
|
// PairFormat returns the pair format
|
|
type PairFormat struct {
|
|
Uppercase bool `json:"uppercase"`
|
|
Delimiter string `json:"delimiter,omitempty"`
|
|
Separator string `json:"separator,omitempty"`
|
|
}
|
|
|
|
// key is used to store the asset type and symbol in a map
|
|
type key struct {
|
|
Symbol string
|
|
Asset asset.Item
|
|
}
|