correlation method
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 withbase, 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 beforeto.to- Window end YYYY-MM-DD (UTC). Defaults to today.cancelToken- ACancelTokenthat can be used to cancel the operationheaders- Can be used to add additional headers to the requestextras- Can be used to add flags to the requestvalidateStatus- AValidateStatuscallback that can be used to determine request success based on the HTTP status of the responseonSendProgress- AProgressCallbackthat can be used to get the send progressonReceiveProgress- AProgressCallbackthat 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,
);
}