mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-30 07:26:46 +00:00
Add OHLC retrieval func (GetHistoricCandles) to all exchanges and expose it as a wrapper func (#414)
* initial wiring to providegethistoricalcandles * initial wiring to providegethistoricalcandles * initial wiring to providegethistoricalcandles * gethistriccandles work from cli using hard coded inputs * gethistoriccandles RPC service and CLI working fine for coinbasepro * fixed unit test * input check on grpc for gethistoriccandles * updated deps * fixed the return value when a method is not yet implemented * code review: fixed CLI input check and int32->int64 * code review: handling wrong exchange name * added check on granularity and allowing start and end being empty * code review: removed currency2 * code review: dependency reverted * improved func comment * typo in func comment * get historic values tests * unit tests for get historical rates on coinbasepro * using time format time.RFC3339 * names to camel case and improved comments * test cleanup * changed to camel case * added InArray tests * dropped not needed string time * enforced use of int64 * fixed make check * cleaned up code organisation to be consistent * fixed Travis remarks * more Travis remarks * added comments * regenerated proto files after merge * linter fix
This commit is contained in:
committed by
Adrian Gallagher
parent
e5b64a5580
commit
5ac5ec8fc1
@@ -1221,6 +1221,44 @@ func (s *RPCServer) GetAuditEvent(ctx context.Context, r *gctrpc.GetAuditEventRe
|
||||
return &resp, nil
|
||||
}
|
||||
|
||||
// GetHistoricCandles returns historical candles for a given exchange
|
||||
func (s *RPCServer) GetHistoricCandles(ctx context.Context, req *gctrpc.GetHistoricCandlesRequest) (*gctrpc.GetHistoricCandlesResponse, error) {
|
||||
if req.Exchange == "" {
|
||||
return nil, errors.New(errExchangeNameUnset)
|
||||
}
|
||||
|
||||
if req.Pair.String() == "" {
|
||||
return nil, errors.New(errCurrencyPairUnset)
|
||||
}
|
||||
|
||||
exchange := GetExchangeByName(req.Exchange)
|
||||
if exchange == nil {
|
||||
return nil, errors.New("Exchange " + req.Exchange + " not found")
|
||||
}
|
||||
|
||||
candles, err := exchange.GetHistoricCandles(currency.Pair{
|
||||
Delimiter: req.Pair.Delimiter,
|
||||
Base: currency.NewCode(req.Pair.Base),
|
||||
Quote: currency.NewCode(req.Pair.Quote),
|
||||
}, req.Rangesize, req.Granularity)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp := gctrpc.GetHistoricCandlesResponse{}
|
||||
for _, candle := range candles {
|
||||
tempCandle := &gctrpc.Candle{
|
||||
Time: candle.Time,
|
||||
Low: candle.Low,
|
||||
High: candle.High,
|
||||
Open: candle.Open,
|
||||
Close: candle.Close,
|
||||
Volume: candle.Volume,
|
||||
}
|
||||
resp.Candle = append(resp.Candle, tempCandle)
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
||||
// GCTScriptStatus returns a slice of current running scripts that includes next run time and uuid
|
||||
func (s *RPCServer) GCTScriptStatus(ctx context.Context, r *gctrpc.GCTScriptStatusRequest) (*gctrpc.GCTScriptStatusResponse, error) {
|
||||
if !gctscript.GCTScriptConfig.Enabled {
|
||||
|
||||
Reference in New Issue
Block a user