kline/exchanges: automatic creation of unsupported candle intervals (#1091)

* kline: Add builder and testing

* Ideas

* kline: deploy builder functionality across GCT

* exchanges: implement across gct

* exchanges: Add tests and fix implementations before kline package testing and veri.

* kline: Add tests and start to fix ConvertToNewInterval

* kline: fix ConvertToNewInterval add tests

* kline: complete overarching tests now on to exchanges

* kline: finish exchange tests and implement limits

* exchanges: more fixes

* linter: fix

* engine: fix tests

* kraken: fix recent trades and other fixes

* zb: fix tests

* bithumb: fix empty insertion

* kline: refactor/optimize CreateKline function

* kline: remove the mooos!

* kline: prealloc CalculateCandleDateRanges

* linter: fix

* exchanges: prealloc extended

* fix whoopsie

* reverse fix because this is a whoopsie

* okx: fix risidual issues

* linter: fix

* kline: initial nits from @gloriouscode

* kline: rename builder -> request and cascade change

* linter: fix + test

* kline: update forced alignment on start and end times when CreateKlineRequest is called.

* nits: more more more

* NITS: Addressed

* tests: fix race issue

* Update exchanges/kline/request.go

Co-authored-by: Scott <gloriousCode@users.noreply.github.com>

* kline: add method AddPadding() to automatically fill in holes in kline.Request functionality and reject if missing data when converting

* kline: Add params start and end to addPadding() to insert blanks in between block

* kline: remove test comment code as it's not needed anymore

* kline: fix lint and test

* kline: sort slice without extra bool check every iteration

* okx: fix issues with timeing and candles and such from niterinos & address typo

* Update exchanges/kline/kline.go

Co-authored-by: Scott <gloriousCode@users.noreply.github.com>

* glorious: niterinos

* Update exchanges/poloniex/poloniex_wrapper.go

Co-authored-by: Scott <gloriousCode@users.noreply.github.com>

* glorious: nits now onto conflicts YAYA!!!

* Update exchanges/exchange_test.go

Co-authored-by: Scott <gloriousCode@users.noreply.github.com>

* glorious: nits again

* thrasher: nitters

* thrasher: niterinos - adds partial flag for incomplete recent candles and fetching.

* kline: rm fmtizzle packageizzle

* glorious: nitters

* glorious: more niterinos

* fix last niterinos

Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
Co-authored-by: Scott <gloriousCode@users.noreply.github.com>
This commit is contained in:
Ryan O'Hara-Reid
2023-01-17 16:22:33 +11:00
committed by GitHub
parent 72f36d70d1
commit 83cfefa45c
110 changed files with 11312 additions and 5768 deletions

View File

@@ -39,7 +39,7 @@ type GCTExchange interface {
DepositAddress(exch, chain string, currencyCode currency.Code) (*deposit.Address, error)
WithdrawalFiatFunds(ctx context.Context, bankAccountID string, request *withdraw.Request) (out string, err error)
WithdrawalCryptoFunds(ctx context.Context, request *withdraw.Request) (out string, err error)
OHLCV(ctx context.Context, exch string, pair currency.Pair, item asset.Item, start, end time.Time, interval kline.Interval) (kline.Item, error)
OHLCV(ctx context.Context, exch string, pair currency.Pair, item asset.Item, start, end time.Time, interval kline.Interval) (*kline.Item, error)
}
// SetModuleWrapper link the wrapper and interface to use for modules

View File

@@ -216,14 +216,14 @@ func (e Exchange) WithdrawalCryptoFunds(ctx context.Context, request *withdraw.R
}
// OHLCV returns open high low close volume candles for requested exchange/pair/asset/start & end time
func (e Exchange) OHLCV(ctx context.Context, exch string, pair currency.Pair, item asset.Item, start, end time.Time, interval kline.Interval) (kline.Item, error) {
func (e Exchange) OHLCV(ctx context.Context, exch string, pair currency.Pair, item asset.Item, start, end time.Time, interval kline.Interval) (*kline.Item, error) {
ex, err := e.GetExchange(exch)
if err != nil {
return kline.Item{}, err
return nil, err
}
ret, err := ex.GetHistoricCandlesExtended(ctx, pair, item, start, end, interval)
ret, err := ex.GetHistoricCandlesExtended(ctx, pair, item, interval, start, end)
if err != nil {
return kline.Item{}, err
return nil, err
}
sort.Slice(ret.Candles, func(i, j int) bool {
@@ -231,6 +231,5 @@ func (e Exchange) OHLCV(ctx context.Context, exch string, pair currency.Pair, it
})
ret.FormatDates()
return ret, nil
}

View File

@@ -247,9 +247,9 @@ func (w Wrapper) WithdrawalFiatFunds(ctx context.Context, _ string, r *withdraw.
}
// OHLCV returns open high low close volume candles for requested exchange/pair/asset/start & end time
func (w Wrapper) OHLCV(ctx context.Context, exch string, p currency.Pair, a asset.Item, start, end time.Time, i kline.Interval) (kline.Item, error) {
func (w Wrapper) OHLCV(ctx context.Context, exch string, p currency.Pair, a asset.Item, start, end time.Time, i kline.Interval) (*kline.Item, error) {
if exch == exchError.String() {
return kline.Item{}, errTestFailed
return nil, errTestFailed
}
var candles []kline.Candle
@@ -275,7 +275,7 @@ func (w Wrapper) OHLCV(ctx context.Context, exch string, p currency.Pair, a asse
candles = append(candles, candle)
}
return kline.Item{
return &kline.Item{
Exchange: exch,
Pair: p,
Asset: a,