mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 23:16:45 +00:00
BUGFIX: GateIO candle retrieval, backtester formatting (#715)
* Fixes gateio candle retrieval. Fixes backtester exch & currency lookups * Fixes strat whoopsie * Using a helper function instead * shadowy lint figures defeated * Fixes fodmap typo Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io> Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>
This commit is contained in:
@@ -135,6 +135,15 @@ func NewFromConfig(cfg *config.Config, templatePath, output string, bot *engine.
|
||||
cfg.CurrencySettings[i].Base+cfg.CurrencySettings[i].Quote,
|
||||
err)
|
||||
}
|
||||
exch := bot.ExchangeManager.GetExchangeByName(cfg.CurrencySettings[i].ExchangeName)
|
||||
b := exch.GetBase()
|
||||
var pFmt currency.PairFormat
|
||||
pFmt, err = b.GetPairFormat(a, true)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not format currency %v, %w", curr, err)
|
||||
}
|
||||
curr = curr.Format(pFmt.Delimiter, pFmt.Uppercase)
|
||||
|
||||
portfolioRisk.CurrencySettings[cfg.CurrencySettings[i].ExchangeName][a][curr] = &risk.CurrencySettings{
|
||||
MaximumOrdersWithLeverageRatio: cfg.CurrencySettings[i].Leverage.MaximumOrdersWithLeverageRatio,
|
||||
MaxLeverageRate: cfg.CurrencySettings[i].Leverage.MaximumLeverageRate,
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"strings"
|
||||
|
||||
gctcommon "github.com/thrasher-corp/gocryptotrader/common"
|
||||
"github.com/thrasher-corp/gocryptotrader/common/file"
|
||||
@@ -179,6 +180,7 @@ func (c *Config) ValidateCurrencySettings() error {
|
||||
c.CurrencySettings[i].MinimumSlippagePercent > c.CurrencySettings[i].MaximumSlippagePercent {
|
||||
return ErrBadSlippageRates
|
||||
}
|
||||
c.CurrencySettings[i].ExchangeName = strings.ToLower(c.CurrencySettings[i].ExchangeName)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -265,7 +265,7 @@ func (e *Exchange) SetExchangeAssetCurrencySettings(exch string, a asset.Item, c
|
||||
// GetCurrencySettings returns the settings for an exchange, asset currency
|
||||
func (e *Exchange) GetCurrencySettings(exch string, a asset.Item, cp currency.Pair) (Settings, error) {
|
||||
for i := range e.CurrencySettings {
|
||||
if e.CurrencySettings[i].CurrencyPair == cp {
|
||||
if e.CurrencySettings[i].CurrencyPair.Equal(cp) {
|
||||
if e.CurrencySettings[i].AssetType == a {
|
||||
if exch == e.CurrencySettings[i].ExchangeName {
|
||||
return e.CurrencySettings[i], nil
|
||||
|
||||
@@ -826,7 +826,7 @@ func (g *Gateio) GetHistoricCandles(pair currency.Pair, a asset.Item, start, end
|
||||
return kline.Item{}, err
|
||||
}
|
||||
|
||||
hours := end.Sub(start).Hours()
|
||||
hours := time.Since(start).Hours()
|
||||
formattedPair, err := g.FormatExchangeCurrency(pair, a)
|
||||
if err != nil {
|
||||
return kline.Item{}, err
|
||||
@@ -847,6 +847,7 @@ func (g *Gateio) GetHistoricCandles(pair currency.Pair, a asset.Item, start, end
|
||||
klineData.Asset = a
|
||||
|
||||
klineData.SortCandlesByTimestamp(false)
|
||||
klineData.RemoveOutsideRange(start, end)
|
||||
return klineData, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user