GetKlineExtendedRequest returns a helper for the fetching of candle/kline data for a *multi* request within a pre-determined time window. This has extended functionality to also break down calls to fetch total history.
(pair currency.Pair, a asset.Item, interval kline.Interval, start, end time.Time)
| 1571 | // data for a *multi* request within a pre-determined time window. This has |
| 1572 | // extended functionality to also break down calls to fetch total history. |
| 1573 | func (b *Base) GetKlineExtendedRequest(pair currency.Pair, a asset.Item, interval kline.Interval, start, end time.Time) (*kline.ExtendedRequest, error) { |
| 1574 | if pair.IsEmpty() { |
| 1575 | return nil, currency.ErrCurrencyPairEmpty |
| 1576 | } |
| 1577 | if !a.IsValid() { |
| 1578 | return nil, asset.ErrNotSupported |
| 1579 | } |
| 1580 | |
| 1581 | exchangeInterval, err := b.Features.Enabled.Kline.Intervals.Construct(interval) |
| 1582 | if err != nil { |
| 1583 | return nil, err |
| 1584 | } |
| 1585 | |
| 1586 | err = b.verifyKlineParameters(pair, a, exchangeInterval) |
| 1587 | if err != nil { |
| 1588 | return nil, err |
| 1589 | } |
| 1590 | |
| 1591 | formatted, err := b.FormatExchangeCurrency(pair, a) |
| 1592 | if err != nil { |
| 1593 | return nil, err |
| 1594 | } |
| 1595 | |
| 1596 | limit, err := b.Features.Enabled.Kline.GetIntervalResultLimit(exchangeInterval) |
| 1597 | if err != nil { |
| 1598 | return nil, err |
| 1599 | } |
| 1600 | |
| 1601 | r, err := kline.CreateKlineRequest(b.Name, pair, formatted, a, interval, exchangeInterval, start, end, limit) |
| 1602 | if err != nil { |
| 1603 | return nil, err |
| 1604 | } |
| 1605 | r.IsExtended = true |
| 1606 | |
| 1607 | dates, err := r.GetRanges(limit) |
| 1608 | if err != nil { |
| 1609 | return nil, err |
| 1610 | } |
| 1611 | |
| 1612 | return &kline.ExtendedRequest{Request: r, RangeHolder: dates}, nil |
| 1613 | } |
| 1614 | |
| 1615 | // Shutdown closes active websocket connections if available and then cleans up |
| 1616 | // a REST requester instance. |