twelve_data_client/apis/market_data_api.rs
1/*
2 * Twelve Data API
3 *
4 * ## Overview Welcome to Twelve Data developer docs — your gateway to comprehensive financial market data through a powerful and easy-to-use API. Twelve Data provides access to financial markets across over 50 global countries, covering more than 1 million public instruments, including stocks, forex, ETFs, mutual funds, commodities, and cryptocurrencies. ## Quickstart To get started, you'll need to sign up for an API key. Once you have your API key, you can start making requests to the API. ### Step 1: Create Twelve Data account Sign up on the Twelve Data website to create your account [here](https://twelvedata.com/register). This gives you access to the API dashboard and your API key. ### Step 2: Get your API key After signing in, navigate to your [dashboard](https://twelvedata.com/account/api-keys) to find your unique API key. This key is required to authenticate all API and WebSocket requests. ### Step 3: Make your first request Try a simple API call with cURL to fetch the latest price for Apple (AAPL): ``` curl \"https://api.twelvedata.com/price?symbol=AAPL&apikey=your_api_key\" ``` ### Step 4: Make a request from Python or Javascript Use our client libraries or standard HTTP clients to make API calls programmatically. Here’s an example in [Python](https://github.com/twelvedata/twelvedata-python) and JavaScript: #### Python (using official Twelve Data SDK): ```python from twelvedata import TDClient # Initialize client with your API key td = TDClient(apikey=\"your_api_key\") # Get latest price for Apple price = td.price(symbol=\"AAPL\").as_json() print(price) ``` #### JavaScript (Node.js): ```javascript const fetch = require('node-fetch'); fetch('https://api.twelvedata.com/price?symbol=AAPL&apikey=your_api_key') .then(response => response.json()) .then(data => console.log(data)); ``` ### Step 5: Perform correlation analysis between Tesla and Microsoft prices Fetch historical price data for Tesla (TSLA) and Microsoft (MSFT) and calculate the correlation of their closing prices: ```python from twelvedata import TDClient import pandas as pd # Initialize client with your API key td = TDClient(apikey=\"your_api_key\") # Fetch historical price data for Tesla tsla_ts = td.time_series( symbol=\"TSLA\", interval=\"1day\", outputsize=100 ).as_pandas() # Fetch historical price data for Microsoft msft_ts = td.time_series( symbol=\"MSFT\", interval=\"1day\", outputsize=100 ).as_pandas() # Align data on datetime index combined = pd.concat( [tsla_ts['close'].astype(float), msft_ts['close'].astype(float)], axis=1, keys=[\"TSLA\", \"MSFT\"] ).dropna() # Calculate correlation correlation = combined[\"TSLA\"].corr(combined[\"MSFT\"]) print(f\"Correlation of closing prices between TSLA and MSFT: {correlation:.2f}\") ``` ### Authentication Authenticate your requests using one of these methods: #### Query parameter method ``` GET https://api.twelvedata.com/endpoint?symbol=AAPL&apikey=your_api_key ``` #### HTTP header method (recommended) ``` Authorization: apikey your_api_key ``` ##### API key useful information <ul> <li> Demo API key (<code>apikey=demo</code>) available for demo requests</li> <li> Personal API key required for full access</li> <li> Premium endpoints and data require higher-tier plans (testable with <a href=\"https://twelvedata.com/exchanges\">trial symbols</a>)</li> </ul> ### API endpoints Service | Base URL | ---------|----------| REST API | `https://api.twelvedata.com` | WebSocket | `wss://ws.twelvedata.com` | ### Parameter guidelines <ul> <li><b>Separator:</b> Use <code>&</code> to separate multiple parameters</li> <li><b>Case sensitivity:</b> Parameter names are case-insensitive</li> <ul><li><code>symbol=AAPL</code> = <code>symbol=aapl</code></li></ul> <li><b>Multiple values:</b> Separate with commas where supported</li> </ul> ### Response handling #### Default format All responses return JSON format by default unless otherwise specified. #### Null values <b>Important:</b> Some response fields may contain `null` values when data is unavailable for specific metrics. This is expected behavior, not an error. ##### Best Practices: <ul> <li>Always implement <code>null</code> value handling in your application</li> <li>Use defensive programming techniques for data processing</li> <li>Consider fallback values or error handling for critical metrics</li> </ul> #### Error handling Structure your code to gracefully handle: <ul> <li>Network timeouts</li> <li>Rate limiting responses</li> <li>Invalid parameter errors</li> <li>Data unavailability periods</li> </ul> ##### Best practices <ul> <li><b>Rate limits:</b> Adhere to your plan’s rate limits to avoid throttling. Check your dashboard for details.</li> <li><b>Error handling:</b> Implement retry logic for transient errors (e.g., <code>429 Too Many Requests</code>).</li> <li><b>Caching:</b> Cache responses for frequently accessed data to reduce API calls and improve performance.</li> <li><b>Secure storage:</b> Store your API key securely and never expose it in client-side code or public repositories.</li> </ul> ## Errors Twelve Data API employs a standardized error response format, delivering a JSON object with `code`, `message`, and `status` keys for clear and consistent error communication. ### Codes Below is a table of possible error codes, their HTTP status, meanings, and resolution steps: Code | status | Meaning | Resolution | --- | --- | --- | --- | **400** | Bad Request | Invalid or incorrect parameter(s) provided. | Check the `message` in the response for details. Refer to the API Documentation to correct the input. | **401** | Unauthorized | Invalid or incorrect API key. | Verify your API key is correct. Sign up for a key <a href=\"https://twelvedata.com/account/api-keys\">here</a>. | **403** | Forbidden | API key lacks permissions for the requested resource (upgrade required). | Upgrade your plan <a href=\"https://twelvedata.com/pricing\">here</a>. | **404** | Not Found | Requested data could not be found. | Adjust parameters to be less strict as they may be too restrictive. | **414** | Parameter Too Long | Input parameter array exceeds the allowed length. | Follow the `message` guidance to adjust the parameter length. | **429** | Too Many Requests | API request limit reached for your key. | Wait briefly or upgrade your plan <a href=\"https://twelvedata.com/pricing\">here</a>. | **500** | Internal Server Error | Server-side issue occurred; retry later. | Contact support <a href=\"https://twelvedata.com/contact\">here</a> for assistance. | ### Example error response Consider the following invalid request: ``` https://api.twelvedata.com/time_series?symbol=AAPL&interval=0.99min&apikey=your_api_key ``` Due to the incorrect `interval` value, the API returns: ```json { \"code\": 400, \"message\": \"Invalid **interval** provided: 0.99min. Supported intervals: 1min, 5min, 15min, 30min, 45min, 1h, 2h, 4h, 8h, 1day, 1week, 1month\", \"status\": \"error\" } ``` Refer to the API Documentation for valid parameter values to resolve such errors. ## Libraries Twelve Data provides a growing ecosystem of libraries and integrations to help you build faster and smarter in your preferred environment. Official libraries are actively maintained by the Twelve Data team, while selected community-built libraries offer additional flexibility. A full list is available on our [GitHub profile](https://github.com/search?q=twelvedata). ### Official SDKs <ul> <li><b>Python:</b> <a href=\"https://github.com/twelvedata/twelvedata-python\">twelvedata-python</a></li> <li><b>R:</b> <a href=\"https://github.com/twelvedata/twelvedata-r-sdk\">twelvedata-r-sdk</a></li> </ul> ### AI integrations <ul> <li><b>Twelve Data MCP Server:</b> <a href=\"https://github.com/twelvedata/mcp\">Repository</a> — Model Context Protocol (MCP) server that provides seamless integration with AI assistants and language models, enabling direct access to Twelve Data's financial market data within conversational interfaces and AI workflows.</li> </ul> ### Spreadsheet add-ons <ul> <li><b>Excel:</b> <a href=\"https://twelvedata.com/excel\">Excel Add-in</a></li> <li><b>Google Sheets:</b> <a href=\"https://twelvedata.com/google-sheets\">Google Sheets Add-on</a></li> </ul> ### Community libraries The community has developed libraries in several popular languages. You can explore more community libraries on [GitHub](https://github.com/search?q=twelvedata). <ul> <li><b>C#:</b> <a href=\"https://github.com/pseudomarkets/TwelveDataSharp\">TwelveDataSharp</a></li> <li><b>JavaScript:</b> <a href=\"https://github.com/evzaboun/twelvedata\">twelvedata</a></li> <li><b>PHP:</b> <a href=\"https://github.com/ingelby/twelvedata\">twelvedata</a></li> <li><b>Go:</b> <a href=\"https://github.com/soulgarden/twelvedata\">twelvedata</a></li> <li><b>TypeScript:</b> <a href=\"https://github.com/Clyde-Goodall/twelve-data-wrapper\">twelve-data-wrapper</a></li> </ul> ### Other Twelve Data repositories <ul> <li><b>searchindex</b> <i>(Go)</i>: <a href=\"https://github.com/twelvedata/searchindex\">Repository</a> — In-memory search index by strings</li> <li><b>ws-tools</b> <i>(Python)</i>: <a href=\"https://github.com/twelvedata/ws-tools\">Repository</a> — Utility tools for WebSocket stream handling</li> </ul> ### API specification <ul> <li><b>OpenAPI / Swagger:</b> Access the <a href=\"https://api.twelvedata.com/doc/swagger/openapi.json\">complete API specification</a> in OpenAPI format. You can use this file to automatically generate client libraries in your preferred programming language, explore the API interactively via Swagger tools, or integrate Twelve Data seamlessly into your AI and LLM workflows.</li> </ul>
5 *
6 * The version of the OpenAPI document: 0.0.1
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11use super::{configuration, ContentType, Error};
12use crate::{apis::ResponseContent, models};
13use reqwest;
14use serde::{de::Error as _, Deserialize, Serialize};
15
16/// struct for passing parameters to the method [`get_currency_conversion`]
17#[derive(Clone, Debug, Default, Serialize, Deserialize)]
18pub struct GetCurrencyConversionParams {
19 /// The currency pair you want to request can be either forex or cryptocurrency. Slash(`/`) delimiter is used. E.g. `EUR/USD` or `BTC/ETH` will be correct
20 pub symbol: String,
21 /// Amount of base currency to be converted into quote currency. Supports values in the range from `0` and above
22 pub amount: f64,
23 /// If not null, will use exchange rate from a specific date or time. Format `2006-01-02` or `2006-01-02T15:04:05`. Is set in the local exchange time zone, use timezone parameter to specify a specific time zone
24 pub date: Option<String>,
25 /// Value can be `JSON` or `CSV`. Default `JSON`
26 pub format: Option<String>,
27 /// Specify the delimiter used when downloading the `CSV` file. Default semicolon `;`
28 pub delimiter: Option<String>,
29 /// The number of decimal places for the data
30 pub dp: Option<i64>,
31 /// Timezone at which output datetime will be displayed. Supports: <ul> <li>1. <code>Exchange</code> for local exchange time</li> <li>2. <code>UTC</code> for datetime at universal UTC standard</li> <li>3. Timezone name according to the IANA Time Zone Database. E.g. <code>America/New_York</code>, <code>Asia/Singapore</code>. Full list of timezones can be found <a href=\"https://en.wikipedia.org/wiki/List_of_tz_database_time_zones\" target=\"blank\">here</a>.</li> </ul> <i>Take note that the IANA Timezone name is case-sensitive</i>
32 pub timezone: Option<String>,
33}
34
35impl GetCurrencyConversionParams {
36 /// Create a new builder for this parameter struct
37 pub fn builder() -> GetCurrencyConversionParamsBuilder {
38 GetCurrencyConversionParamsBuilder::default()
39 }
40}
41
42/// Builder for [`GetCurrencyConversionParams`]
43#[derive(Clone, Debug, Default)]
44pub struct GetCurrencyConversionParamsBuilder {
45 /// The currency pair you want to request can be either forex or cryptocurrency. Slash(`/`) delimiter is used. E.g. `EUR/USD` or `BTC/ETH` will be correct
46 symbol: String,
47 /// Amount of base currency to be converted into quote currency. Supports values in the range from `0` and above
48 amount: f64,
49 /// If not null, will use exchange rate from a specific date or time. Format `2006-01-02` or `2006-01-02T15:04:05`. Is set in the local exchange time zone, use timezone parameter to specify a specific time zone
50 date: Option<String>,
51 /// Value can be `JSON` or `CSV`. Default `JSON`
52 format: Option<String>,
53 /// Specify the delimiter used when downloading the `CSV` file. Default semicolon `;`
54 delimiter: Option<String>,
55 /// The number of decimal places for the data
56 dp: Option<i64>,
57 /// Timezone at which output datetime will be displayed. Supports: <ul> <li>1. <code>Exchange</code> for local exchange time</li> <li>2. <code>UTC</code> for datetime at universal UTC standard</li> <li>3. Timezone name according to the IANA Time Zone Database. E.g. <code>America/New_York</code>, <code>Asia/Singapore</code>. Full list of timezones can be found <a href=\"https://en.wikipedia.org/wiki/List_of_tz_database_time_zones\" target=\"blank\">here</a>.</li> </ul> <i>Take note that the IANA Timezone name is case-sensitive</i>
58 timezone: Option<String>,
59}
60
61impl GetCurrencyConversionParamsBuilder {
62 /// The currency pair you want to request can be either forex or cryptocurrency. Slash(`/`) delimiter is used. E.g. `EUR/USD` or `BTC/ETH` will be correct
63 pub fn symbol(mut self, symbol: impl Into<String>) -> Self {
64 self.symbol = symbol.into();
65 self
66 }
67 /// Amount of base currency to be converted into quote currency. Supports values in the range from `0` and above
68 pub fn amount(mut self, amount: f64) -> Self {
69 self.amount = amount;
70 self
71 }
72 /// If not null, will use exchange rate from a specific date or time. Format `2006-01-02` or `2006-01-02T15:04:05`. Is set in the local exchange time zone, use timezone parameter to specify a specific time zone
73 pub fn date(mut self, date: impl Into<String>) -> Self {
74 self.date = Some(date.into());
75 self
76 }
77 /// Value can be `JSON` or `CSV`. Default `JSON`
78 pub fn format(mut self, format: impl Into<String>) -> Self {
79 self.format = Some(format.into());
80 self
81 }
82 /// Specify the delimiter used when downloading the `CSV` file. Default semicolon `;`
83 pub fn delimiter(mut self, delimiter: impl Into<String>) -> Self {
84 self.delimiter = Some(delimiter.into());
85 self
86 }
87 /// The number of decimal places for the data
88 pub fn dp(mut self, dp: i64) -> Self {
89 self.dp = Some(dp);
90 self
91 }
92 /// Timezone at which output datetime will be displayed. Supports: <ul> <li>1. <code>Exchange</code> for local exchange time</li> <li>2. <code>UTC</code> for datetime at universal UTC standard</li> <li>3. Timezone name according to the IANA Time Zone Database. E.g. <code>America/New_York</code>, <code>Asia/Singapore</code>. Full list of timezones can be found <a href=\"https://en.wikipedia.org/wiki/List_of_tz_database_time_zones\" target=\"blank\">here</a>.</li> </ul> <i>Take note that the IANA Timezone name is case-sensitive</i>
93 pub fn timezone(mut self, timezone: impl Into<String>) -> Self {
94 self.timezone = Some(timezone.into());
95 self
96 }
97
98 /// Build the parameter struct
99 pub fn build(self) -> GetCurrencyConversionParams {
100 GetCurrencyConversionParams {
101 symbol: self.symbol,
102 amount: self.amount,
103 date: self.date,
104 format: self.format,
105 delimiter: self.delimiter,
106 dp: self.dp,
107 timezone: self.timezone,
108 }
109 }
110}
111
112/// struct for passing parameters to the method [`get_eod`]
113#[derive(Clone, Debug, Default, Serialize, Deserialize)]
114pub struct GetEodParams {
115 /// Symbol ticker of the instrument
116 pub symbol: Option<String>,
117 /// Filter by financial instrument global identifier (FIGI)
118 pub figi: Option<String>,
119 /// Filter by international securities identification number (ISIN)
120 pub isin: Option<String>,
121 /// The CUSIP of an instrument for which data is requested. CUSIP access is activating in the <a href=\"https://twelvedata.com/account/add-ons\">Add-ons</a> section
122 pub cusip: Option<String>,
123 /// Exchange where instrument is traded
124 pub exchange: Option<String>,
125 /// Market Identifier Code (MIC) under ISO 10383 standard
126 pub mic_code: Option<String>,
127 /// Country where instrument is traded, e.g., `United States` or `US`
128 pub country: Option<String>,
129 /// The asset class to which the instrument belongs
130 pub r#type: Option<String>,
131 /// If not null, then return data from a specific date
132 pub date: Option<String>,
133 /// Parameter is optional. Only for `Pro` and above plans. Available at the `1min`, `5min`, `15min`, and `30min` intervals for US equities. Open, high, low, close values are supplied without volume
134 pub prepost: Option<bool>,
135 /// Specifies the number of decimal places for floating values Should be in range [0,11] inclusive
136 pub dp: Option<i64>,
137}
138
139impl GetEodParams {
140 /// Create a new builder for this parameter struct
141 pub fn builder() -> GetEodParamsBuilder {
142 GetEodParamsBuilder::default()
143 }
144}
145
146/// Builder for [`GetEodParams`]
147#[derive(Clone, Debug, Default)]
148pub struct GetEodParamsBuilder {
149 /// Symbol ticker of the instrument
150 symbol: Option<String>,
151 /// Filter by financial instrument global identifier (FIGI)
152 figi: Option<String>,
153 /// Filter by international securities identification number (ISIN)
154 isin: Option<String>,
155 /// The CUSIP of an instrument for which data is requested. CUSIP access is activating in the <a href=\"https://twelvedata.com/account/add-ons\">Add-ons</a> section
156 cusip: Option<String>,
157 /// Exchange where instrument is traded
158 exchange: Option<String>,
159 /// Market Identifier Code (MIC) under ISO 10383 standard
160 mic_code: Option<String>,
161 /// Country where instrument is traded, e.g., `United States` or `US`
162 country: Option<String>,
163 /// The asset class to which the instrument belongs
164 r#type: Option<String>,
165 /// If not null, then return data from a specific date
166 date: Option<String>,
167 /// Parameter is optional. Only for `Pro` and above plans. Available at the `1min`, `5min`, `15min`, and `30min` intervals for US equities. Open, high, low, close values are supplied without volume
168 prepost: Option<bool>,
169 /// Specifies the number of decimal places for floating values Should be in range [0,11] inclusive
170 dp: Option<i64>,
171}
172
173impl GetEodParamsBuilder {
174 /// Symbol ticker of the instrument
175 pub fn symbol(mut self, symbol: impl Into<String>) -> Self {
176 self.symbol = Some(symbol.into());
177 self
178 }
179 /// Filter by financial instrument global identifier (FIGI)
180 pub fn figi(mut self, figi: impl Into<String>) -> Self {
181 self.figi = Some(figi.into());
182 self
183 }
184 /// Filter by international securities identification number (ISIN)
185 pub fn isin(mut self, isin: impl Into<String>) -> Self {
186 self.isin = Some(isin.into());
187 self
188 }
189 /// The CUSIP of an instrument for which data is requested. CUSIP access is activating in the <a href=\"https://twelvedata.com/account/add-ons\">Add-ons</a> section
190 pub fn cusip(mut self, cusip: impl Into<String>) -> Self {
191 self.cusip = Some(cusip.into());
192 self
193 }
194 /// Exchange where instrument is traded
195 pub fn exchange(mut self, exchange: impl Into<String>) -> Self {
196 self.exchange = Some(exchange.into());
197 self
198 }
199 /// Market Identifier Code (MIC) under ISO 10383 standard
200 pub fn mic_code(mut self, mic_code: impl Into<String>) -> Self {
201 self.mic_code = Some(mic_code.into());
202 self
203 }
204 /// Country where instrument is traded, e.g., `United States` or `US`
205 pub fn country(mut self, country: impl Into<String>) -> Self {
206 self.country = Some(country.into());
207 self
208 }
209 /// The asset class to which the instrument belongs
210 pub fn r#type(mut self, r#type: impl Into<String>) -> Self {
211 self.r#type = Some(r#type.into());
212 self
213 }
214 /// If not null, then return data from a specific date
215 pub fn date(mut self, date: impl Into<String>) -> Self {
216 self.date = Some(date.into());
217 self
218 }
219 /// Parameter is optional. Only for `Pro` and above plans. Available at the `1min`, `5min`, `15min`, and `30min` intervals for US equities. Open, high, low, close values are supplied without volume
220 pub fn prepost(mut self, prepost: bool) -> Self {
221 self.prepost = Some(prepost);
222 self
223 }
224 /// Specifies the number of decimal places for floating values Should be in range [0,11] inclusive
225 pub fn dp(mut self, dp: i64) -> Self {
226 self.dp = Some(dp);
227 self
228 }
229
230 /// Build the parameter struct
231 pub fn build(self) -> GetEodParams {
232 GetEodParams {
233 symbol: self.symbol,
234 figi: self.figi,
235 isin: self.isin,
236 cusip: self.cusip,
237 exchange: self.exchange,
238 mic_code: self.mic_code,
239 country: self.country,
240 r#type: self.r#type,
241 date: self.date,
242 prepost: self.prepost,
243 dp: self.dp,
244 }
245 }
246}
247
248/// struct for passing parameters to the method [`get_exchange_rate`]
249#[derive(Clone, Debug, Default, Serialize, Deserialize)]
250pub struct GetExchangeRateParams {
251 /// The currency pair you want to request can be either forex or cryptocurrency. Slash(`/`) delimiter is used. E.g. `EUR/USD` or `BTC/ETH` will be correct
252 pub symbol: String,
253 /// If not null, will use exchange rate from a specific date or time. Format `2006-01-02` or `2006-01-02T15:04:05`. Is set in the local exchange time zone, use timezone parameter to specify a specific time zone
254 pub date: Option<String>,
255 /// Value can be `JSON` or `CSV`. Default `JSON`
256 pub format: Option<String>,
257 /// Specify the delimiter used when downloading the `CSV` file. Default semicolon `;`
258 pub delimiter: Option<String>,
259 /// The number of decimal places for the data
260 pub dp: Option<i64>,
261 /// Timezone at which output datetime will be displayed. Supports: <ul> <li>1. <code>Exchange</code> for local exchange time</li> <li>2. <code>UTC</code> for datetime at universal UTC standard</li> <li>3. Timezone name according to the IANA Time Zone Database. E.g. <code>America/New_York</code>, <code>Asia/Singapore</code>. Full list of timezones can be found <a href=\"https://en.wikipedia.org/wiki/List_of_tz_database_time_zones\" target=\"blank\">here</a>.</li> </ul> <i>Take note that the IANA Timezone name is case-sensitive</i>
262 pub timezone: Option<String>,
263}
264
265impl GetExchangeRateParams {
266 /// Create a new builder for this parameter struct
267 pub fn builder() -> GetExchangeRateParamsBuilder {
268 GetExchangeRateParamsBuilder::default()
269 }
270}
271
272/// Builder for [`GetExchangeRateParams`]
273#[derive(Clone, Debug, Default)]
274pub struct GetExchangeRateParamsBuilder {
275 /// The currency pair you want to request can be either forex or cryptocurrency. Slash(`/`) delimiter is used. E.g. `EUR/USD` or `BTC/ETH` will be correct
276 symbol: String,
277 /// If not null, will use exchange rate from a specific date or time. Format `2006-01-02` or `2006-01-02T15:04:05`. Is set in the local exchange time zone, use timezone parameter to specify a specific time zone
278 date: Option<String>,
279 /// Value can be `JSON` or `CSV`. Default `JSON`
280 format: Option<String>,
281 /// Specify the delimiter used when downloading the `CSV` file. Default semicolon `;`
282 delimiter: Option<String>,
283 /// The number of decimal places for the data
284 dp: Option<i64>,
285 /// Timezone at which output datetime will be displayed. Supports: <ul> <li>1. <code>Exchange</code> for local exchange time</li> <li>2. <code>UTC</code> for datetime at universal UTC standard</li> <li>3. Timezone name according to the IANA Time Zone Database. E.g. <code>America/New_York</code>, <code>Asia/Singapore</code>. Full list of timezones can be found <a href=\"https://en.wikipedia.org/wiki/List_of_tz_database_time_zones\" target=\"blank\">here</a>.</li> </ul> <i>Take note that the IANA Timezone name is case-sensitive</i>
286 timezone: Option<String>,
287}
288
289impl GetExchangeRateParamsBuilder {
290 /// The currency pair you want to request can be either forex or cryptocurrency. Slash(`/`) delimiter is used. E.g. `EUR/USD` or `BTC/ETH` will be correct
291 pub fn symbol(mut self, symbol: impl Into<String>) -> Self {
292 self.symbol = symbol.into();
293 self
294 }
295 /// If not null, will use exchange rate from a specific date or time. Format `2006-01-02` or `2006-01-02T15:04:05`. Is set in the local exchange time zone, use timezone parameter to specify a specific time zone
296 pub fn date(mut self, date: impl Into<String>) -> Self {
297 self.date = Some(date.into());
298 self
299 }
300 /// Value can be `JSON` or `CSV`. Default `JSON`
301 pub fn format(mut self, format: impl Into<String>) -> Self {
302 self.format = Some(format.into());
303 self
304 }
305 /// Specify the delimiter used when downloading the `CSV` file. Default semicolon `;`
306 pub fn delimiter(mut self, delimiter: impl Into<String>) -> Self {
307 self.delimiter = Some(delimiter.into());
308 self
309 }
310 /// The number of decimal places for the data
311 pub fn dp(mut self, dp: i64) -> Self {
312 self.dp = Some(dp);
313 self
314 }
315 /// Timezone at which output datetime will be displayed. Supports: <ul> <li>1. <code>Exchange</code> for local exchange time</li> <li>2. <code>UTC</code> for datetime at universal UTC standard</li> <li>3. Timezone name according to the IANA Time Zone Database. E.g. <code>America/New_York</code>, <code>Asia/Singapore</code>. Full list of timezones can be found <a href=\"https://en.wikipedia.org/wiki/List_of_tz_database_time_zones\" target=\"blank\">here</a>.</li> </ul> <i>Take note that the IANA Timezone name is case-sensitive</i>
316 pub fn timezone(mut self, timezone: impl Into<String>) -> Self {
317 self.timezone = Some(timezone.into());
318 self
319 }
320
321 /// Build the parameter struct
322 pub fn build(self) -> GetExchangeRateParams {
323 GetExchangeRateParams {
324 symbol: self.symbol,
325 date: self.date,
326 format: self.format,
327 delimiter: self.delimiter,
328 dp: self.dp,
329 timezone: self.timezone,
330 }
331 }
332}
333
334/// struct for passing parameters to the method [`get_market_movers`]
335#[derive(Clone, Debug, Default, Serialize, Deserialize)]
336pub struct GetMarketMoversParams {
337 /// Maket type
338 pub market: String,
339 /// Specifies direction of the snapshot gainers or losers
340 pub direction: Option<String>,
341 /// Specifies the size of the snapshot. Can be in a range from `1` to `50`
342 pub outputsize: Option<i64>,
343 /// Country of the snapshot, applicable to non-currencies only. Takes country name or alpha code
344 pub country: Option<String>,
345 /// Takes values with price grater than specified value
346 pub price_greater_than: Option<String>,
347 /// Specifies the number of decimal places for floating values. Should be in range [0,11] inclusive
348 pub dp: Option<String>,
349}
350
351impl GetMarketMoversParams {
352 /// Create a new builder for this parameter struct
353 pub fn builder() -> GetMarketMoversParamsBuilder {
354 GetMarketMoversParamsBuilder::default()
355 }
356}
357
358/// Builder for [`GetMarketMoversParams`]
359#[derive(Clone, Debug, Default)]
360pub struct GetMarketMoversParamsBuilder {
361 /// Maket type
362 market: String,
363 /// Specifies direction of the snapshot gainers or losers
364 direction: Option<String>,
365 /// Specifies the size of the snapshot. Can be in a range from `1` to `50`
366 outputsize: Option<i64>,
367 /// Country of the snapshot, applicable to non-currencies only. Takes country name or alpha code
368 country: Option<String>,
369 /// Takes values with price grater than specified value
370 price_greater_than: Option<String>,
371 /// Specifies the number of decimal places for floating values. Should be in range [0,11] inclusive
372 dp: Option<String>,
373}
374
375impl GetMarketMoversParamsBuilder {
376 /// Maket type
377 pub fn market(mut self, market: impl Into<String>) -> Self {
378 self.market = market.into();
379 self
380 }
381 /// Specifies direction of the snapshot gainers or losers
382 pub fn direction(mut self, direction: impl Into<String>) -> Self {
383 self.direction = Some(direction.into());
384 self
385 }
386 /// Specifies the size of the snapshot. Can be in a range from `1` to `50`
387 pub fn outputsize(mut self, outputsize: i64) -> Self {
388 self.outputsize = Some(outputsize);
389 self
390 }
391 /// Country of the snapshot, applicable to non-currencies only. Takes country name or alpha code
392 pub fn country(mut self, country: impl Into<String>) -> Self {
393 self.country = Some(country.into());
394 self
395 }
396 /// Takes values with price grater than specified value
397 pub fn price_greater_than(mut self, price_greater_than: impl Into<String>) -> Self {
398 self.price_greater_than = Some(price_greater_than.into());
399 self
400 }
401 /// Specifies the number of decimal places for floating values. Should be in range [0,11] inclusive
402 pub fn dp(mut self, dp: impl Into<String>) -> Self {
403 self.dp = Some(dp.into());
404 self
405 }
406
407 /// Build the parameter struct
408 pub fn build(self) -> GetMarketMoversParams {
409 GetMarketMoversParams {
410 market: self.market,
411 direction: self.direction,
412 outputsize: self.outputsize,
413 country: self.country,
414 price_greater_than: self.price_greater_than,
415 dp: self.dp,
416 }
417 }
418}
419
420/// struct for passing parameters to the method [`get_price`]
421#[derive(Clone, Debug, Default, Serialize, Deserialize)]
422pub struct GetPriceParams {
423 /// Symbol ticker of the instrument
424 pub symbol: Option<String>,
425 /// Filter by financial instrument global identifier (FIGI)
426 pub figi: Option<String>,
427 /// Filter by international securities identification number (ISIN)
428 pub isin: Option<String>,
429 /// The CUSIP of an instrument for which data is requested. CUSIP access is activating in the <a href=\"https://twelvedata.com/account/add-ons\">Add-ons</a> section
430 pub cusip: Option<String>,
431 /// Exchange where instrument is traded
432 pub exchange: Option<String>,
433 /// Market Identifier Code (MIC) under ISO 10383 standard
434 pub mic_code: Option<String>,
435 /// Country where instrument is traded, e.g., `United States` or `US`
436 pub country: Option<String>,
437 /// The asset class to which the instrument belongs
438 pub r#type: Option<String>,
439 /// Value can be JSON or CSV
440 pub format: Option<String>,
441 /// Specify the delimiter used when downloading the CSV file
442 pub delimiter: Option<String>,
443 /// Parameter is optional. Only for Pro and above plans. Available at the `1min`, `5min`, `15min`, and `30min` intervals for US equities. Open, high, low, close values are supplied without volume.
444 pub prepost: Option<bool>,
445 /// Specifies the number of decimal places for floating values. Should be in range [0,11] inclusive
446 pub dp: Option<i64>,
447}
448
449impl GetPriceParams {
450 /// Create a new builder for this parameter struct
451 pub fn builder() -> GetPriceParamsBuilder {
452 GetPriceParamsBuilder::default()
453 }
454}
455
456/// Builder for [`GetPriceParams`]
457#[derive(Clone, Debug, Default)]
458pub struct GetPriceParamsBuilder {
459 /// Symbol ticker of the instrument
460 symbol: Option<String>,
461 /// Filter by financial instrument global identifier (FIGI)
462 figi: Option<String>,
463 /// Filter by international securities identification number (ISIN)
464 isin: Option<String>,
465 /// The CUSIP of an instrument for which data is requested. CUSIP access is activating in the <a href=\"https://twelvedata.com/account/add-ons\">Add-ons</a> section
466 cusip: Option<String>,
467 /// Exchange where instrument is traded
468 exchange: Option<String>,
469 /// Market Identifier Code (MIC) under ISO 10383 standard
470 mic_code: Option<String>,
471 /// Country where instrument is traded, e.g., `United States` or `US`
472 country: Option<String>,
473 /// The asset class to which the instrument belongs
474 r#type: Option<String>,
475 /// Value can be JSON or CSV
476 format: Option<String>,
477 /// Specify the delimiter used when downloading the CSV file
478 delimiter: Option<String>,
479 /// Parameter is optional. Only for Pro and above plans. Available at the `1min`, `5min`, `15min`, and `30min` intervals for US equities. Open, high, low, close values are supplied without volume.
480 prepost: Option<bool>,
481 /// Specifies the number of decimal places for floating values. Should be in range [0,11] inclusive
482 dp: Option<i64>,
483}
484
485impl GetPriceParamsBuilder {
486 /// Symbol ticker of the instrument
487 pub fn symbol(mut self, symbol: impl Into<String>) -> Self {
488 self.symbol = Some(symbol.into());
489 self
490 }
491 /// Filter by financial instrument global identifier (FIGI)
492 pub fn figi(mut self, figi: impl Into<String>) -> Self {
493 self.figi = Some(figi.into());
494 self
495 }
496 /// Filter by international securities identification number (ISIN)
497 pub fn isin(mut self, isin: impl Into<String>) -> Self {
498 self.isin = Some(isin.into());
499 self
500 }
501 /// The CUSIP of an instrument for which data is requested. CUSIP access is activating in the <a href=\"https://twelvedata.com/account/add-ons\">Add-ons</a> section
502 pub fn cusip(mut self, cusip: impl Into<String>) -> Self {
503 self.cusip = Some(cusip.into());
504 self
505 }
506 /// Exchange where instrument is traded
507 pub fn exchange(mut self, exchange: impl Into<String>) -> Self {
508 self.exchange = Some(exchange.into());
509 self
510 }
511 /// Market Identifier Code (MIC) under ISO 10383 standard
512 pub fn mic_code(mut self, mic_code: impl Into<String>) -> Self {
513 self.mic_code = Some(mic_code.into());
514 self
515 }
516 /// Country where instrument is traded, e.g., `United States` or `US`
517 pub fn country(mut self, country: impl Into<String>) -> Self {
518 self.country = Some(country.into());
519 self
520 }
521 /// The asset class to which the instrument belongs
522 pub fn r#type(mut self, r#type: impl Into<String>) -> Self {
523 self.r#type = Some(r#type.into());
524 self
525 }
526 /// Value can be JSON or CSV
527 pub fn format(mut self, format: impl Into<String>) -> Self {
528 self.format = Some(format.into());
529 self
530 }
531 /// Specify the delimiter used when downloading the CSV file
532 pub fn delimiter(mut self, delimiter: impl Into<String>) -> Self {
533 self.delimiter = Some(delimiter.into());
534 self
535 }
536 /// Parameter is optional. Only for Pro and above plans. Available at the `1min`, `5min`, `15min`, and `30min` intervals for US equities. Open, high, low, close values are supplied without volume.
537 pub fn prepost(mut self, prepost: bool) -> Self {
538 self.prepost = Some(prepost);
539 self
540 }
541 /// Specifies the number of decimal places for floating values. Should be in range [0,11] inclusive
542 pub fn dp(mut self, dp: i64) -> Self {
543 self.dp = Some(dp);
544 self
545 }
546
547 /// Build the parameter struct
548 pub fn build(self) -> GetPriceParams {
549 GetPriceParams {
550 symbol: self.symbol,
551 figi: self.figi,
552 isin: self.isin,
553 cusip: self.cusip,
554 exchange: self.exchange,
555 mic_code: self.mic_code,
556 country: self.country,
557 r#type: self.r#type,
558 format: self.format,
559 delimiter: self.delimiter,
560 prepost: self.prepost,
561 dp: self.dp,
562 }
563 }
564}
565
566/// struct for passing parameters to the method [`get_quote`]
567#[derive(Clone, Debug, Default, Serialize, Deserialize)]
568pub struct GetQuoteParams {
569 /// Symbol ticker of the instrument
570 pub symbol: Option<String>,
571 /// Filter by financial instrument global identifier (FIGI)
572 pub figi: Option<String>,
573 /// Filter by international securities identification number (ISIN)
574 pub isin: Option<String>,
575 /// The CUSIP of an instrument for which data is requested. CUSIP access is activating in the <a href=\"https://twelvedata.com/account/add-ons\">Add-ons</a> section
576 pub cusip: Option<String>,
577 /// Interval of the quote
578 pub interval: Option<String>,
579 /// Exchange where instrument is traded
580 pub exchange: Option<String>,
581 /// Market Identifier Code (MIC) under ISO 10383 standard
582 pub mic_code: Option<String>,
583 /// Country where instrument is traded, e.g., `United States` or `US`
584 pub country: Option<String>,
585 /// Number of periods for Average Volume
586 pub volume_time_period: Option<i64>,
587 /// The asset class to which the instrument belongs
588 pub r#type: Option<String>,
589 /// Value can be JSON or CSV Default JSON
590 pub format: Option<String>,
591 /// Specify the delimiter used when downloading the CSV file
592 pub delimiter: Option<String>,
593 /// Parameter is optional. Only for `Pro` and above plans. Available at the `1min`, `5min`, `15min`, and `30min` intervals for US equities. Open, high, low, close values are supplied without volume.
594 pub prepost: Option<bool>,
595 /// If true, then return data for closed day
596 pub eod: Option<bool>,
597 /// Number of hours for calculate rolling change at period. By default set to 24, it can be in range [1, 168].
598 pub rolling_period: Option<i64>,
599 /// Specifies the number of decimal places for floating values Should be in range [0,11] inclusive
600 pub dp: Option<i64>,
601 /// Timezone at which output datetime will be displayed. Supports: <ul> <li>1. <code>Exchange</code> for local exchange time</li> <li>2. <code>UTC</code> for datetime at universal UTC standard</li> <li>3. Timezone name according to the IANA Time Zone Database. E.g. <code>America/New_York</code>, <code>Asia/Singapore</code>. Full list of timezones can be found <a href=\"https://en.wikipedia.org/wiki/List_of_tz_database_time_zones\" target=\"blank\">here</a>.</li> </ul> <i>Take note that the IANA Timezone name is case-sensitive</i>
602 pub timezone: Option<String>,
603}
604
605impl GetQuoteParams {
606 /// Create a new builder for this parameter struct
607 pub fn builder() -> GetQuoteParamsBuilder {
608 GetQuoteParamsBuilder::default()
609 }
610}
611
612/// Builder for [`GetQuoteParams`]
613#[derive(Clone, Debug, Default)]
614pub struct GetQuoteParamsBuilder {
615 /// Symbol ticker of the instrument
616 symbol: Option<String>,
617 /// Filter by financial instrument global identifier (FIGI)
618 figi: Option<String>,
619 /// Filter by international securities identification number (ISIN)
620 isin: Option<String>,
621 /// The CUSIP of an instrument for which data is requested. CUSIP access is activating in the <a href=\"https://twelvedata.com/account/add-ons\">Add-ons</a> section
622 cusip: Option<String>,
623 /// Interval of the quote
624 interval: Option<String>,
625 /// Exchange where instrument is traded
626 exchange: Option<String>,
627 /// Market Identifier Code (MIC) under ISO 10383 standard
628 mic_code: Option<String>,
629 /// Country where instrument is traded, e.g., `United States` or `US`
630 country: Option<String>,
631 /// Number of periods for Average Volume
632 volume_time_period: Option<i64>,
633 /// The asset class to which the instrument belongs
634 r#type: Option<String>,
635 /// Value can be JSON or CSV Default JSON
636 format: Option<String>,
637 /// Specify the delimiter used when downloading the CSV file
638 delimiter: Option<String>,
639 /// Parameter is optional. Only for `Pro` and above plans. Available at the `1min`, `5min`, `15min`, and `30min` intervals for US equities. Open, high, low, close values are supplied without volume.
640 prepost: Option<bool>,
641 /// If true, then return data for closed day
642 eod: Option<bool>,
643 /// Number of hours for calculate rolling change at period. By default set to 24, it can be in range [1, 168].
644 rolling_period: Option<i64>,
645 /// Specifies the number of decimal places for floating values Should be in range [0,11] inclusive
646 dp: Option<i64>,
647 /// Timezone at which output datetime will be displayed. Supports: <ul> <li>1. <code>Exchange</code> for local exchange time</li> <li>2. <code>UTC</code> for datetime at universal UTC standard</li> <li>3. Timezone name according to the IANA Time Zone Database. E.g. <code>America/New_York</code>, <code>Asia/Singapore</code>. Full list of timezones can be found <a href=\"https://en.wikipedia.org/wiki/List_of_tz_database_time_zones\" target=\"blank\">here</a>.</li> </ul> <i>Take note that the IANA Timezone name is case-sensitive</i>
648 timezone: Option<String>,
649}
650
651impl GetQuoteParamsBuilder {
652 /// Symbol ticker of the instrument
653 pub fn symbol(mut self, symbol: impl Into<String>) -> Self {
654 self.symbol = Some(symbol.into());
655 self
656 }
657 /// Filter by financial instrument global identifier (FIGI)
658 pub fn figi(mut self, figi: impl Into<String>) -> Self {
659 self.figi = Some(figi.into());
660 self
661 }
662 /// Filter by international securities identification number (ISIN)
663 pub fn isin(mut self, isin: impl Into<String>) -> Self {
664 self.isin = Some(isin.into());
665 self
666 }
667 /// The CUSIP of an instrument for which data is requested. CUSIP access is activating in the <a href=\"https://twelvedata.com/account/add-ons\">Add-ons</a> section
668 pub fn cusip(mut self, cusip: impl Into<String>) -> Self {
669 self.cusip = Some(cusip.into());
670 self
671 }
672 /// Interval of the quote
673 pub fn interval(mut self, interval: impl Into<String>) -> Self {
674 self.interval = Some(interval.into());
675 self
676 }
677 /// Exchange where instrument is traded
678 pub fn exchange(mut self, exchange: impl Into<String>) -> Self {
679 self.exchange = Some(exchange.into());
680 self
681 }
682 /// Market Identifier Code (MIC) under ISO 10383 standard
683 pub fn mic_code(mut self, mic_code: impl Into<String>) -> Self {
684 self.mic_code = Some(mic_code.into());
685 self
686 }
687 /// Country where instrument is traded, e.g., `United States` or `US`
688 pub fn country(mut self, country: impl Into<String>) -> Self {
689 self.country = Some(country.into());
690 self
691 }
692 /// Number of periods for Average Volume
693 pub fn volume_time_period(mut self, volume_time_period: i64) -> Self {
694 self.volume_time_period = Some(volume_time_period);
695 self
696 }
697 /// The asset class to which the instrument belongs
698 pub fn r#type(mut self, r#type: impl Into<String>) -> Self {
699 self.r#type = Some(r#type.into());
700 self
701 }
702 /// Value can be JSON or CSV Default JSON
703 pub fn format(mut self, format: impl Into<String>) -> Self {
704 self.format = Some(format.into());
705 self
706 }
707 /// Specify the delimiter used when downloading the CSV file
708 pub fn delimiter(mut self, delimiter: impl Into<String>) -> Self {
709 self.delimiter = Some(delimiter.into());
710 self
711 }
712 /// Parameter is optional. Only for `Pro` and above plans. Available at the `1min`, `5min`, `15min`, and `30min` intervals for US equities. Open, high, low, close values are supplied without volume.
713 pub fn prepost(mut self, prepost: bool) -> Self {
714 self.prepost = Some(prepost);
715 self
716 }
717 /// If true, then return data for closed day
718 pub fn eod(mut self, eod: bool) -> Self {
719 self.eod = Some(eod);
720 self
721 }
722 /// Number of hours for calculate rolling change at period. By default set to 24, it can be in range [1, 168].
723 pub fn rolling_period(mut self, rolling_period: i64) -> Self {
724 self.rolling_period = Some(rolling_period);
725 self
726 }
727 /// Specifies the number of decimal places for floating values Should be in range [0,11] inclusive
728 pub fn dp(mut self, dp: i64) -> Self {
729 self.dp = Some(dp);
730 self
731 }
732 /// Timezone at which output datetime will be displayed. Supports: <ul> <li>1. <code>Exchange</code> for local exchange time</li> <li>2. <code>UTC</code> for datetime at universal UTC standard</li> <li>3. Timezone name according to the IANA Time Zone Database. E.g. <code>America/New_York</code>, <code>Asia/Singapore</code>. Full list of timezones can be found <a href=\"https://en.wikipedia.org/wiki/List_of_tz_database_time_zones\" target=\"blank\">here</a>.</li> </ul> <i>Take note that the IANA Timezone name is case-sensitive</i>
733 pub fn timezone(mut self, timezone: impl Into<String>) -> Self {
734 self.timezone = Some(timezone.into());
735 self
736 }
737
738 /// Build the parameter struct
739 pub fn build(self) -> GetQuoteParams {
740 GetQuoteParams {
741 symbol: self.symbol,
742 figi: self.figi,
743 isin: self.isin,
744 cusip: self.cusip,
745 interval: self.interval,
746 exchange: self.exchange,
747 mic_code: self.mic_code,
748 country: self.country,
749 volume_time_period: self.volume_time_period,
750 r#type: self.r#type,
751 format: self.format,
752 delimiter: self.delimiter,
753 prepost: self.prepost,
754 eod: self.eod,
755 rolling_period: self.rolling_period,
756 dp: self.dp,
757 timezone: self.timezone,
758 }
759 }
760}
761
762/// struct for passing parameters to the method [`get_time_series`]
763#[derive(Clone, Debug, Default, Serialize, Deserialize)]
764pub struct GetTimeSeriesParams {
765 /// Interval between two consecutive points in time series
766 pub interval: String,
767 /// Symbol ticker of the instrument. E.g. `AAPL`, `EUR/USD`, `ETH/BTC`, ...
768 pub symbol: Option<String>,
769 /// Filter by international securities identification number (ISIN)
770 pub isin: Option<String>,
771 /// The FIGI of an instrument for which data is requested
772 pub figi: Option<String>,
773 /// The CUSIP of an instrument for which data is requested. CUSIP access is activating in the <a href=\"https://twelvedata.com/account/add-ons\">Add-ons</a> section
774 pub cusip: Option<String>,
775 /// Number of data points to retrieve. Supports values in the range from `1` to `5000`. Default `30` when no date parameters are set, otherwise set to maximum
776 pub outputsize: Option<i64>,
777 /// Exchange where instrument is traded
778 pub exchange: Option<String>,
779 /// Market Identifier Code (MIC) under ISO 10383 standard
780 pub mic_code: Option<String>,
781 /// The country where the instrument is traded, e.g., `United States` or `US`
782 pub country: Option<String>,
783 /// The asset class to which the instrument belongs
784 pub r#type: Option<String>,
785 /// Timezone at which output datetime will be displayed. Supports: <ul> <li>1. <code>Exchange</code> for local exchange time</li> <li>2. <code>UTC</code> for datetime at universal UTC standard</li> <li>3. Timezone name according to the IANA Time Zone Database. E.g. <code>America/New_York</code>, <code>Asia/Singapore</code>. Full list of timezones can be found <a href=\"https://en.wikipedia.org/wiki/List_of_tz_database_time_zones\" target=\"blank\">here</a></li> </ul> <i>Take note that the IANA Timezone name is case-sensitive</i>
786 pub timezone: Option<String>,
787 /// Can be used separately and together with `end_date`. Format `2006-01-02` or `2006-01-02T15:04:05` Default location: <ul> <li>Forex and Cryptocurrencies - <code>UTC</code></li> <li>Stocks - where exchange is located (e.g. for AAPL it will be <code>America/New_York</code>)</li> </ul> Both parameters take into account if <code>timezone</code> parameter is provided.<br/> If <code>timezone</code> is given then, <code>start_date</code> and <code>end_date</code> will be used in the specified location Examples: <ul> <li>1. <code>&symbol=AAPL&start_date=2019-08-09T15:50:00&…</code><br/> Returns all records starting from 2019-08-09T15:50:00 New York time up to current date</li> <li>2. <code>&symbol=EUR/USD&timezone=Asia/Singapore&start_date=2019-08-09T15:50:00&…</code><br/> Returns all records starting from 2019-08-09T15:50:00 Singapore time up to current date</li> <li>3. <code>&symbol=ETH/BTC&timezone=Europe/Zurich&start_date=2019-08-09T15:50:00&end_date=2019-08-09T15:55:00&...</code><br/> Returns all records starting from 2019-08-09T15:50:00 Zurich time up to 2019-08-09T15:55:00</li> </ul>
788 pub start_date: Option<String>,
789 /// The ending date and time for data selection, see `start_date` description for details.
790 pub end_date: Option<String>,
791 /// Specifies the exact date to get the data for. Could be the exact date, e.g. `2021-10-27`, or in human language `today` or `yesterday`
792 pub date: Option<String>,
793 /// Sorting order of the output
794 pub order: Option<String>,
795 /// Returns quotes that include pre-market and post-market data. Only for `Pro` and above plans. Available at the `1min`, `5min`, `15min`, and `30min` intervals for US equities. Open, high, low, close values are supplied without volume
796 pub prepost: Option<bool>,
797 /// The format of the response data
798 pub format: Option<String>,
799 /// The separator used in the CSV response data
800 pub delimiter: Option<String>,
801 /// Specifies the number of decimal places for floating values. Should be in range [0, 11] inclusive. By default, the number of decimal places is automatically determined based on the values provided
802 pub dp: Option<i64>,
803 /// A boolean parameter to include the previous closing price in the time_series data. If true, adds previous bar close price value to the current object
804 pub previous_close: Option<bool>,
805 /// Adjusting mode for prices
806 pub adjust: Option<String>,
807}
808
809impl GetTimeSeriesParams {
810 /// Create a new builder for this parameter struct
811 pub fn builder() -> GetTimeSeriesParamsBuilder {
812 GetTimeSeriesParamsBuilder::default()
813 }
814}
815
816/// Builder for [`GetTimeSeriesParams`]
817#[derive(Clone, Debug, Default)]
818pub struct GetTimeSeriesParamsBuilder {
819 /// Interval between two consecutive points in time series
820 interval: String,
821 /// Symbol ticker of the instrument. E.g. `AAPL`, `EUR/USD`, `ETH/BTC`, ...
822 symbol: Option<String>,
823 /// Filter by international securities identification number (ISIN)
824 isin: Option<String>,
825 /// The FIGI of an instrument for which data is requested
826 figi: Option<String>,
827 /// The CUSIP of an instrument for which data is requested. CUSIP access is activating in the <a href=\"https://twelvedata.com/account/add-ons\">Add-ons</a> section
828 cusip: Option<String>,
829 /// Number of data points to retrieve. Supports values in the range from `1` to `5000`. Default `30` when no date parameters are set, otherwise set to maximum
830 outputsize: Option<i64>,
831 /// Exchange where instrument is traded
832 exchange: Option<String>,
833 /// Market Identifier Code (MIC) under ISO 10383 standard
834 mic_code: Option<String>,
835 /// The country where the instrument is traded, e.g., `United States` or `US`
836 country: Option<String>,
837 /// The asset class to which the instrument belongs
838 r#type: Option<String>,
839 /// Timezone at which output datetime will be displayed. Supports: <ul> <li>1. <code>Exchange</code> for local exchange time</li> <li>2. <code>UTC</code> for datetime at universal UTC standard</li> <li>3. Timezone name according to the IANA Time Zone Database. E.g. <code>America/New_York</code>, <code>Asia/Singapore</code>. Full list of timezones can be found <a href=\"https://en.wikipedia.org/wiki/List_of_tz_database_time_zones\" target=\"blank\">here</a></li> </ul> <i>Take note that the IANA Timezone name is case-sensitive</i>
840 timezone: Option<String>,
841 /// Can be used separately and together with `end_date`. Format `2006-01-02` or `2006-01-02T15:04:05` Default location: <ul> <li>Forex and Cryptocurrencies - <code>UTC</code></li> <li>Stocks - where exchange is located (e.g. for AAPL it will be <code>America/New_York</code>)</li> </ul> Both parameters take into account if <code>timezone</code> parameter is provided.<br/> If <code>timezone</code> is given then, <code>start_date</code> and <code>end_date</code> will be used in the specified location Examples: <ul> <li>1. <code>&symbol=AAPL&start_date=2019-08-09T15:50:00&…</code><br/> Returns all records starting from 2019-08-09T15:50:00 New York time up to current date</li> <li>2. <code>&symbol=EUR/USD&timezone=Asia/Singapore&start_date=2019-08-09T15:50:00&…</code><br/> Returns all records starting from 2019-08-09T15:50:00 Singapore time up to current date</li> <li>3. <code>&symbol=ETH/BTC&timezone=Europe/Zurich&start_date=2019-08-09T15:50:00&end_date=2019-08-09T15:55:00&...</code><br/> Returns all records starting from 2019-08-09T15:50:00 Zurich time up to 2019-08-09T15:55:00</li> </ul>
842 start_date: Option<String>,
843 /// The ending date and time for data selection, see `start_date` description for details.
844 end_date: Option<String>,
845 /// Specifies the exact date to get the data for. Could be the exact date, e.g. `2021-10-27`, or in human language `today` or `yesterday`
846 date: Option<String>,
847 /// Sorting order of the output
848 order: Option<String>,
849 /// Returns quotes that include pre-market and post-market data. Only for `Pro` and above plans. Available at the `1min`, `5min`, `15min`, and `30min` intervals for US equities. Open, high, low, close values are supplied without volume
850 prepost: Option<bool>,
851 /// The format of the response data
852 format: Option<String>,
853 /// The separator used in the CSV response data
854 delimiter: Option<String>,
855 /// Specifies the number of decimal places for floating values. Should be in range [0, 11] inclusive. By default, the number of decimal places is automatically determined based on the values provided
856 dp: Option<i64>,
857 /// A boolean parameter to include the previous closing price in the time_series data. If true, adds previous bar close price value to the current object
858 previous_close: Option<bool>,
859 /// Adjusting mode for prices
860 adjust: Option<String>,
861}
862
863impl GetTimeSeriesParamsBuilder {
864 /// Interval between two consecutive points in time series
865 pub fn interval(mut self, interval: impl Into<String>) -> Self {
866 self.interval = interval.into();
867 self
868 }
869 /// Symbol ticker of the instrument. E.g. `AAPL`, `EUR/USD`, `ETH/BTC`, ...
870 pub fn symbol(mut self, symbol: impl Into<String>) -> Self {
871 self.symbol = Some(symbol.into());
872 self
873 }
874 /// Filter by international securities identification number (ISIN)
875 pub fn isin(mut self, isin: impl Into<String>) -> Self {
876 self.isin = Some(isin.into());
877 self
878 }
879 /// The FIGI of an instrument for which data is requested
880 pub fn figi(mut self, figi: impl Into<String>) -> Self {
881 self.figi = Some(figi.into());
882 self
883 }
884 /// The CUSIP of an instrument for which data is requested. CUSIP access is activating in the <a href=\"https://twelvedata.com/account/add-ons\">Add-ons</a> section
885 pub fn cusip(mut self, cusip: impl Into<String>) -> Self {
886 self.cusip = Some(cusip.into());
887 self
888 }
889 /// Number of data points to retrieve. Supports values in the range from `1` to `5000`. Default `30` when no date parameters are set, otherwise set to maximum
890 pub fn outputsize(mut self, outputsize: i64) -> Self {
891 self.outputsize = Some(outputsize);
892 self
893 }
894 /// Exchange where instrument is traded
895 pub fn exchange(mut self, exchange: impl Into<String>) -> Self {
896 self.exchange = Some(exchange.into());
897 self
898 }
899 /// Market Identifier Code (MIC) under ISO 10383 standard
900 pub fn mic_code(mut self, mic_code: impl Into<String>) -> Self {
901 self.mic_code = Some(mic_code.into());
902 self
903 }
904 /// The country where the instrument is traded, e.g., `United States` or `US`
905 pub fn country(mut self, country: impl Into<String>) -> Self {
906 self.country = Some(country.into());
907 self
908 }
909 /// The asset class to which the instrument belongs
910 pub fn r#type(mut self, r#type: impl Into<String>) -> Self {
911 self.r#type = Some(r#type.into());
912 self
913 }
914 /// Timezone at which output datetime will be displayed. Supports: <ul> <li>1. <code>Exchange</code> for local exchange time</li> <li>2. <code>UTC</code> for datetime at universal UTC standard</li> <li>3. Timezone name according to the IANA Time Zone Database. E.g. <code>America/New_York</code>, <code>Asia/Singapore</code>. Full list of timezones can be found <a href=\"https://en.wikipedia.org/wiki/List_of_tz_database_time_zones\" target=\"blank\">here</a></li> </ul> <i>Take note that the IANA Timezone name is case-sensitive</i>
915 pub fn timezone(mut self, timezone: impl Into<String>) -> Self {
916 self.timezone = Some(timezone.into());
917 self
918 }
919 /// Can be used separately and together with `end_date`. Format `2006-01-02` or `2006-01-02T15:04:05` Default location: <ul> <li>Forex and Cryptocurrencies - <code>UTC</code></li> <li>Stocks - where exchange is located (e.g. for AAPL it will be <code>America/New_York</code>)</li> </ul> Both parameters take into account if <code>timezone</code> parameter is provided.<br/> If <code>timezone</code> is given then, <code>start_date</code> and <code>end_date</code> will be used in the specified location Examples: <ul> <li>1. <code>&symbol=AAPL&start_date=2019-08-09T15:50:00&…</code><br/> Returns all records starting from 2019-08-09T15:50:00 New York time up to current date</li> <li>2. <code>&symbol=EUR/USD&timezone=Asia/Singapore&start_date=2019-08-09T15:50:00&…</code><br/> Returns all records starting from 2019-08-09T15:50:00 Singapore time up to current date</li> <li>3. <code>&symbol=ETH/BTC&timezone=Europe/Zurich&start_date=2019-08-09T15:50:00&end_date=2019-08-09T15:55:00&...</code><br/> Returns all records starting from 2019-08-09T15:50:00 Zurich time up to 2019-08-09T15:55:00</li> </ul>
920 pub fn start_date(mut self, start_date: impl Into<String>) -> Self {
921 self.start_date = Some(start_date.into());
922 self
923 }
924 /// The ending date and time for data selection, see `start_date` description for details.
925 pub fn end_date(mut self, end_date: impl Into<String>) -> Self {
926 self.end_date = Some(end_date.into());
927 self
928 }
929 /// Specifies the exact date to get the data for. Could be the exact date, e.g. `2021-10-27`, or in human language `today` or `yesterday`
930 pub fn date(mut self, date: impl Into<String>) -> Self {
931 self.date = Some(date.into());
932 self
933 }
934 /// Sorting order of the output
935 pub fn order(mut self, order: impl Into<String>) -> Self {
936 self.order = Some(order.into());
937 self
938 }
939 /// Returns quotes that include pre-market and post-market data. Only for `Pro` and above plans. Available at the `1min`, `5min`, `15min`, and `30min` intervals for US equities. Open, high, low, close values are supplied without volume
940 pub fn prepost(mut self, prepost: bool) -> Self {
941 self.prepost = Some(prepost);
942 self
943 }
944 /// The format of the response data
945 pub fn format(mut self, format: impl Into<String>) -> Self {
946 self.format = Some(format.into());
947 self
948 }
949 /// The separator used in the CSV response data
950 pub fn delimiter(mut self, delimiter: impl Into<String>) -> Self {
951 self.delimiter = Some(delimiter.into());
952 self
953 }
954 /// Specifies the number of decimal places for floating values. Should be in range [0, 11] inclusive. By default, the number of decimal places is automatically determined based on the values provided
955 pub fn dp(mut self, dp: i64) -> Self {
956 self.dp = Some(dp);
957 self
958 }
959 /// A boolean parameter to include the previous closing price in the time_series data. If true, adds previous bar close price value to the current object
960 pub fn previous_close(mut self, previous_close: bool) -> Self {
961 self.previous_close = Some(previous_close);
962 self
963 }
964 /// Adjusting mode for prices
965 pub fn adjust(mut self, adjust: impl Into<String>) -> Self {
966 self.adjust = Some(adjust.into());
967 self
968 }
969
970 /// Build the parameter struct
971 pub fn build(self) -> GetTimeSeriesParams {
972 GetTimeSeriesParams {
973 interval: self.interval,
974 symbol: self.symbol,
975 isin: self.isin,
976 figi: self.figi,
977 cusip: self.cusip,
978 outputsize: self.outputsize,
979 exchange: self.exchange,
980 mic_code: self.mic_code,
981 country: self.country,
982 r#type: self.r#type,
983 timezone: self.timezone,
984 start_date: self.start_date,
985 end_date: self.end_date,
986 date: self.date,
987 order: self.order,
988 prepost: self.prepost,
989 format: self.format,
990 delimiter: self.delimiter,
991 dp: self.dp,
992 previous_close: self.previous_close,
993 adjust: self.adjust,
994 }
995 }
996}
997
998/// struct for passing parameters to the method [`get_time_series_cross`]
999#[derive(Clone, Debug, Default, Serialize, Deserialize)]
1000pub struct GetTimeSeriesCrossParams {
1001 /// Base currency symbol
1002 pub base: String,
1003 /// Quote currency symbol
1004 pub quote: String,
1005 /// Interval between two consecutive points in time series
1006 pub interval: String,
1007 /// Base instrument type according to the `/instrument_type` endpoint
1008 pub base_type: Option<String>,
1009 /// Base exchange
1010 pub base_exchange: Option<String>,
1011 /// Base MIC code
1012 pub base_mic_code: Option<String>,
1013 /// Quote instrument type according to the `/instrument_type` endpoint
1014 pub quote_type: Option<String>,
1015 /// Quote exchange
1016 pub quote_exchange: Option<String>,
1017 /// Quote MIC code
1018 pub quote_mic_code: Option<String>,
1019 /// Number of data points to retrieve. Supports values in the range from `1` to `5000`. Default `30` when no date parameters are set, otherwise set to maximum
1020 pub outputsize: Option<i64>,
1021 /// Format of the response data
1022 pub format: Option<String>,
1023 /// Delimiter used in CSV file
1024 pub delimiter: Option<String>,
1025 /// Only for `Pro` and above plans. Available at the `1min`, `5min`, `15min`, and `30min` intervals for US equities. Open, high, low, close values are supplied without volume.
1026 pub prepost: Option<bool>,
1027 /// Start date for the time series data
1028 pub start_date: Option<String>,
1029 /// End date for the time series data
1030 pub end_date: Option<String>,
1031 /// Specifies if there should be an adjustment
1032 pub adjust: Option<bool>,
1033 /// Specifies the number of decimal places for floating values. Should be in range [0, 11] inclusive.
1034 pub dp: Option<i64>,
1035 /// Timezone at which output datetime will be displayed. Supports: <ul> <li>1. <code>Exchange</code> for local exchange time</li> <li>2. <code>UTC</code> for datetime at universal UTC standard</li> <li>3. Timezone name according to the IANA Time Zone Database. E.g. <code>America/New_York</code>, <code>Asia/Singapore</code>. Full list of timezones can be found <a href=\"https://en.wikipedia.org/wiki/List_of_tz_database_time_zones\" target=\"blank\">here</a>.</li> </ul> <i>Take note that the IANA Timezone name is case-sensitive</i>
1036 pub timezone: Option<String>,
1037}
1038
1039impl GetTimeSeriesCrossParams {
1040 /// Create a new builder for this parameter struct
1041 pub fn builder() -> GetTimeSeriesCrossParamsBuilder {
1042 GetTimeSeriesCrossParamsBuilder::default()
1043 }
1044}
1045
1046/// Builder for [`GetTimeSeriesCrossParams`]
1047#[derive(Clone, Debug, Default)]
1048pub struct GetTimeSeriesCrossParamsBuilder {
1049 /// Base currency symbol
1050 base: String,
1051 /// Quote currency symbol
1052 quote: String,
1053 /// Interval between two consecutive points in time series
1054 interval: String,
1055 /// Base instrument type according to the `/instrument_type` endpoint
1056 base_type: Option<String>,
1057 /// Base exchange
1058 base_exchange: Option<String>,
1059 /// Base MIC code
1060 base_mic_code: Option<String>,
1061 /// Quote instrument type according to the `/instrument_type` endpoint
1062 quote_type: Option<String>,
1063 /// Quote exchange
1064 quote_exchange: Option<String>,
1065 /// Quote MIC code
1066 quote_mic_code: Option<String>,
1067 /// Number of data points to retrieve. Supports values in the range from `1` to `5000`. Default `30` when no date parameters are set, otherwise set to maximum
1068 outputsize: Option<i64>,
1069 /// Format of the response data
1070 format: Option<String>,
1071 /// Delimiter used in CSV file
1072 delimiter: Option<String>,
1073 /// Only for `Pro` and above plans. Available at the `1min`, `5min`, `15min`, and `30min` intervals for US equities. Open, high, low, close values are supplied without volume.
1074 prepost: Option<bool>,
1075 /// Start date for the time series data
1076 start_date: Option<String>,
1077 /// End date for the time series data
1078 end_date: Option<String>,
1079 /// Specifies if there should be an adjustment
1080 adjust: Option<bool>,
1081 /// Specifies the number of decimal places for floating values. Should be in range [0, 11] inclusive.
1082 dp: Option<i64>,
1083 /// Timezone at which output datetime will be displayed. Supports: <ul> <li>1. <code>Exchange</code> for local exchange time</li> <li>2. <code>UTC</code> for datetime at universal UTC standard</li> <li>3. Timezone name according to the IANA Time Zone Database. E.g. <code>America/New_York</code>, <code>Asia/Singapore</code>. Full list of timezones can be found <a href=\"https://en.wikipedia.org/wiki/List_of_tz_database_time_zones\" target=\"blank\">here</a>.</li> </ul> <i>Take note that the IANA Timezone name is case-sensitive</i>
1084 timezone: Option<String>,
1085}
1086
1087impl GetTimeSeriesCrossParamsBuilder {
1088 /// Base currency symbol
1089 pub fn base(mut self, base: impl Into<String>) -> Self {
1090 self.base = base.into();
1091 self
1092 }
1093 /// Quote currency symbol
1094 pub fn quote(mut self, quote: impl Into<String>) -> Self {
1095 self.quote = quote.into();
1096 self
1097 }
1098 /// Interval between two consecutive points in time series
1099 pub fn interval(mut self, interval: impl Into<String>) -> Self {
1100 self.interval = interval.into();
1101 self
1102 }
1103 /// Base instrument type according to the `/instrument_type` endpoint
1104 pub fn base_type(mut self, base_type: impl Into<String>) -> Self {
1105 self.base_type = Some(base_type.into());
1106 self
1107 }
1108 /// Base exchange
1109 pub fn base_exchange(mut self, base_exchange: impl Into<String>) -> Self {
1110 self.base_exchange = Some(base_exchange.into());
1111 self
1112 }
1113 /// Base MIC code
1114 pub fn base_mic_code(mut self, base_mic_code: impl Into<String>) -> Self {
1115 self.base_mic_code = Some(base_mic_code.into());
1116 self
1117 }
1118 /// Quote instrument type according to the `/instrument_type` endpoint
1119 pub fn quote_type(mut self, quote_type: impl Into<String>) -> Self {
1120 self.quote_type = Some(quote_type.into());
1121 self
1122 }
1123 /// Quote exchange
1124 pub fn quote_exchange(mut self, quote_exchange: impl Into<String>) -> Self {
1125 self.quote_exchange = Some(quote_exchange.into());
1126 self
1127 }
1128 /// Quote MIC code
1129 pub fn quote_mic_code(mut self, quote_mic_code: impl Into<String>) -> Self {
1130 self.quote_mic_code = Some(quote_mic_code.into());
1131 self
1132 }
1133 /// Number of data points to retrieve. Supports values in the range from `1` to `5000`. Default `30` when no date parameters are set, otherwise set to maximum
1134 pub fn outputsize(mut self, outputsize: i64) -> Self {
1135 self.outputsize = Some(outputsize);
1136 self
1137 }
1138 /// Format of the response data
1139 pub fn format(mut self, format: impl Into<String>) -> Self {
1140 self.format = Some(format.into());
1141 self
1142 }
1143 /// Delimiter used in CSV file
1144 pub fn delimiter(mut self, delimiter: impl Into<String>) -> Self {
1145 self.delimiter = Some(delimiter.into());
1146 self
1147 }
1148 /// Only for `Pro` and above plans. Available at the `1min`, `5min`, `15min`, and `30min` intervals for US equities. Open, high, low, close values are supplied without volume.
1149 pub fn prepost(mut self, prepost: bool) -> Self {
1150 self.prepost = Some(prepost);
1151 self
1152 }
1153 /// Start date for the time series data
1154 pub fn start_date(mut self, start_date: impl Into<String>) -> Self {
1155 self.start_date = Some(start_date.into());
1156 self
1157 }
1158 /// End date for the time series data
1159 pub fn end_date(mut self, end_date: impl Into<String>) -> Self {
1160 self.end_date = Some(end_date.into());
1161 self
1162 }
1163 /// Specifies if there should be an adjustment
1164 pub fn adjust(mut self, adjust: bool) -> Self {
1165 self.adjust = Some(adjust);
1166 self
1167 }
1168 /// Specifies the number of decimal places for floating values. Should be in range [0, 11] inclusive.
1169 pub fn dp(mut self, dp: i64) -> Self {
1170 self.dp = Some(dp);
1171 self
1172 }
1173 /// Timezone at which output datetime will be displayed. Supports: <ul> <li>1. <code>Exchange</code> for local exchange time</li> <li>2. <code>UTC</code> for datetime at universal UTC standard</li> <li>3. Timezone name according to the IANA Time Zone Database. E.g. <code>America/New_York</code>, <code>Asia/Singapore</code>. Full list of timezones can be found <a href=\"https://en.wikipedia.org/wiki/List_of_tz_database_time_zones\" target=\"blank\">here</a>.</li> </ul> <i>Take note that the IANA Timezone name is case-sensitive</i>
1174 pub fn timezone(mut self, timezone: impl Into<String>) -> Self {
1175 self.timezone = Some(timezone.into());
1176 self
1177 }
1178
1179 /// Build the parameter struct
1180 pub fn build(self) -> GetTimeSeriesCrossParams {
1181 GetTimeSeriesCrossParams {
1182 base: self.base,
1183 quote: self.quote,
1184 interval: self.interval,
1185 base_type: self.base_type,
1186 base_exchange: self.base_exchange,
1187 base_mic_code: self.base_mic_code,
1188 quote_type: self.quote_type,
1189 quote_exchange: self.quote_exchange,
1190 quote_mic_code: self.quote_mic_code,
1191 outputsize: self.outputsize,
1192 format: self.format,
1193 delimiter: self.delimiter,
1194 prepost: self.prepost,
1195 start_date: self.start_date,
1196 end_date: self.end_date,
1197 adjust: self.adjust,
1198 dp: self.dp,
1199 timezone: self.timezone,
1200 }
1201 }
1202}
1203
1204/// struct for typed errors of method [`get_currency_conversion`]
1205#[derive(Debug, Clone, Serialize, Deserialize)]
1206#[serde(untagged)]
1207pub enum GetCurrencyConversionError {
1208 UnknownValue(serde_json::Value),
1209}
1210
1211/// struct for typed errors of method [`get_eod`]
1212#[derive(Debug, Clone, Serialize, Deserialize)]
1213#[serde(untagged)]
1214pub enum GetEodError {
1215 UnknownValue(serde_json::Value),
1216}
1217
1218/// struct for typed errors of method [`get_exchange_rate`]
1219#[derive(Debug, Clone, Serialize, Deserialize)]
1220#[serde(untagged)]
1221pub enum GetExchangeRateError {
1222 UnknownValue(serde_json::Value),
1223}
1224
1225/// struct for typed errors of method [`get_market_movers`]
1226#[derive(Debug, Clone, Serialize, Deserialize)]
1227#[serde(untagged)]
1228pub enum GetMarketMoversError {
1229 UnknownValue(serde_json::Value),
1230}
1231
1232/// struct for typed errors of method [`get_price`]
1233#[derive(Debug, Clone, Serialize, Deserialize)]
1234#[serde(untagged)]
1235pub enum GetPriceError {
1236 UnknownValue(serde_json::Value),
1237}
1238
1239/// struct for typed errors of method [`get_quote`]
1240#[derive(Debug, Clone, Serialize, Deserialize)]
1241#[serde(untagged)]
1242pub enum GetQuoteError {
1243 UnknownValue(serde_json::Value),
1244}
1245
1246/// struct for typed errors of method [`get_time_series`]
1247#[derive(Debug, Clone, Serialize, Deserialize)]
1248#[serde(untagged)]
1249pub enum GetTimeSeriesError {
1250 UnknownValue(serde_json::Value),
1251}
1252
1253/// struct for typed errors of method [`get_time_series_cross`]
1254#[derive(Debug, Clone, Serialize, Deserialize)]
1255#[serde(untagged)]
1256pub enum GetTimeSeriesCrossError {
1257 UnknownValue(serde_json::Value),
1258}
1259
1260/// The currency conversion endpoint provides real-time exchange rates and calculates the converted amount for specified currency pairs, including both forex and cryptocurrencies. This endpoint is useful for obtaining up-to-date conversion values between two currencies, facilitating tasks such as financial reporting, e-commerce transactions, and travel budgeting.
1261pub async fn get_currency_conversion(
1262 configuration: &configuration::Configuration,
1263 params: GetCurrencyConversionParams,
1264) -> Result<models::GetCurrencyConversionResponse, Error<GetCurrencyConversionError>> {
1265 // Extract parameters from params struct
1266 let p_query_symbol = params.symbol;
1267 let p_query_amount = params.amount;
1268 let p_query_date = params.date;
1269 let p_query_format = params.format;
1270 let p_query_delimiter = params.delimiter;
1271 let p_query_dp = params.dp;
1272 let p_query_timezone = params.timezone;
1273
1274 let uri_str = format!("{}/currency_conversion", configuration.base_path);
1275 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1276
1277 req_builder = req_builder.query(&[("symbol", &p_query_symbol.to_string())]);
1278 req_builder = req_builder.query(&[("amount", &p_query_amount.to_string())]);
1279 if let Some(ref param_value) = p_query_date {
1280 req_builder = req_builder.query(&[("date", ¶m_value.to_string())]);
1281 }
1282 if let Some(ref param_value) = p_query_format {
1283 req_builder = req_builder.query(&[("format", ¶m_value.to_string())]);
1284 }
1285 if let Some(ref param_value) = p_query_delimiter {
1286 req_builder = req_builder.query(&[("delimiter", ¶m_value.to_string())]);
1287 }
1288 if let Some(ref param_value) = p_query_dp {
1289 req_builder = req_builder.query(&[("dp", ¶m_value.to_string())]);
1290 }
1291 if let Some(ref param_value) = p_query_timezone {
1292 req_builder = req_builder.query(&[("timezone", ¶m_value.to_string())]);
1293 }
1294 if let Some(ref user_agent) = configuration.user_agent {
1295 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1296 }
1297 if let Some(ref apikey) = configuration.api_key {
1298 let key = apikey.key.clone();
1299 let value = match apikey.prefix {
1300 Some(ref prefix) => format!("{} {}", prefix, key),
1301 None => key,
1302 };
1303 req_builder = req_builder.header("Authorization", value);
1304 };
1305
1306 let req = req_builder.build()?;
1307 let resp = configuration.client.execute(req).await?;
1308
1309 let status = resp.status();
1310 let content_type = resp
1311 .headers()
1312 .get("content-type")
1313 .and_then(|v| v.to_str().ok())
1314 .unwrap_or("application/octet-stream");
1315 let content_type = super::ContentType::from(content_type);
1316
1317 if !status.is_client_error() && !status.is_server_error() {
1318 let content = resp.text().await?;
1319 match content_type {
1320 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1321 ContentType::Text => return Ok(models::GetCurrencyConversionResponse::Text(content)),
1322 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetCurrencyConversionResponse`")))),
1323 }
1324 } else {
1325 let content = resp.text().await?;
1326 let entity: Option<GetCurrencyConversionError> = serde_json::from_str(&content).ok();
1327 Err(Error::ResponseError(ResponseContent {
1328 status,
1329 content,
1330 entity,
1331 }))
1332 }
1333}
1334
1335/// The End of Day (EOD) Prices endpoint provides the closing price and other relevant metadata for a financial instrument at the end of a trading day. This endpoint is useful for retrieving daily historical data for stocks, ETFs, or other securities, allowing users to track performance over time and compare daily market movements.
1336pub async fn get_eod(
1337 configuration: &configuration::Configuration,
1338 params: GetEodParams,
1339) -> Result<models::GetEodResponse, Error<GetEodError>> {
1340 // Extract parameters from params struct
1341 let p_query_symbol = params.symbol;
1342 let p_query_figi = params.figi;
1343 let p_query_isin = params.isin;
1344 let p_query_cusip = params.cusip;
1345 let p_query_exchange = params.exchange;
1346 let p_query_mic_code = params.mic_code;
1347 let p_query_country = params.country;
1348 let p_query_type = params.r#type;
1349 let p_query_date = params.date;
1350 let p_query_prepost = params.prepost;
1351 let p_query_dp = params.dp;
1352
1353 let uri_str = format!("{}/eod", configuration.base_path);
1354 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1355
1356 if let Some(ref param_value) = p_query_symbol {
1357 req_builder = req_builder.query(&[("symbol", ¶m_value.to_string())]);
1358 }
1359 if let Some(ref param_value) = p_query_figi {
1360 req_builder = req_builder.query(&[("figi", ¶m_value.to_string())]);
1361 }
1362 if let Some(ref param_value) = p_query_isin {
1363 req_builder = req_builder.query(&[("isin", ¶m_value.to_string())]);
1364 }
1365 if let Some(ref param_value) = p_query_cusip {
1366 req_builder = req_builder.query(&[("cusip", ¶m_value.to_string())]);
1367 }
1368 if let Some(ref param_value) = p_query_exchange {
1369 req_builder = req_builder.query(&[("exchange", ¶m_value.to_string())]);
1370 }
1371 if let Some(ref param_value) = p_query_mic_code {
1372 req_builder = req_builder.query(&[("mic_code", ¶m_value.to_string())]);
1373 }
1374 if let Some(ref param_value) = p_query_country {
1375 req_builder = req_builder.query(&[("country", ¶m_value.to_string())]);
1376 }
1377 if let Some(ref param_value) = p_query_type {
1378 req_builder = req_builder.query(&[("type", ¶m_value.to_string())]);
1379 }
1380 if let Some(ref param_value) = p_query_date {
1381 req_builder = req_builder.query(&[("date", ¶m_value.to_string())]);
1382 }
1383 if let Some(ref param_value) = p_query_prepost {
1384 req_builder = req_builder.query(&[("prepost", ¶m_value.to_string())]);
1385 }
1386 if let Some(ref param_value) = p_query_dp {
1387 req_builder = req_builder.query(&[("dp", ¶m_value.to_string())]);
1388 }
1389 if let Some(ref user_agent) = configuration.user_agent {
1390 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1391 }
1392 if let Some(ref apikey) = configuration.api_key {
1393 let key = apikey.key.clone();
1394 let value = match apikey.prefix {
1395 Some(ref prefix) => format!("{} {}", prefix, key),
1396 None => key,
1397 };
1398 req_builder = req_builder.header("Authorization", value);
1399 };
1400
1401 let req = req_builder.build()?;
1402 let resp = configuration.client.execute(req).await?;
1403
1404 let status = resp.status();
1405 let content_type = resp
1406 .headers()
1407 .get("content-type")
1408 .and_then(|v| v.to_str().ok())
1409 .unwrap_or("application/octet-stream");
1410 let content_type = super::ContentType::from(content_type);
1411
1412 if !status.is_client_error() && !status.is_server_error() {
1413 let content = resp.text().await?;
1414 match content_type {
1415 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1416 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/*` content type response that cannot be converted to `models::GetEodResponse`"))),
1417 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetEodResponse`")))),
1418 }
1419 } else {
1420 let content = resp.text().await?;
1421 let entity: Option<GetEodError> = serde_json::from_str(&content).ok();
1422 Err(Error::ResponseError(ResponseContent {
1423 status,
1424 content,
1425 entity,
1426 }))
1427 }
1428}
1429
1430/// The exchange rate endpoint provides real-time exchange rates for specified currency pairs, including both forex and cryptocurrency. It returns the current exchange rate value between two currencies, allowing users to quickly access up-to-date conversion rates for financial transactions or market analysis.
1431pub async fn get_exchange_rate(
1432 configuration: &configuration::Configuration,
1433 params: GetExchangeRateParams,
1434) -> Result<models::GetExchangeRateResponse, Error<GetExchangeRateError>> {
1435 // Extract parameters from params struct
1436 let p_query_symbol = params.symbol;
1437 let p_query_date = params.date;
1438 let p_query_format = params.format;
1439 let p_query_delimiter = params.delimiter;
1440 let p_query_dp = params.dp;
1441 let p_query_timezone = params.timezone;
1442
1443 let uri_str = format!("{}/exchange_rate", configuration.base_path);
1444 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1445
1446 req_builder = req_builder.query(&[("symbol", &p_query_symbol.to_string())]);
1447 if let Some(ref param_value) = p_query_date {
1448 req_builder = req_builder.query(&[("date", ¶m_value.to_string())]);
1449 }
1450 if let Some(ref param_value) = p_query_format {
1451 req_builder = req_builder.query(&[("format", ¶m_value.to_string())]);
1452 }
1453 if let Some(ref param_value) = p_query_delimiter {
1454 req_builder = req_builder.query(&[("delimiter", ¶m_value.to_string())]);
1455 }
1456 if let Some(ref param_value) = p_query_dp {
1457 req_builder = req_builder.query(&[("dp", ¶m_value.to_string())]);
1458 }
1459 if let Some(ref param_value) = p_query_timezone {
1460 req_builder = req_builder.query(&[("timezone", ¶m_value.to_string())]);
1461 }
1462 if let Some(ref user_agent) = configuration.user_agent {
1463 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1464 }
1465 if let Some(ref apikey) = configuration.api_key {
1466 let key = apikey.key.clone();
1467 let value = match apikey.prefix {
1468 Some(ref prefix) => format!("{} {}", prefix, key),
1469 None => key,
1470 };
1471 req_builder = req_builder.header("Authorization", value);
1472 };
1473
1474 let req = req_builder.build()?;
1475 let resp = configuration.client.execute(req).await?;
1476
1477 let status = resp.status();
1478 let content_type = resp
1479 .headers()
1480 .get("content-type")
1481 .and_then(|v| v.to_str().ok())
1482 .unwrap_or("application/octet-stream");
1483 let content_type = super::ContentType::from(content_type);
1484
1485 if !status.is_client_error() && !status.is_server_error() {
1486 let content = resp.text().await?;
1487 match content_type {
1488 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1489 ContentType::Text => return Ok(models::GetExchangeRateResponse::Text(content)),
1490 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetExchangeRateResponse`")))),
1491 }
1492 } else {
1493 let content = resp.text().await?;
1494 let entity: Option<GetExchangeRateError> = serde_json::from_str(&content).ok();
1495 Err(Error::ResponseError(ResponseContent {
1496 status,
1497 content,
1498 entity,
1499 }))
1500 }
1501}
1502
1503/// The market movers endpoint provides a ranked list of the top-gaining and losing assets for the current trading day. It returns detailed data on the highest percentage price increases and decreases since the previous day's close. This endpoint supports international equities, forex, and cryptocurrencies, enabling users to quickly identify significant market movements across various asset classes.
1504pub async fn get_market_movers(
1505 configuration: &configuration::Configuration,
1506 params: GetMarketMoversParams,
1507) -> Result<models::GetMarketMoversResponse, Error<GetMarketMoversError>> {
1508 // Extract parameters from params struct
1509 let p_path_market = params.market;
1510 let p_query_direction = params.direction;
1511 let p_query_outputsize = params.outputsize;
1512 let p_query_country = params.country;
1513 let p_query_price_greater_than = params.price_greater_than;
1514 let p_query_dp = params.dp;
1515
1516 let uri_str = format!(
1517 "{}/market_movers/{market}",
1518 configuration.base_path,
1519 market = crate::apis::urlencode(p_path_market)
1520 );
1521 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1522
1523 if let Some(ref param_value) = p_query_direction {
1524 req_builder = req_builder.query(&[("direction", ¶m_value.to_string())]);
1525 }
1526 if let Some(ref param_value) = p_query_outputsize {
1527 req_builder = req_builder.query(&[("outputsize", ¶m_value.to_string())]);
1528 }
1529 if let Some(ref param_value) = p_query_country {
1530 req_builder = req_builder.query(&[("country", ¶m_value.to_string())]);
1531 }
1532 if let Some(ref param_value) = p_query_price_greater_than {
1533 req_builder = req_builder.query(&[("price_greater_than", ¶m_value.to_string())]);
1534 }
1535 if let Some(ref param_value) = p_query_dp {
1536 req_builder = req_builder.query(&[("dp", ¶m_value.to_string())]);
1537 }
1538 if let Some(ref user_agent) = configuration.user_agent {
1539 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1540 }
1541 if let Some(ref apikey) = configuration.api_key {
1542 let key = apikey.key.clone();
1543 let value = match apikey.prefix {
1544 Some(ref prefix) => format!("{} {}", prefix, key),
1545 None => key,
1546 };
1547 req_builder = req_builder.header("Authorization", value);
1548 };
1549
1550 let req = req_builder.build()?;
1551 let resp = configuration.client.execute(req).await?;
1552
1553 let status = resp.status();
1554 let content_type = resp
1555 .headers()
1556 .get("content-type")
1557 .and_then(|v| v.to_str().ok())
1558 .unwrap_or("application/octet-stream");
1559 let content_type = super::ContentType::from(content_type);
1560
1561 if !status.is_client_error() && !status.is_server_error() {
1562 let content = resp.text().await?;
1563 match content_type {
1564 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1565 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/*` content type response that cannot be converted to `models::GetMarketMoversResponse`"))),
1566 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetMarketMoversResponse`")))),
1567 }
1568 } else {
1569 let content = resp.text().await?;
1570 let entity: Option<GetMarketMoversError> = serde_json::from_str(&content).ok();
1571 Err(Error::ResponseError(ResponseContent {
1572 status,
1573 content,
1574 entity,
1575 }))
1576 }
1577}
1578
1579/// The latest price endpoint provides the latest market price for a specified financial instrument. It returns a single data point representing the current (or the most recently available) trading price.
1580pub async fn get_price(
1581 configuration: &configuration::Configuration,
1582 params: GetPriceParams,
1583) -> Result<models::GetPriceResponse, Error<GetPriceError>> {
1584 // Extract parameters from params struct
1585 let p_query_symbol = params.symbol;
1586 let p_query_figi = params.figi;
1587 let p_query_isin = params.isin;
1588 let p_query_cusip = params.cusip;
1589 let p_query_exchange = params.exchange;
1590 let p_query_mic_code = params.mic_code;
1591 let p_query_country = params.country;
1592 let p_query_type = params.r#type;
1593 let p_query_format = params.format;
1594 let p_query_delimiter = params.delimiter;
1595 let p_query_prepost = params.prepost;
1596 let p_query_dp = params.dp;
1597
1598 let uri_str = format!("{}/price", configuration.base_path);
1599 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1600
1601 if let Some(ref param_value) = p_query_symbol {
1602 req_builder = req_builder.query(&[("symbol", ¶m_value.to_string())]);
1603 }
1604 if let Some(ref param_value) = p_query_figi {
1605 req_builder = req_builder.query(&[("figi", ¶m_value.to_string())]);
1606 }
1607 if let Some(ref param_value) = p_query_isin {
1608 req_builder = req_builder.query(&[("isin", ¶m_value.to_string())]);
1609 }
1610 if let Some(ref param_value) = p_query_cusip {
1611 req_builder = req_builder.query(&[("cusip", ¶m_value.to_string())]);
1612 }
1613 if let Some(ref param_value) = p_query_exchange {
1614 req_builder = req_builder.query(&[("exchange", ¶m_value.to_string())]);
1615 }
1616 if let Some(ref param_value) = p_query_mic_code {
1617 req_builder = req_builder.query(&[("mic_code", ¶m_value.to_string())]);
1618 }
1619 if let Some(ref param_value) = p_query_country {
1620 req_builder = req_builder.query(&[("country", ¶m_value.to_string())]);
1621 }
1622 if let Some(ref param_value) = p_query_type {
1623 req_builder = req_builder.query(&[("type", ¶m_value.to_string())]);
1624 }
1625 if let Some(ref param_value) = p_query_format {
1626 req_builder = req_builder.query(&[("format", ¶m_value.to_string())]);
1627 }
1628 if let Some(ref param_value) = p_query_delimiter {
1629 req_builder = req_builder.query(&[("delimiter", ¶m_value.to_string())]);
1630 }
1631 if let Some(ref param_value) = p_query_prepost {
1632 req_builder = req_builder.query(&[("prepost", ¶m_value.to_string())]);
1633 }
1634 if let Some(ref param_value) = p_query_dp {
1635 req_builder = req_builder.query(&[("dp", ¶m_value.to_string())]);
1636 }
1637 if let Some(ref user_agent) = configuration.user_agent {
1638 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1639 }
1640 if let Some(ref apikey) = configuration.api_key {
1641 let key = apikey.key.clone();
1642 let value = match apikey.prefix {
1643 Some(ref prefix) => format!("{} {}", prefix, key),
1644 None => key,
1645 };
1646 req_builder = req_builder.header("Authorization", value);
1647 };
1648
1649 let req = req_builder.build()?;
1650 let resp = configuration.client.execute(req).await?;
1651
1652 let status = resp.status();
1653 let content_type = resp
1654 .headers()
1655 .get("content-type")
1656 .and_then(|v| v.to_str().ok())
1657 .unwrap_or("application/octet-stream");
1658 let content_type = super::ContentType::from(content_type);
1659
1660 if !status.is_client_error() && !status.is_server_error() {
1661 let content = resp.text().await?;
1662 match content_type {
1663 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1664 ContentType::Text => return Ok(models::GetPriceResponse::Text(content)),
1665 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetPriceResponse`")))),
1666 }
1667 } else {
1668 let content = resp.text().await?;
1669 let entity: Option<GetPriceError> = serde_json::from_str(&content).ok();
1670 Err(Error::ResponseError(ResponseContent {
1671 status,
1672 content,
1673 entity,
1674 }))
1675 }
1676}
1677
1678/// The quote endpoint provides real-time data for a selected financial instrument, returning essential information such as the latest price, open, high, low, close, volume, and price change. This endpoint is ideal for users needing up-to-date market data to track price movements and trading activity for specific stocks, ETFs, or other securities.
1679pub async fn get_quote(
1680 configuration: &configuration::Configuration,
1681 params: GetQuoteParams,
1682) -> Result<models::GetQuoteResponse, Error<GetQuoteError>> {
1683 // Extract parameters from params struct
1684 let p_query_symbol = params.symbol;
1685 let p_query_figi = params.figi;
1686 let p_query_isin = params.isin;
1687 let p_query_cusip = params.cusip;
1688 let p_query_interval = params.interval;
1689 let p_query_exchange = params.exchange;
1690 let p_query_mic_code = params.mic_code;
1691 let p_query_country = params.country;
1692 let p_query_volume_time_period = params.volume_time_period;
1693 let p_query_type = params.r#type;
1694 let p_query_format = params.format;
1695 let p_query_delimiter = params.delimiter;
1696 let p_query_prepost = params.prepost;
1697 let p_query_eod = params.eod;
1698 let p_query_rolling_period = params.rolling_period;
1699 let p_query_dp = params.dp;
1700 let p_query_timezone = params.timezone;
1701
1702 let uri_str = format!("{}/quote", configuration.base_path);
1703 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1704
1705 if let Some(ref param_value) = p_query_symbol {
1706 req_builder = req_builder.query(&[("symbol", ¶m_value.to_string())]);
1707 }
1708 if let Some(ref param_value) = p_query_figi {
1709 req_builder = req_builder.query(&[("figi", ¶m_value.to_string())]);
1710 }
1711 if let Some(ref param_value) = p_query_isin {
1712 req_builder = req_builder.query(&[("isin", ¶m_value.to_string())]);
1713 }
1714 if let Some(ref param_value) = p_query_cusip {
1715 req_builder = req_builder.query(&[("cusip", ¶m_value.to_string())]);
1716 }
1717 if let Some(ref param_value) = p_query_interval {
1718 req_builder = req_builder.query(&[("interval", ¶m_value.to_string())]);
1719 }
1720 if let Some(ref param_value) = p_query_exchange {
1721 req_builder = req_builder.query(&[("exchange", ¶m_value.to_string())]);
1722 }
1723 if let Some(ref param_value) = p_query_mic_code {
1724 req_builder = req_builder.query(&[("mic_code", ¶m_value.to_string())]);
1725 }
1726 if let Some(ref param_value) = p_query_country {
1727 req_builder = req_builder.query(&[("country", ¶m_value.to_string())]);
1728 }
1729 if let Some(ref param_value) = p_query_volume_time_period {
1730 req_builder = req_builder.query(&[("volume_time_period", ¶m_value.to_string())]);
1731 }
1732 if let Some(ref param_value) = p_query_type {
1733 req_builder = req_builder.query(&[("type", ¶m_value.to_string())]);
1734 }
1735 if let Some(ref param_value) = p_query_format {
1736 req_builder = req_builder.query(&[("format", ¶m_value.to_string())]);
1737 }
1738 if let Some(ref param_value) = p_query_delimiter {
1739 req_builder = req_builder.query(&[("delimiter", ¶m_value.to_string())]);
1740 }
1741 if let Some(ref param_value) = p_query_prepost {
1742 req_builder = req_builder.query(&[("prepost", ¶m_value.to_string())]);
1743 }
1744 if let Some(ref param_value) = p_query_eod {
1745 req_builder = req_builder.query(&[("eod", ¶m_value.to_string())]);
1746 }
1747 if let Some(ref param_value) = p_query_rolling_period {
1748 req_builder = req_builder.query(&[("rolling_period", ¶m_value.to_string())]);
1749 }
1750 if let Some(ref param_value) = p_query_dp {
1751 req_builder = req_builder.query(&[("dp", ¶m_value.to_string())]);
1752 }
1753 if let Some(ref param_value) = p_query_timezone {
1754 req_builder = req_builder.query(&[("timezone", ¶m_value.to_string())]);
1755 }
1756 if let Some(ref user_agent) = configuration.user_agent {
1757 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1758 }
1759 if let Some(ref apikey) = configuration.api_key {
1760 let key = apikey.key.clone();
1761 let value = match apikey.prefix {
1762 Some(ref prefix) => format!("{} {}", prefix, key),
1763 None => key,
1764 };
1765 req_builder = req_builder.header("Authorization", value);
1766 };
1767
1768 let req = req_builder.build()?;
1769 let resp = configuration.client.execute(req).await?;
1770
1771 let status = resp.status();
1772 let content_type = resp
1773 .headers()
1774 .get("content-type")
1775 .and_then(|v| v.to_str().ok())
1776 .unwrap_or("application/octet-stream");
1777 let content_type = super::ContentType::from(content_type);
1778
1779 if !status.is_client_error() && !status.is_server_error() {
1780 let content = resp.text().await?;
1781 match content_type {
1782 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1783 ContentType::Text => return Ok(models::GetQuoteResponse::Text(content)),
1784 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetQuoteResponse`")))),
1785 }
1786 } else {
1787 let content = resp.text().await?;
1788 let entity: Option<GetQuoteError> = serde_json::from_str(&content).ok();
1789 Err(Error::ResponseError(ResponseContent {
1790 status,
1791 content,
1792 entity,
1793 }))
1794 }
1795}
1796
1797/// The time series endpoint provides detailed historical data for a specified financial instrument. It returns two main components: metadata, which includes essential information about the instrument, and a time series dataset. The time series consists of chronological entries with Open, High, Low, and Close prices, and for applicable instruments, it also includes trading volume. This endpoint is ideal for retrieving comprehensive historical price data for analysis or visualization purposes.
1798pub async fn get_time_series(
1799 configuration: &configuration::Configuration,
1800 params: GetTimeSeriesParams,
1801) -> Result<models::GetTimeSeriesResponse, Error<GetTimeSeriesError>> {
1802 // Extract parameters from params struct
1803 let p_query_interval = params.interval;
1804 let p_query_symbol = params.symbol;
1805 let p_query_isin = params.isin;
1806 let p_query_figi = params.figi;
1807 let p_query_cusip = params.cusip;
1808 let p_query_outputsize = params.outputsize;
1809 let p_query_exchange = params.exchange;
1810 let p_query_mic_code = params.mic_code;
1811 let p_query_country = params.country;
1812 let p_query_type = params.r#type;
1813 let p_query_timezone = params.timezone;
1814 let p_query_start_date = params.start_date;
1815 let p_query_end_date = params.end_date;
1816 let p_query_date = params.date;
1817 let p_query_order = params.order;
1818 let p_query_prepost = params.prepost;
1819 let p_query_format = params.format;
1820 let p_query_delimiter = params.delimiter;
1821 let p_query_dp = params.dp;
1822 let p_query_previous_close = params.previous_close;
1823 let p_query_adjust = params.adjust;
1824
1825 let uri_str = format!("{}/time_series", configuration.base_path);
1826 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1827
1828 if let Some(ref param_value) = p_query_symbol {
1829 req_builder = req_builder.query(&[("symbol", ¶m_value.to_string())]);
1830 }
1831 if let Some(ref param_value) = p_query_isin {
1832 req_builder = req_builder.query(&[("isin", ¶m_value.to_string())]);
1833 }
1834 if let Some(ref param_value) = p_query_figi {
1835 req_builder = req_builder.query(&[("figi", ¶m_value.to_string())]);
1836 }
1837 if let Some(ref param_value) = p_query_cusip {
1838 req_builder = req_builder.query(&[("cusip", ¶m_value.to_string())]);
1839 }
1840 req_builder = req_builder.query(&[("interval", &p_query_interval.to_string())]);
1841 if let Some(ref param_value) = p_query_outputsize {
1842 req_builder = req_builder.query(&[("outputsize", ¶m_value.to_string())]);
1843 }
1844 if let Some(ref param_value) = p_query_exchange {
1845 req_builder = req_builder.query(&[("exchange", ¶m_value.to_string())]);
1846 }
1847 if let Some(ref param_value) = p_query_mic_code {
1848 req_builder = req_builder.query(&[("mic_code", ¶m_value.to_string())]);
1849 }
1850 if let Some(ref param_value) = p_query_country {
1851 req_builder = req_builder.query(&[("country", ¶m_value.to_string())]);
1852 }
1853 if let Some(ref param_value) = p_query_type {
1854 req_builder = req_builder.query(&[("type", ¶m_value.to_string())]);
1855 }
1856 if let Some(ref param_value) = p_query_timezone {
1857 req_builder = req_builder.query(&[("timezone", ¶m_value.to_string())]);
1858 }
1859 if let Some(ref param_value) = p_query_start_date {
1860 req_builder = req_builder.query(&[("start_date", ¶m_value.to_string())]);
1861 }
1862 if let Some(ref param_value) = p_query_end_date {
1863 req_builder = req_builder.query(&[("end_date", ¶m_value.to_string())]);
1864 }
1865 if let Some(ref param_value) = p_query_date {
1866 req_builder = req_builder.query(&[("date", ¶m_value.to_string())]);
1867 }
1868 if let Some(ref param_value) = p_query_order {
1869 req_builder = req_builder.query(&[("order", ¶m_value.to_string())]);
1870 }
1871 if let Some(ref param_value) = p_query_prepost {
1872 req_builder = req_builder.query(&[("prepost", ¶m_value.to_string())]);
1873 }
1874 if let Some(ref param_value) = p_query_format {
1875 req_builder = req_builder.query(&[("format", ¶m_value.to_string())]);
1876 }
1877 if let Some(ref param_value) = p_query_delimiter {
1878 req_builder = req_builder.query(&[("delimiter", ¶m_value.to_string())]);
1879 }
1880 if let Some(ref param_value) = p_query_dp {
1881 req_builder = req_builder.query(&[("dp", ¶m_value.to_string())]);
1882 }
1883 if let Some(ref param_value) = p_query_previous_close {
1884 req_builder = req_builder.query(&[("previous_close", ¶m_value.to_string())]);
1885 }
1886 if let Some(ref param_value) = p_query_adjust {
1887 req_builder = req_builder.query(&[("adjust", ¶m_value.to_string())]);
1888 }
1889 if let Some(ref user_agent) = configuration.user_agent {
1890 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1891 }
1892 if let Some(ref apikey) = configuration.api_key {
1893 let key = apikey.key.clone();
1894 let value = match apikey.prefix {
1895 Some(ref prefix) => format!("{} {}", prefix, key),
1896 None => key,
1897 };
1898 req_builder = req_builder.header("Authorization", value);
1899 };
1900
1901 let req = req_builder.build()?;
1902 let resp = configuration.client.execute(req).await?;
1903
1904 let status = resp.status();
1905 let content_type = resp
1906 .headers()
1907 .get("content-type")
1908 .and_then(|v| v.to_str().ok())
1909 .unwrap_or("application/octet-stream");
1910 let content_type = super::ContentType::from(content_type);
1911
1912 if !status.is_client_error() && !status.is_server_error() {
1913 let content = resp.text().await?;
1914 match content_type {
1915 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1916 ContentType::Text => return Ok(models::GetTimeSeriesResponse::Text(content)),
1917 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetTimeSeriesResponse`")))),
1918 }
1919 } else {
1920 let content = resp.text().await?;
1921 let entity: Option<GetTimeSeriesError> = serde_json::from_str(&content).ok();
1922 Err(Error::ResponseError(ResponseContent {
1923 status,
1924 content,
1925 entity,
1926 }))
1927 }
1928}
1929
1930/// The Time Series Cross endpoint calculates and returns historical cross-rate data for exotic forex pairs, cryptocurrencies, or stocks (e.g., Apple Inc. price in Indian Rupees) on the fly. It provides metadata about the requested symbol and a time series array with Open, High, Low, and Close prices, sorted descending by time, enabling analysis of price history and market trends.
1931pub async fn get_time_series_cross(
1932 configuration: &configuration::Configuration,
1933 params: GetTimeSeriesCrossParams,
1934) -> Result<models::GetTimeSeriesCrossResponse, Error<GetTimeSeriesCrossError>> {
1935 // Extract parameters from params struct
1936 let p_query_base = params.base;
1937 let p_query_quote = params.quote;
1938 let p_query_interval = params.interval;
1939 let p_query_base_type = params.base_type;
1940 let p_query_base_exchange = params.base_exchange;
1941 let p_query_base_mic_code = params.base_mic_code;
1942 let p_query_quote_type = params.quote_type;
1943 let p_query_quote_exchange = params.quote_exchange;
1944 let p_query_quote_mic_code = params.quote_mic_code;
1945 let p_query_outputsize = params.outputsize;
1946 let p_query_format = params.format;
1947 let p_query_delimiter = params.delimiter;
1948 let p_query_prepost = params.prepost;
1949 let p_query_start_date = params.start_date;
1950 let p_query_end_date = params.end_date;
1951 let p_query_adjust = params.adjust;
1952 let p_query_dp = params.dp;
1953 let p_query_timezone = params.timezone;
1954
1955 let uri_str = format!("{}/time_series/cross", configuration.base_path);
1956 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1957
1958 req_builder = req_builder.query(&[("base", &p_query_base.to_string())]);
1959 if let Some(ref param_value) = p_query_base_type {
1960 req_builder = req_builder.query(&[("base_type", ¶m_value.to_string())]);
1961 }
1962 if let Some(ref param_value) = p_query_base_exchange {
1963 req_builder = req_builder.query(&[("base_exchange", ¶m_value.to_string())]);
1964 }
1965 if let Some(ref param_value) = p_query_base_mic_code {
1966 req_builder = req_builder.query(&[("base_mic_code", ¶m_value.to_string())]);
1967 }
1968 req_builder = req_builder.query(&[("quote", &p_query_quote.to_string())]);
1969 if let Some(ref param_value) = p_query_quote_type {
1970 req_builder = req_builder.query(&[("quote_type", ¶m_value.to_string())]);
1971 }
1972 if let Some(ref param_value) = p_query_quote_exchange {
1973 req_builder = req_builder.query(&[("quote_exchange", ¶m_value.to_string())]);
1974 }
1975 if let Some(ref param_value) = p_query_quote_mic_code {
1976 req_builder = req_builder.query(&[("quote_mic_code", ¶m_value.to_string())]);
1977 }
1978 req_builder = req_builder.query(&[("interval", &p_query_interval.to_string())]);
1979 if let Some(ref param_value) = p_query_outputsize {
1980 req_builder = req_builder.query(&[("outputsize", ¶m_value.to_string())]);
1981 }
1982 if let Some(ref param_value) = p_query_format {
1983 req_builder = req_builder.query(&[("format", ¶m_value.to_string())]);
1984 }
1985 if let Some(ref param_value) = p_query_delimiter {
1986 req_builder = req_builder.query(&[("delimiter", ¶m_value.to_string())]);
1987 }
1988 if let Some(ref param_value) = p_query_prepost {
1989 req_builder = req_builder.query(&[("prepost", ¶m_value.to_string())]);
1990 }
1991 if let Some(ref param_value) = p_query_start_date {
1992 req_builder = req_builder.query(&[("start_date", ¶m_value.to_string())]);
1993 }
1994 if let Some(ref param_value) = p_query_end_date {
1995 req_builder = req_builder.query(&[("end_date", ¶m_value.to_string())]);
1996 }
1997 if let Some(ref param_value) = p_query_adjust {
1998 req_builder = req_builder.query(&[("adjust", ¶m_value.to_string())]);
1999 }
2000 if let Some(ref param_value) = p_query_dp {
2001 req_builder = req_builder.query(&[("dp", ¶m_value.to_string())]);
2002 }
2003 if let Some(ref param_value) = p_query_timezone {
2004 req_builder = req_builder.query(&[("timezone", ¶m_value.to_string())]);
2005 }
2006 if let Some(ref user_agent) = configuration.user_agent {
2007 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2008 }
2009 if let Some(ref apikey) = configuration.api_key {
2010 let key = apikey.key.clone();
2011 let value = match apikey.prefix {
2012 Some(ref prefix) => format!("{} {}", prefix, key),
2013 None => key,
2014 };
2015 req_builder = req_builder.header("Authorization", value);
2016 };
2017
2018 let req = req_builder.build()?;
2019 let resp = configuration.client.execute(req).await?;
2020
2021 let status = resp.status();
2022 let content_type = resp
2023 .headers()
2024 .get("content-type")
2025 .and_then(|v| v.to_str().ok())
2026 .unwrap_or("application/octet-stream");
2027 let content_type = super::ContentType::from(content_type);
2028
2029 if !status.is_client_error() && !status.is_server_error() {
2030 let content = resp.text().await?;
2031 match content_type {
2032 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2033 ContentType::Text => return Ok(models::GetTimeSeriesCrossResponse::Text(content)),
2034 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetTimeSeriesCrossResponse`")))),
2035 }
2036 } else {
2037 let content = resp.text().await?;
2038 let entity: Option<GetTimeSeriesCrossError> = serde_json::from_str(&content).ok();
2039 Err(Error::ResponseError(ResponseContent {
2040 status,
2041 content,
2042 entity,
2043 }))
2044 }
2045}