mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 23:16:45 +00:00
engine/exchanges: Add GetCurrencyTradeURL wrapper func/gRPC endpoint (#1521)
* beginning the concept * expands testing and implementations * test standardisation, expansion * more * finish remainder, add rpc func * lint * grammar? I barely know her! * wow i forgot something wow wow wow wow * rm SendPayload * enFixio! * improve binance long-dated support * update test design, update wrapper funcs * adds kraken futures, adds bybit support * fixes SIMPLE bugs * s is for sucks * fixed option url x2 * fixed silly test
This commit is contained in:
@@ -6016,3 +6016,36 @@ func (s *RPCServer) GetOpenInterest(ctx context.Context, r *gctrpc.GetOpenIntere
|
||||
Data: resp,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// GetCurrencyTradeURL returns the URL for the trading pair
|
||||
func (s *RPCServer) GetCurrencyTradeURL(ctx context.Context, r *gctrpc.GetCurrencyTradeURLRequest) (*gctrpc.GetCurrencyTradeURLResponse, error) {
|
||||
if r == nil {
|
||||
return nil, fmt.Errorf("%w GetCurrencyTradeURLRequest", common.ErrNilPointer)
|
||||
}
|
||||
exch, err := s.GetExchangeByName(r.Exchange)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !exch.IsEnabled() {
|
||||
return nil, fmt.Errorf("%s %w", r.Exchange, errExchangeNotEnabled)
|
||||
}
|
||||
ai, err := asset.New(r.Asset)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if r.Pair == nil ||
|
||||
(r.Pair.Base == "" && r.Pair.Quote == "") {
|
||||
return nil, currency.ErrCurrencyPairEmpty
|
||||
}
|
||||
cp, err := exch.MatchSymbolWithAvailablePairs(r.Pair.Base+r.Pair.Quote, ai, false)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
url, err := exch.GetCurrencyTradeURL(ctx, ai, cp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &gctrpc.GetCurrencyTradeURLResponse{
|
||||
Url: url,
|
||||
}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user