correlation method

Future<Response<CorrelationResponse>> correlation({
  1. required String currencies,
  2. String? base_,
  3. String? from,
  4. String? to,
  5. CancelToken? cancelToken,
  6. Map<String, dynamic>? headers,
  7. Map<String, dynamic>? extra,
  8. ValidateStatus? validateStatus,
  9. ProgressCallback? onSendProgress,
  10. ProgressCallback? onReceiveProgress,
})

Correlation Correlation of each currency's daily returns with a base currency's, over a window. Growth plan or higher.

Parameters:

  • currencies - Comma-separated currencies to correlate with base, e.g. GBP,CHF,SEK.
  • base_ - Reference currency to correlate against (3-letter ISO 4217). Defaults to USD (a non-USD base is more meaningful).
  • from - Window start YYYY-MM-DD (UTC). Defaults to 365 days before to.
  • to - Window end YYYY-MM-DD (UTC). Defaults to today.
  • cancelToken - A CancelToken that can be used to cancel the operation
  • headers - Can be used to add additional headers to the request
  • extras - Can be used to add flags to the request
  • validateStatus - A ValidateStatus callback that can be used to determine request success based on the HTTP status of the response
  • onSendProgress - A ProgressCallback that can be used to get the send progress
  • onReceiveProgress - A ProgressCallback that can be used to get the receive progress

Returns a Future containing a Response with a CorrelationResponse as data Throws DioException if API call or serialization fails

Implementation

Future<Response<CorrelationResponse>> correlation({
  required String currencies,
  String? base_,
  String? from,
  String? to,
  CancelToken? cancelToken,
  Map<String, dynamic>? headers,
  Map<String, dynamic>? extra,
  ValidateStatus? validateStatus,
  ProgressCallback? onSendProgress,
  ProgressCallback? onReceiveProgress,
}) async {
  final _path = r'/correlation';
  final _options = Options(
    method: r'GET',
    headers: <String, dynamic>{
      ...?headers,
    },
    extra: <String, dynamic>{
      'secure': <Map<String, String>>[
        {
          'type': 'http',
          'scheme': 'bearer',
          'name': 'bearerAuth',
        },
      ],
      ...?extra,
    },
    validateStatus: validateStatus,
  );

  final _queryParameters = <String, dynamic>{
    if (base_ != null) r'base': encodeQueryParameter(_serializers, base_, const FullType(String)),
    r'currencies': encodeQueryParameter(_serializers, currencies, const FullType(String)),
    if (from != null) r'from': encodeQueryParameter(_serializers, from, const FullType(String)),
    if (to != null) r'to': encodeQueryParameter(_serializers, to, const FullType(String)),
  };

  final _response = await _dio.request<Object>(
    _path,
    options: _options,
    queryParameters: _queryParameters,
    cancelToken: cancelToken,
    onSendProgress: onSendProgress,
    onReceiveProgress: onReceiveProgress,
  );

  CorrelationResponse? _responseData;

  try {
    final rawResponse = _response.data;
    _responseData = rawResponse == null ? null : _serializers.deserialize(
      rawResponse,
      specifiedType: const FullType(CorrelationResponse),
    ) as CorrelationResponse;

  } catch (error, stackTrace) {
    throw DioException(
      requestOptions: _response.requestOptions,
      response: _response,
      type: DioExceptionType.unknown,
      error: error,
      stackTrace: stackTrace,
    );
  }

  return Response<CorrelationResponse>(
    data: _responseData,
    headers: _response.headers,
    isRedirect: _response.isRedirect,
    requestOptions: _response.requestOptions,
    redirects: _response.redirects,
    statusCode: _response.statusCode,
    statusMessage: _response.statusMessage,
    extra: _response.extra,
  );
}