meanReversion method

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

Mean reversion Ranks currencies by how strongly they revert to their mean (crossing frequency + reversion half-life). Growth plan or higher.

Parameters:

  • currencies - Comma-separated currencies to score, e.g. EUR,GBP. OMIT to rank the liquid set.
  • base_ - Base currency to measure against (3-letter ISO 4217). Defaults to USD.
  • from - Window start YYYY-MM-DD (UTC). Defaults to ~2 years before to.
  • to - Window end YYYY-MM-DD (UTC). Defaults to today.
  • limit - How many to return (default 10, max 50).
  • 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 MeanReversionResponse as data Throws DioException if API call or serialization fails

Implementation

Future<Response<MeanReversionResponse>> meanReversion({
  String? currencies,
  String? base_,
  String? from,
  String? to,
  num? limit,
  CancelToken? cancelToken,
  Map<String, dynamic>? headers,
  Map<String, dynamic>? extra,
  ValidateStatus? validateStatus,
  ProgressCallback? onSendProgress,
  ProgressCallback? onReceiveProgress,
}) async {
  final _path = r'/mean-reversion';
  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 (currencies != null) r'currencies': encodeQueryParameter(_serializers, currencies, const FullType(String)),
    if (base_ != null) r'base': encodeQueryParameter(_serializers, base_, 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)),
    if (limit != null) r'limit': encodeQueryParameter(_serializers, limit, const FullType(num)),
  };

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

  MeanReversionResponse? _responseData;

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

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

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