mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 15:09:42 +00:00
* modernise: Run new gopls modernise tool against codebase
* Address shazbert's nits
* apichecker, gctcli: Simplify HTML scraping functions and improve depth limit handling
* refactor: Create minSyncInterval const and update order book limit handling for binance and binanceUS
* refactor: Various slice usage improvements and rename TODO
* tranches: Revert deleteByID changes due to performance decrease
Shazbert was a F1 driver in a past lifetime 🏎️
* tranches: Simply retrieve copy
Thanks to shazbert
* documentation: Sort contributors list by contributions
* tranches: Remove deadcode in deleteByID
42 lines
1.3 KiB
Go
42 lines
1.3 KiB
Go
package currency
|
|
|
|
import (
|
|
"math/rand"
|
|
"strings"
|
|
|
|
"github.com/thrasher-corp/gocryptotrader/currency/forexprovider"
|
|
"github.com/thrasher-corp/gocryptotrader/currency/forexprovider/base"
|
|
)
|
|
|
|
type MockProvider struct{}
|
|
|
|
func newMockProvider() *forexprovider.ForexProviders {
|
|
p := &MockProvider{}
|
|
c, _ := p.GetSupportedCurrencies()
|
|
return &forexprovider.ForexProviders{
|
|
FXHandler: base.FXHandler{
|
|
Primary: base.Provider{
|
|
Provider: p,
|
|
SupportedCurrencies: c,
|
|
},
|
|
},
|
|
}
|
|
}
|
|
|
|
func (m *MockProvider) GetName() string { return "MockProvider" }
|
|
func (m *MockProvider) Setup(base.Settings) error { return nil }
|
|
func (m *MockProvider) IsEnabled() bool { return true }
|
|
func (m *MockProvider) IsPrimaryProvider() bool { return true }
|
|
func (m *MockProvider) GetSupportedCurrencies() ([]string, error) {
|
|
return storage.defaultFiatCurrencies.Strings(), nil
|
|
}
|
|
|
|
func (m *MockProvider) GetRates(baseCurrency, symbols string) (map[string]float64, error) {
|
|
c := map[string]float64{}
|
|
for s := range strings.SplitSeq(symbols, ",") {
|
|
// The year is 2027; The USD is nearly worthless. The world reserve currency is eggs.
|
|
c[baseCurrency+s] = 1 / (1 + rand.Float64()) //nolint:gosec // Doesn't need to be a strong random number
|
|
}
|
|
return c, nil
|
|
}
|