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') &nbsp;&nbsp;.then(response => response.json()) &nbsp;&nbsp;.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( &nbsp;&nbsp;&nbsp;&nbsp;symbol=\"TSLA\", &nbsp;&nbsp;&nbsp;&nbsp;interval=\"1day\", &nbsp;&nbsp;&nbsp;&nbsp;outputsize=100 ).as_pandas()  # Fetch historical price data for Microsoft msft_ts = td.time_series( &nbsp;&nbsp;&nbsp;&nbsp;symbol=\"MSFT\", &nbsp;&nbsp;&nbsp;&nbsp;interval=\"1day\", &nbsp;&nbsp;&nbsp;&nbsp;outputsize=100 ).as_pandas()  # Align data on datetime index combined = pd.concat( &nbsp;&nbsp;&nbsp;&nbsp;[tsla_ts['close'].astype(float), msft_ts['close'].astype(float)], &nbsp;&nbsp;&nbsp;&nbsp;axis=1, &nbsp;&nbsp;&nbsp;&nbsp;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 Documenta­tion to correct the input. |  **401** | Unauthor­ized | 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 { &nbsp;&nbsp;\"code\": 400, &nbsp;&nbsp;\"message\": \"Invalid **interval** provided: 0.99min. Supported intervals: 1min, 5min, 15min, 30min, 45min, 1h, 2h, 4h, 8h, 1day, 1week, 1month\", &nbsp;&nbsp;\"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
11
12use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17/// struct for passing parameters to the method [`get_currency_conversion`]
18#[derive(Clone, Debug, Default, Serialize, Deserialize)]
19pub struct GetCurrencyConversionParams {
20    /// 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
21    pub symbol: String,
22    /// Amount of base currency to be converted into quote currency. Supports values in the range from `0` and above
23    pub amount: f64,
24    /// 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
25    pub date: Option<String>,
26    /// Value can be `JSON` or `CSV`. Default `JSON`
27    pub format: Option<String>,
28    /// Specify the delimiter used when downloading the `CSV` file. Default semicolon `;`
29    pub delimiter: Option<String>,
30    /// The number of decimal places for the data
31    pub dp: Option<i64>,
32    /// 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>
33    pub timezone: Option<String>
34}
35
36impl GetCurrencyConversionParams {
37    /// Create a new builder for this parameter struct
38    pub fn builder() -> GetCurrencyConversionParamsBuilder {
39        GetCurrencyConversionParamsBuilder::default()
40    }
41}
42
43/// Builder for [`GetCurrencyConversionParams`]
44#[derive(Clone, Debug, Default)]
45pub struct GetCurrencyConversionParamsBuilder {
46    /// 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
47    symbol: String,
48    /// Amount of base currency to be converted into quote currency. Supports values in the range from `0` and above
49    amount: f64,
50    /// 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
51    date: Option<String>,
52    /// Value can be `JSON` or `CSV`. Default `JSON`
53    format: Option<String>,
54    /// Specify the delimiter used when downloading the `CSV` file. Default semicolon `;`
55    delimiter: Option<String>,
56    /// The number of decimal places for the data
57    dp: Option<i64>,
58    /// 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>
59    timezone: Option<String>
60}
61
62impl GetCurrencyConversionParamsBuilder {
63    /// 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
64    pub fn symbol(mut self, symbol: impl Into<String>) -> Self {
65        self.symbol = symbol.into();
66        self
67    }
68    /// Amount of base currency to be converted into quote currency. Supports values in the range from `0` and above
69    pub fn amount(mut self, amount: f64) -> Self {
70        self.amount = amount;
71        self
72    }
73    /// 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
74    pub fn date(mut self, date: impl Into<String>) -> Self {
75        self.date = Some(date.into());
76        self
77    }
78    /// Value can be `JSON` or `CSV`. Default `JSON`
79    pub fn format(mut self, format: impl Into<String>) -> Self {
80        self.format = Some(format.into());
81        self
82    }
83    /// Specify the delimiter used when downloading the `CSV` file. Default semicolon `;`
84    pub fn delimiter(mut self, delimiter: impl Into<String>) -> Self {
85        self.delimiter = Some(delimiter.into());
86        self
87    }
88    /// The number of decimal places for the data
89    pub fn dp(mut self, dp: i64) -> Self {
90        self.dp = Some(dp);
91        self
92    }
93    /// 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>
94    pub fn timezone(mut self, timezone: impl Into<String>) -> Self {
95        self.timezone = Some(timezone.into());
96        self
97    }
98
99    /// Build the parameter struct
100    pub fn build(self) -> GetCurrencyConversionParams {
101        GetCurrencyConversionParams {
102            symbol: self.symbol,
103            amount: self.amount,
104            date: self.date,
105            format: self.format,
106            delimiter: self.delimiter,
107            dp: self.dp,
108            timezone: self.timezone
109        }
110    }
111}
112
113/// struct for passing parameters to the method [`get_eod`]
114#[derive(Clone, Debug, Default, Serialize, Deserialize)]
115pub struct GetEodParams {
116    /// Symbol ticker of the instrument
117    pub symbol: Option<String>,
118    /// Filter by financial instrument global identifier (FIGI)
119    pub figi: Option<String>,
120    /// Filter by international securities identification number (ISIN)
121    pub isin: Option<String>,
122    /// 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
123    pub cusip: Option<String>,
124    /// Exchange where instrument is traded
125    pub exchange: Option<String>,
126    /// Market Identifier Code (MIC) under ISO 10383 standard
127    pub mic_code: Option<String>,
128    /// Country where instrument is traded, e.g., `United States` or `US`
129    pub country: Option<String>,
130    /// The asset class to which the instrument belongs
131    pub r#type: Option<String>,
132    /// If not null, then return data from a specific date
133    pub date: Option<String>,
134    /// 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
135    pub prepost: Option<bool>,
136    /// Specifies the number of decimal places for floating values Should be in range [0,11] inclusive
137    pub dp: Option<i64>
138}
139
140impl GetEodParams {
141    /// Create a new builder for this parameter struct
142    pub fn builder() -> GetEodParamsBuilder {
143        GetEodParamsBuilder::default()
144    }
145}
146
147/// Builder for [`GetEodParams`]
148#[derive(Clone, Debug, Default)]
149pub struct GetEodParamsBuilder {
150    /// Symbol ticker of the instrument
151    symbol: Option<String>,
152    /// Filter by financial instrument global identifier (FIGI)
153    figi: Option<String>,
154    /// Filter by international securities identification number (ISIN)
155    isin: Option<String>,
156    /// 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
157    cusip: Option<String>,
158    /// Exchange where instrument is traded
159    exchange: Option<String>,
160    /// Market Identifier Code (MIC) under ISO 10383 standard
161    mic_code: Option<String>,
162    /// Country where instrument is traded, e.g., `United States` or `US`
163    country: Option<String>,
164    /// The asset class to which the instrument belongs
165    r#type: Option<String>,
166    /// If not null, then return data from a specific date
167    date: Option<String>,
168    /// 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
169    prepost: Option<bool>,
170    /// Specifies the number of decimal places for floating values Should be in range [0,11] inclusive
171    dp: Option<i64>
172}
173
174impl GetEodParamsBuilder {
175    /// Symbol ticker of the instrument
176    pub fn symbol(mut self, symbol: impl Into<String>) -> Self {
177        self.symbol = Some(symbol.into());
178        self
179    }
180    /// Filter by financial instrument global identifier (FIGI)
181    pub fn figi(mut self, figi: impl Into<String>) -> Self {
182        self.figi = Some(figi.into());
183        self
184    }
185    /// Filter by international securities identification number (ISIN)
186    pub fn isin(mut self, isin: impl Into<String>) -> Self {
187        self.isin = Some(isin.into());
188        self
189    }
190    /// 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
191    pub fn cusip(mut self, cusip: impl Into<String>) -> Self {
192        self.cusip = Some(cusip.into());
193        self
194    }
195    /// Exchange where instrument is traded
196    pub fn exchange(mut self, exchange: impl Into<String>) -> Self {
197        self.exchange = Some(exchange.into());
198        self
199    }
200    /// Market Identifier Code (MIC) under ISO 10383 standard
201    pub fn mic_code(mut self, mic_code: impl Into<String>) -> Self {
202        self.mic_code = Some(mic_code.into());
203        self
204    }
205    /// Country where instrument is traded, e.g., `United States` or `US`
206    pub fn country(mut self, country: impl Into<String>) -> Self {
207        self.country = Some(country.into());
208        self
209    }
210    /// The asset class to which the instrument belongs
211    pub fn r#type(mut self, r#type: impl Into<String>) -> Self {
212        self.r#type = Some(r#type.into());
213        self
214    }
215    /// If not null, then return data from a specific date
216    pub fn date(mut self, date: impl Into<String>) -> Self {
217        self.date = Some(date.into());
218        self
219    }
220    /// 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
221    pub fn prepost(mut self, prepost: bool) -> Self {
222        self.prepost = Some(prepost);
223        self
224    }
225    /// Specifies the number of decimal places for floating values Should be in range [0,11] inclusive
226    pub fn dp(mut self, dp: i64) -> Self {
227        self.dp = Some(dp);
228        self
229    }
230
231    /// Build the parameter struct
232    pub fn build(self) -> GetEodParams {
233        GetEodParams {
234            symbol: self.symbol,
235            figi: self.figi,
236            isin: self.isin,
237            cusip: self.cusip,
238            exchange: self.exchange,
239            mic_code: self.mic_code,
240            country: self.country,
241            r#type: self.r#type,
242            date: self.date,
243            prepost: self.prepost,
244            dp: self.dp
245        }
246    }
247}
248
249/// struct for passing parameters to the method [`get_exchange_rate`]
250#[derive(Clone, Debug, Default, Serialize, Deserialize)]
251pub struct GetExchangeRateParams {
252    /// 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
253    pub symbol: String,
254    /// 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
255    pub date: Option<String>,
256    /// Value can be `JSON` or `CSV`. Default `JSON`
257    pub format: Option<String>,
258    /// Specify the delimiter used when downloading the `CSV` file. Default semicolon `;`
259    pub delimiter: Option<String>,
260    /// The number of decimal places for the data
261    pub dp: Option<i64>,
262    /// 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>
263    pub timezone: Option<String>
264}
265
266impl GetExchangeRateParams {
267    /// Create a new builder for this parameter struct
268    pub fn builder() -> GetExchangeRateParamsBuilder {
269        GetExchangeRateParamsBuilder::default()
270    }
271}
272
273/// Builder for [`GetExchangeRateParams`]
274#[derive(Clone, Debug, Default)]
275pub struct GetExchangeRateParamsBuilder {
276    /// 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
277    symbol: String,
278    /// 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
279    date: Option<String>,
280    /// Value can be `JSON` or `CSV`. Default `JSON`
281    format: Option<String>,
282    /// Specify the delimiter used when downloading the `CSV` file. Default semicolon `;`
283    delimiter: Option<String>,
284    /// The number of decimal places for the data
285    dp: Option<i64>,
286    /// 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>
287    timezone: Option<String>
288}
289
290impl GetExchangeRateParamsBuilder {
291    /// 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
292    pub fn symbol(mut self, symbol: impl Into<String>) -> Self {
293        self.symbol = symbol.into();
294        self
295    }
296    /// 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
297    pub fn date(mut self, date: impl Into<String>) -> Self {
298        self.date = Some(date.into());
299        self
300    }
301    /// Value can be `JSON` or `CSV`. Default `JSON`
302    pub fn format(mut self, format: impl Into<String>) -> Self {
303        self.format = Some(format.into());
304        self
305    }
306    /// Specify the delimiter used when downloading the `CSV` file. Default semicolon `;`
307    pub fn delimiter(mut self, delimiter: impl Into<String>) -> Self {
308        self.delimiter = Some(delimiter.into());
309        self
310    }
311    /// The number of decimal places for the data
312    pub fn dp(mut self, dp: i64) -> Self {
313        self.dp = Some(dp);
314        self
315    }
316    /// 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>
317    pub fn timezone(mut self, timezone: impl Into<String>) -> Self {
318        self.timezone = Some(timezone.into());
319        self
320    }
321
322    /// Build the parameter struct
323    pub fn build(self) -> GetExchangeRateParams {
324        GetExchangeRateParams {
325            symbol: self.symbol,
326            date: self.date,
327            format: self.format,
328            delimiter: self.delimiter,
329            dp: self.dp,
330            timezone: self.timezone
331        }
332    }
333}
334
335/// struct for passing parameters to the method [`get_market_movers`]
336#[derive(Clone, Debug, Default, Serialize, Deserialize)]
337pub struct GetMarketMoversParams {
338    /// Maket type
339    pub market: String,
340    /// Specifies direction of the snapshot gainers or losers
341    pub direction: Option<String>,
342    /// Specifies the size of the snapshot. Can be in a range from `1` to `50`
343    pub outputsize: Option<i64>,
344    /// Country of the snapshot, applicable to non-currencies only. Takes country name or alpha code
345    pub country: Option<String>,
346    /// Takes values with price grater than specified value
347    pub price_greater_than: Option<String>,
348    /// Specifies the number of decimal places for floating values. Should be in range [0,11] inclusive
349    pub dp: Option<String>
350}
351
352impl GetMarketMoversParams {
353    /// Create a new builder for this parameter struct
354    pub fn builder() -> GetMarketMoversParamsBuilder {
355        GetMarketMoversParamsBuilder::default()
356    }
357}
358
359/// Builder for [`GetMarketMoversParams`]
360#[derive(Clone, Debug, Default)]
361pub struct GetMarketMoversParamsBuilder {
362    /// Maket type
363    market: String,
364    /// Specifies direction of the snapshot gainers or losers
365    direction: Option<String>,
366    /// Specifies the size of the snapshot. Can be in a range from `1` to `50`
367    outputsize: Option<i64>,
368    /// Country of the snapshot, applicable to non-currencies only. Takes country name or alpha code
369    country: Option<String>,
370    /// Takes values with price grater than specified value
371    price_greater_than: Option<String>,
372    /// Specifies the number of decimal places for floating values. Should be in range [0,11] inclusive
373    dp: Option<String>
374}
375
376impl GetMarketMoversParamsBuilder {
377    /// Maket type
378    pub fn market(mut self, market: impl Into<String>) -> Self {
379        self.market = market.into();
380        self
381    }
382    /// Specifies direction of the snapshot gainers or losers
383    pub fn direction(mut self, direction: impl Into<String>) -> Self {
384        self.direction = Some(direction.into());
385        self
386    }
387    /// Specifies the size of the snapshot. Can be in a range from `1` to `50`
388    pub fn outputsize(mut self, outputsize: i64) -> Self {
389        self.outputsize = Some(outputsize);
390        self
391    }
392    /// Country of the snapshot, applicable to non-currencies only. Takes country name or alpha code
393    pub fn country(mut self, country: impl Into<String>) -> Self {
394        self.country = Some(country.into());
395        self
396    }
397    /// Takes values with price grater than specified value
398    pub fn price_greater_than(mut self, price_greater_than: impl Into<String>) -> Self {
399        self.price_greater_than = Some(price_greater_than.into());
400        self
401    }
402    /// Specifies the number of decimal places for floating values. Should be in range [0,11] inclusive
403    pub fn dp(mut self, dp: impl Into<String>) -> Self {
404        self.dp = Some(dp.into());
405        self
406    }
407
408    /// Build the parameter struct
409    pub fn build(self) -> GetMarketMoversParams {
410        GetMarketMoversParams {
411            market: self.market,
412            direction: self.direction,
413            outputsize: self.outputsize,
414            country: self.country,
415            price_greater_than: self.price_greater_than,
416            dp: self.dp
417        }
418    }
419}
420
421/// struct for passing parameters to the method [`get_price`]
422#[derive(Clone, Debug, Default, Serialize, Deserialize)]
423pub struct GetPriceParams {
424    /// Symbol ticker of the instrument
425    pub symbol: Option<String>,
426    /// Filter by financial instrument global identifier (FIGI)
427    pub figi: Option<String>,
428    /// Filter by international securities identification number (ISIN)
429    pub isin: Option<String>,
430    /// 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
431    pub cusip: Option<String>,
432    /// Exchange where instrument is traded
433    pub exchange: Option<String>,
434    /// Market Identifier Code (MIC) under ISO 10383 standard
435    pub mic_code: Option<String>,
436    /// Country where instrument is traded, e.g., `United States` or `US`
437    pub country: Option<String>,
438    /// The asset class to which the instrument belongs
439    pub r#type: Option<String>,
440    /// Value can be JSON or CSV
441    pub format: Option<String>,
442    /// Specify the delimiter used when downloading the CSV file
443    pub delimiter: Option<String>,
444    /// 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.
445    pub prepost: Option<bool>,
446    /// Specifies the number of decimal places for floating values. Should be in range [0,11] inclusive
447    pub dp: Option<i64>
448}
449
450impl GetPriceParams {
451    /// Create a new builder for this parameter struct
452    pub fn builder() -> GetPriceParamsBuilder {
453        GetPriceParamsBuilder::default()
454    }
455}
456
457/// Builder for [`GetPriceParams`]
458#[derive(Clone, Debug, Default)]
459pub struct GetPriceParamsBuilder {
460    /// Symbol ticker of the instrument
461    symbol: Option<String>,
462    /// Filter by financial instrument global identifier (FIGI)
463    figi: Option<String>,
464    /// Filter by international securities identification number (ISIN)
465    isin: Option<String>,
466    /// 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
467    cusip: Option<String>,
468    /// Exchange where instrument is traded
469    exchange: Option<String>,
470    /// Market Identifier Code (MIC) under ISO 10383 standard
471    mic_code: Option<String>,
472    /// Country where instrument is traded, e.g., `United States` or `US`
473    country: Option<String>,
474    /// The asset class to which the instrument belongs
475    r#type: Option<String>,
476    /// Value can be JSON or CSV
477    format: Option<String>,
478    /// Specify the delimiter used when downloading the CSV file
479    delimiter: Option<String>,
480    /// 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.
481    prepost: Option<bool>,
482    /// Specifies the number of decimal places for floating values. Should be in range [0,11] inclusive
483    dp: Option<i64>
484}
485
486impl GetPriceParamsBuilder {
487    /// Symbol ticker of the instrument
488    pub fn symbol(mut self, symbol: impl Into<String>) -> Self {
489        self.symbol = Some(symbol.into());
490        self
491    }
492    /// Filter by financial instrument global identifier (FIGI)
493    pub fn figi(mut self, figi: impl Into<String>) -> Self {
494        self.figi = Some(figi.into());
495        self
496    }
497    /// Filter by international securities identification number (ISIN)
498    pub fn isin(mut self, isin: impl Into<String>) -> Self {
499        self.isin = Some(isin.into());
500        self
501    }
502    /// 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
503    pub fn cusip(mut self, cusip: impl Into<String>) -> Self {
504        self.cusip = Some(cusip.into());
505        self
506    }
507    /// Exchange where instrument is traded
508    pub fn exchange(mut self, exchange: impl Into<String>) -> Self {
509        self.exchange = Some(exchange.into());
510        self
511    }
512    /// Market Identifier Code (MIC) under ISO 10383 standard
513    pub fn mic_code(mut self, mic_code: impl Into<String>) -> Self {
514        self.mic_code = Some(mic_code.into());
515        self
516    }
517    /// Country where instrument is traded, e.g., `United States` or `US`
518    pub fn country(mut self, country: impl Into<String>) -> Self {
519        self.country = Some(country.into());
520        self
521    }
522    /// The asset class to which the instrument belongs
523    pub fn r#type(mut self, r#type: impl Into<String>) -> Self {
524        self.r#type = Some(r#type.into());
525        self
526    }
527    /// Value can be JSON or CSV
528    pub fn format(mut self, format: impl Into<String>) -> Self {
529        self.format = Some(format.into());
530        self
531    }
532    /// Specify the delimiter used when downloading the CSV file
533    pub fn delimiter(mut self, delimiter: impl Into<String>) -> Self {
534        self.delimiter = Some(delimiter.into());
535        self
536    }
537    /// 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.
538    pub fn prepost(mut self, prepost: bool) -> Self {
539        self.prepost = Some(prepost);
540        self
541    }
542    /// Specifies the number of decimal places for floating values. Should be in range [0,11] inclusive
543    pub fn dp(mut self, dp: i64) -> Self {
544        self.dp = Some(dp);
545        self
546    }
547
548    /// Build the parameter struct
549    pub fn build(self) -> GetPriceParams {
550        GetPriceParams {
551            symbol: self.symbol,
552            figi: self.figi,
553            isin: self.isin,
554            cusip: self.cusip,
555            exchange: self.exchange,
556            mic_code: self.mic_code,
557            country: self.country,
558            r#type: self.r#type,
559            format: self.format,
560            delimiter: self.delimiter,
561            prepost: self.prepost,
562            dp: self.dp
563        }
564    }
565}
566
567/// struct for passing parameters to the method [`get_quote`]
568#[derive(Clone, Debug, Default, Serialize, Deserialize)]
569pub struct GetQuoteParams {
570    /// Symbol ticker of the instrument
571    pub symbol: Option<String>,
572    /// Filter by financial instrument global identifier (FIGI)
573    pub figi: Option<String>,
574    /// Filter by international securities identification number (ISIN)
575    pub isin: Option<String>,
576    /// 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
577    pub cusip: Option<String>,
578    /// Interval of the quote
579    pub interval: Option<String>,
580    /// Exchange where instrument is traded
581    pub exchange: Option<String>,
582    /// Market Identifier Code (MIC) under ISO 10383 standard
583    pub mic_code: Option<String>,
584    /// Country where instrument is traded, e.g., `United States` or `US`
585    pub country: Option<String>,
586    /// Number of periods for Average Volume
587    pub volume_time_period: Option<i64>,
588    /// The asset class to which the instrument belongs
589    pub r#type: Option<String>,
590    /// Value can be JSON or CSV Default JSON
591    pub format: Option<String>,
592    /// Specify the delimiter used when downloading the CSV file
593    pub delimiter: Option<String>,
594    /// 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.
595    pub prepost: Option<bool>,
596    /// If true, then return data for closed day
597    pub eod: Option<bool>,
598    /// Number of hours for calculate rolling change at period. By default set to 24, it can be in range [1, 168].
599    pub rolling_period: Option<i64>,
600    /// Specifies the number of decimal places for floating values Should be in range [0,11] inclusive
601    pub dp: Option<i64>,
602    /// 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>
603    pub timezone: Option<String>
604}
605
606impl GetQuoteParams {
607    /// Create a new builder for this parameter struct
608    pub fn builder() -> GetQuoteParamsBuilder {
609        GetQuoteParamsBuilder::default()
610    }
611}
612
613/// Builder for [`GetQuoteParams`]
614#[derive(Clone, Debug, Default)]
615pub struct GetQuoteParamsBuilder {
616    /// Symbol ticker of the instrument
617    symbol: Option<String>,
618    /// Filter by financial instrument global identifier (FIGI)
619    figi: Option<String>,
620    /// Filter by international securities identification number (ISIN)
621    isin: Option<String>,
622    /// 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
623    cusip: Option<String>,
624    /// Interval of the quote
625    interval: Option<String>,
626    /// Exchange where instrument is traded
627    exchange: Option<String>,
628    /// Market Identifier Code (MIC) under ISO 10383 standard
629    mic_code: Option<String>,
630    /// Country where instrument is traded, e.g., `United States` or `US`
631    country: Option<String>,
632    /// Number of periods for Average Volume
633    volume_time_period: Option<i64>,
634    /// The asset class to which the instrument belongs
635    r#type: Option<String>,
636    /// Value can be JSON or CSV Default JSON
637    format: Option<String>,
638    /// Specify the delimiter used when downloading the CSV file
639    delimiter: Option<String>,
640    /// 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.
641    prepost: Option<bool>,
642    /// If true, then return data for closed day
643    eod: Option<bool>,
644    /// Number of hours for calculate rolling change at period. By default set to 24, it can be in range [1, 168].
645    rolling_period: Option<i64>,
646    /// Specifies the number of decimal places for floating values Should be in range [0,11] inclusive
647    dp: Option<i64>,
648    /// 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>
649    timezone: Option<String>
650}
651
652impl GetQuoteParamsBuilder {
653    /// Symbol ticker of the instrument
654    pub fn symbol(mut self, symbol: impl Into<String>) -> Self {
655        self.symbol = Some(symbol.into());
656        self
657    }
658    /// Filter by financial instrument global identifier (FIGI)
659    pub fn figi(mut self, figi: impl Into<String>) -> Self {
660        self.figi = Some(figi.into());
661        self
662    }
663    /// Filter by international securities identification number (ISIN)
664    pub fn isin(mut self, isin: impl Into<String>) -> Self {
665        self.isin = Some(isin.into());
666        self
667    }
668    /// 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
669    pub fn cusip(mut self, cusip: impl Into<String>) -> Self {
670        self.cusip = Some(cusip.into());
671        self
672    }
673    /// Interval of the quote
674    pub fn interval(mut self, interval: impl Into<String>) -> Self {
675        self.interval = Some(interval.into());
676        self
677    }
678    /// Exchange where instrument is traded
679    pub fn exchange(mut self, exchange: impl Into<String>) -> Self {
680        self.exchange = Some(exchange.into());
681        self
682    }
683    /// Market Identifier Code (MIC) under ISO 10383 standard
684    pub fn mic_code(mut self, mic_code: impl Into<String>) -> Self {
685        self.mic_code = Some(mic_code.into());
686        self
687    }
688    /// Country where instrument is traded, e.g., `United States` or `US`
689    pub fn country(mut self, country: impl Into<String>) -> Self {
690        self.country = Some(country.into());
691        self
692    }
693    /// Number of periods for Average Volume
694    pub fn volume_time_period(mut self, volume_time_period: i64) -> Self {
695        self.volume_time_period = Some(volume_time_period);
696        self
697    }
698    /// The asset class to which the instrument belongs
699    pub fn r#type(mut self, r#type: impl Into<String>) -> Self {
700        self.r#type = Some(r#type.into());
701        self
702    }
703    /// Value can be JSON or CSV Default JSON
704    pub fn format(mut self, format: impl Into<String>) -> Self {
705        self.format = Some(format.into());
706        self
707    }
708    /// Specify the delimiter used when downloading the CSV file
709    pub fn delimiter(mut self, delimiter: impl Into<String>) -> Self {
710        self.delimiter = Some(delimiter.into());
711        self
712    }
713    /// 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.
714    pub fn prepost(mut self, prepost: bool) -> Self {
715        self.prepost = Some(prepost);
716        self
717    }
718    /// If true, then return data for closed day
719    pub fn eod(mut self, eod: bool) -> Self {
720        self.eod = Some(eod);
721        self
722    }
723    /// Number of hours for calculate rolling change at period. By default set to 24, it can be in range [1, 168].
724    pub fn rolling_period(mut self, rolling_period: i64) -> Self {
725        self.rolling_period = Some(rolling_period);
726        self
727    }
728    /// Specifies the number of decimal places for floating values Should be in range [0,11] inclusive
729    pub fn dp(mut self, dp: i64) -> Self {
730        self.dp = Some(dp);
731        self
732    }
733    /// 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>
734    pub fn timezone(mut self, timezone: impl Into<String>) -> Self {
735        self.timezone = Some(timezone.into());
736        self
737    }
738
739    /// Build the parameter struct
740    pub fn build(self) -> GetQuoteParams {
741        GetQuoteParams {
742            symbol: self.symbol,
743            figi: self.figi,
744            isin: self.isin,
745            cusip: self.cusip,
746            interval: self.interval,
747            exchange: self.exchange,
748            mic_code: self.mic_code,
749            country: self.country,
750            volume_time_period: self.volume_time_period,
751            r#type: self.r#type,
752            format: self.format,
753            delimiter: self.delimiter,
754            prepost: self.prepost,
755            eod: self.eod,
756            rolling_period: self.rolling_period,
757            dp: self.dp,
758            timezone: self.timezone
759        }
760    }
761}
762
763/// struct for passing parameters to the method [`get_time_series`]
764#[derive(Clone, Debug, Default, Serialize, Deserialize)]
765pub struct GetTimeSeriesParams {
766    /// Interval between two consecutive points in time series
767    pub interval: String,
768    /// Symbol ticker of the instrument. E.g. `AAPL`, `EUR/USD`, `ETH/BTC`, ...
769    pub symbol: Option<String>,
770    /// Filter by international securities identification number (ISIN)
771    pub isin: Option<String>,
772    /// The FIGI of an instrument for which data is requested
773    pub figi: Option<String>,
774    /// 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
775    pub cusip: Option<String>,
776    /// 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
777    pub outputsize: Option<i64>,
778    /// Exchange where instrument is traded
779    pub exchange: Option<String>,
780    /// Market Identifier Code (MIC) under ISO 10383 standard
781    pub mic_code: Option<String>,
782    /// The country where the instrument is traded, e.g., `United States` or `US`
783    pub country: Option<String>,
784    /// The asset class to which the instrument belongs
785    pub r#type: Option<String>,
786    /// 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>
787    pub timezone: Option<String>,
788    /// 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>
789    pub start_date: Option<String>,
790    /// The ending date and time for data selection, see `start_date` description for details.
791    pub end_date: Option<String>,
792    /// 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`
793    pub date: Option<String>,
794    /// Sorting order of the output
795    pub order: Option<String>,
796    /// 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
797    pub prepost: Option<bool>,
798    /// The format of the response data
799    pub format: Option<String>,
800    /// The separator used in the CSV response data
801    pub delimiter: Option<String>,
802    /// 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
803    pub dp: Option<i64>,
804    /// 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
805    pub previous_close: Option<bool>,
806    /// Adjusting mode for prices
807    pub adjust: Option<String>
808}
809
810impl GetTimeSeriesParams {
811    /// Create a new builder for this parameter struct
812    pub fn builder() -> GetTimeSeriesParamsBuilder {
813        GetTimeSeriesParamsBuilder::default()
814    }
815}
816
817/// Builder for [`GetTimeSeriesParams`]
818#[derive(Clone, Debug, Default)]
819pub struct GetTimeSeriesParamsBuilder {
820    /// Interval between two consecutive points in time series
821    interval: String,
822    /// Symbol ticker of the instrument. E.g. `AAPL`, `EUR/USD`, `ETH/BTC`, ...
823    symbol: Option<String>,
824    /// Filter by international securities identification number (ISIN)
825    isin: Option<String>,
826    /// The FIGI of an instrument for which data is requested
827    figi: Option<String>,
828    /// 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
829    cusip: Option<String>,
830    /// 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
831    outputsize: Option<i64>,
832    /// Exchange where instrument is traded
833    exchange: Option<String>,
834    /// Market Identifier Code (MIC) under ISO 10383 standard
835    mic_code: Option<String>,
836    /// The country where the instrument is traded, e.g., `United States` or `US`
837    country: Option<String>,
838    /// The asset class to which the instrument belongs
839    r#type: Option<String>,
840    /// 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>
841    timezone: Option<String>,
842    /// 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>
843    start_date: Option<String>,
844    /// The ending date and time for data selection, see `start_date` description for details.
845    end_date: Option<String>,
846    /// 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`
847    date: Option<String>,
848    /// Sorting order of the output
849    order: Option<String>,
850    /// 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
851    prepost: Option<bool>,
852    /// The format of the response data
853    format: Option<String>,
854    /// The separator used in the CSV response data
855    delimiter: Option<String>,
856    /// 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
857    dp: Option<i64>,
858    /// 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
859    previous_close: Option<bool>,
860    /// Adjusting mode for prices
861    adjust: Option<String>
862}
863
864impl GetTimeSeriesParamsBuilder {
865    /// Interval between two consecutive points in time series
866    pub fn interval(mut self, interval: impl Into<String>) -> Self {
867        self.interval = interval.into();
868        self
869    }
870    /// Symbol ticker of the instrument. E.g. `AAPL`, `EUR/USD`, `ETH/BTC`, ...
871    pub fn symbol(mut self, symbol: impl Into<String>) -> Self {
872        self.symbol = Some(symbol.into());
873        self
874    }
875    /// Filter by international securities identification number (ISIN)
876    pub fn isin(mut self, isin: impl Into<String>) -> Self {
877        self.isin = Some(isin.into());
878        self
879    }
880    /// The FIGI of an instrument for which data is requested
881    pub fn figi(mut self, figi: impl Into<String>) -> Self {
882        self.figi = Some(figi.into());
883        self
884    }
885    /// 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
886    pub fn cusip(mut self, cusip: impl Into<String>) -> Self {
887        self.cusip = Some(cusip.into());
888        self
889    }
890    /// 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
891    pub fn outputsize(mut self, outputsize: i64) -> Self {
892        self.outputsize = Some(outputsize);
893        self
894    }
895    /// Exchange where instrument is traded
896    pub fn exchange(mut self, exchange: impl Into<String>) -> Self {
897        self.exchange = Some(exchange.into());
898        self
899    }
900    /// Market Identifier Code (MIC) under ISO 10383 standard
901    pub fn mic_code(mut self, mic_code: impl Into<String>) -> Self {
902        self.mic_code = Some(mic_code.into());
903        self
904    }
905    /// The country where the instrument is traded, e.g., `United States` or `US`
906    pub fn country(mut self, country: impl Into<String>) -> Self {
907        self.country = Some(country.into());
908        self
909    }
910    /// The asset class to which the instrument belongs
911    pub fn r#type(mut self, r#type: impl Into<String>) -> Self {
912        self.r#type = Some(r#type.into());
913        self
914    }
915    /// 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>
916    pub fn timezone(mut self, timezone: impl Into<String>) -> Self {
917        self.timezone = Some(timezone.into());
918        self
919    }
920    /// 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>
921    pub fn start_date(mut self, start_date: impl Into<String>) -> Self {
922        self.start_date = Some(start_date.into());
923        self
924    }
925    /// The ending date and time for data selection, see `start_date` description for details.
926    pub fn end_date(mut self, end_date: impl Into<String>) -> Self {
927        self.end_date = Some(end_date.into());
928        self
929    }
930    /// 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`
931    pub fn date(mut self, date: impl Into<String>) -> Self {
932        self.date = Some(date.into());
933        self
934    }
935    /// Sorting order of the output
936    pub fn order(mut self, order: impl Into<String>) -> Self {
937        self.order = Some(order.into());
938        self
939    }
940    /// 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
941    pub fn prepost(mut self, prepost: bool) -> Self {
942        self.prepost = Some(prepost);
943        self
944    }
945    /// The format of the response data
946    pub fn format(mut self, format: impl Into<String>) -> Self {
947        self.format = Some(format.into());
948        self
949    }
950    /// The separator used in the CSV response data
951    pub fn delimiter(mut self, delimiter: impl Into<String>) -> Self {
952        self.delimiter = Some(delimiter.into());
953        self
954    }
955    /// 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
956    pub fn dp(mut self, dp: i64) -> Self {
957        self.dp = Some(dp);
958        self
959    }
960    /// 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
961    pub fn previous_close(mut self, previous_close: bool) -> Self {
962        self.previous_close = Some(previous_close);
963        self
964    }
965    /// Adjusting mode for prices
966    pub fn adjust(mut self, adjust: impl Into<String>) -> Self {
967        self.adjust = Some(adjust.into());
968        self
969    }
970
971    /// Build the parameter struct
972    pub fn build(self) -> GetTimeSeriesParams {
973        GetTimeSeriesParams {
974            interval: self.interval,
975            symbol: self.symbol,
976            isin: self.isin,
977            figi: self.figi,
978            cusip: self.cusip,
979            outputsize: self.outputsize,
980            exchange: self.exchange,
981            mic_code: self.mic_code,
982            country: self.country,
983            r#type: self.r#type,
984            timezone: self.timezone,
985            start_date: self.start_date,
986            end_date: self.end_date,
987            date: self.date,
988            order: self.order,
989            prepost: self.prepost,
990            format: self.format,
991            delimiter: self.delimiter,
992            dp: self.dp,
993            previous_close: self.previous_close,
994            adjust: self.adjust
995        }
996    }
997}
998
999/// struct for passing parameters to the method [`get_time_series_cross`]
1000#[derive(Clone, Debug, Default, Serialize, Deserialize)]
1001pub struct GetTimeSeriesCrossParams {
1002    /// Base currency symbol
1003    pub base: String,
1004    /// Quote currency symbol
1005    pub quote: String,
1006    /// Interval between two consecutive points in time series
1007    pub interval: String,
1008    /// Base instrument type according to the `/instrument_type` endpoint
1009    pub base_type: Option<String>,
1010    /// Base exchange
1011    pub base_exchange: Option<String>,
1012    /// Base MIC code
1013    pub base_mic_code: Option<String>,
1014    /// Quote instrument type according to the `/instrument_type` endpoint
1015    pub quote_type: Option<String>,
1016    /// Quote exchange
1017    pub quote_exchange: Option<String>,
1018    /// Quote MIC code
1019    pub quote_mic_code: Option<String>,
1020    /// 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
1021    pub outputsize: Option<i64>,
1022    /// Format of the response data
1023    pub format: Option<String>,
1024    /// Delimiter used in CSV file
1025    pub delimiter: Option<String>,
1026    /// 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.
1027    pub prepost: Option<bool>,
1028    /// Start date for the time series data
1029    pub start_date: Option<String>,
1030    /// End date for the time series data
1031    pub end_date: Option<String>,
1032    /// Specifies if there should be an adjustment
1033    pub adjust: Option<bool>,
1034    /// Specifies the number of decimal places for floating values. Should be in range [0, 11] inclusive.
1035    pub dp: Option<i64>,
1036    /// 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>
1037    pub timezone: Option<String>
1038}
1039
1040impl GetTimeSeriesCrossParams {
1041    /// Create a new builder for this parameter struct
1042    pub fn builder() -> GetTimeSeriesCrossParamsBuilder {
1043        GetTimeSeriesCrossParamsBuilder::default()
1044    }
1045}
1046
1047/// Builder for [`GetTimeSeriesCrossParams`]
1048#[derive(Clone, Debug, Default)]
1049pub struct GetTimeSeriesCrossParamsBuilder {
1050    /// Base currency symbol
1051    base: String,
1052    /// Quote currency symbol
1053    quote: String,
1054    /// Interval between two consecutive points in time series
1055    interval: String,
1056    /// Base instrument type according to the `/instrument_type` endpoint
1057    base_type: Option<String>,
1058    /// Base exchange
1059    base_exchange: Option<String>,
1060    /// Base MIC code
1061    base_mic_code: Option<String>,
1062    /// Quote instrument type according to the `/instrument_type` endpoint
1063    quote_type: Option<String>,
1064    /// Quote exchange
1065    quote_exchange: Option<String>,
1066    /// Quote MIC code
1067    quote_mic_code: Option<String>,
1068    /// 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
1069    outputsize: Option<i64>,
1070    /// Format of the response data
1071    format: Option<String>,
1072    /// Delimiter used in CSV file
1073    delimiter: Option<String>,
1074    /// 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.
1075    prepost: Option<bool>,
1076    /// Start date for the time series data
1077    start_date: Option<String>,
1078    /// End date for the time series data
1079    end_date: Option<String>,
1080    /// Specifies if there should be an adjustment
1081    adjust: Option<bool>,
1082    /// Specifies the number of decimal places for floating values. Should be in range [0, 11] inclusive.
1083    dp: Option<i64>,
1084    /// 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>
1085    timezone: Option<String>
1086}
1087
1088impl GetTimeSeriesCrossParamsBuilder {
1089    /// Base currency symbol
1090    pub fn base(mut self, base: impl Into<String>) -> Self {
1091        self.base = base.into();
1092        self
1093    }
1094    /// Quote currency symbol
1095    pub fn quote(mut self, quote: impl Into<String>) -> Self {
1096        self.quote = quote.into();
1097        self
1098    }
1099    /// Interval between two consecutive points in time series
1100    pub fn interval(mut self, interval: impl Into<String>) -> Self {
1101        self.interval = interval.into();
1102        self
1103    }
1104    /// Base instrument type according to the `/instrument_type` endpoint
1105    pub fn base_type(mut self, base_type: impl Into<String>) -> Self {
1106        self.base_type = Some(base_type.into());
1107        self
1108    }
1109    /// Base exchange
1110    pub fn base_exchange(mut self, base_exchange: impl Into<String>) -> Self {
1111        self.base_exchange = Some(base_exchange.into());
1112        self
1113    }
1114    /// Base MIC code
1115    pub fn base_mic_code(mut self, base_mic_code: impl Into<String>) -> Self {
1116        self.base_mic_code = Some(base_mic_code.into());
1117        self
1118    }
1119    /// Quote instrument type according to the `/instrument_type` endpoint
1120    pub fn quote_type(mut self, quote_type: impl Into<String>) -> Self {
1121        self.quote_type = Some(quote_type.into());
1122        self
1123    }
1124    /// Quote exchange
1125    pub fn quote_exchange(mut self, quote_exchange: impl Into<String>) -> Self {
1126        self.quote_exchange = Some(quote_exchange.into());
1127        self
1128    }
1129    /// Quote MIC code
1130    pub fn quote_mic_code(mut self, quote_mic_code: impl Into<String>) -> Self {
1131        self.quote_mic_code = Some(quote_mic_code.into());
1132        self
1133    }
1134    /// 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
1135    pub fn outputsize(mut self, outputsize: i64) -> Self {
1136        self.outputsize = Some(outputsize);
1137        self
1138    }
1139    /// Format of the response data
1140    pub fn format(mut self, format: impl Into<String>) -> Self {
1141        self.format = Some(format.into());
1142        self
1143    }
1144    /// Delimiter used in CSV file
1145    pub fn delimiter(mut self, delimiter: impl Into<String>) -> Self {
1146        self.delimiter = Some(delimiter.into());
1147        self
1148    }
1149    /// 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.
1150    pub fn prepost(mut self, prepost: bool) -> Self {
1151        self.prepost = Some(prepost);
1152        self
1153    }
1154    /// Start date for the time series data
1155    pub fn start_date(mut self, start_date: impl Into<String>) -> Self {
1156        self.start_date = Some(start_date.into());
1157        self
1158    }
1159    /// End date for the time series data
1160    pub fn end_date(mut self, end_date: impl Into<String>) -> Self {
1161        self.end_date = Some(end_date.into());
1162        self
1163    }
1164    /// Specifies if there should be an adjustment
1165    pub fn adjust(mut self, adjust: bool) -> Self {
1166        self.adjust = Some(adjust);
1167        self
1168    }
1169    /// Specifies the number of decimal places for floating values. Should be in range [0, 11] inclusive.
1170    pub fn dp(mut self, dp: i64) -> Self {
1171        self.dp = Some(dp);
1172        self
1173    }
1174    /// 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>
1175    pub fn timezone(mut self, timezone: impl Into<String>) -> Self {
1176        self.timezone = Some(timezone.into());
1177        self
1178    }
1179
1180    /// Build the parameter struct
1181    pub fn build(self) -> GetTimeSeriesCrossParams {
1182        GetTimeSeriesCrossParams {
1183            base: self.base,
1184            quote: self.quote,
1185            interval: self.interval,
1186            base_type: self.base_type,
1187            base_exchange: self.base_exchange,
1188            base_mic_code: self.base_mic_code,
1189            quote_type: self.quote_type,
1190            quote_exchange: self.quote_exchange,
1191            quote_mic_code: self.quote_mic_code,
1192            outputsize: self.outputsize,
1193            format: self.format,
1194            delimiter: self.delimiter,
1195            prepost: self.prepost,
1196            start_date: self.start_date,
1197            end_date: self.end_date,
1198            adjust: self.adjust,
1199            dp: self.dp,
1200            timezone: self.timezone
1201        }
1202    }
1203}
1204
1205
1206/// struct for typed errors of method [`get_currency_conversion`]
1207#[derive(Debug, Clone, Serialize, Deserialize)]
1208#[serde(untagged)]
1209pub enum GetCurrencyConversionError {
1210    UnknownValue(serde_json::Value),
1211}
1212
1213/// struct for typed errors of method [`get_eod`]
1214#[derive(Debug, Clone, Serialize, Deserialize)]
1215#[serde(untagged)]
1216pub enum GetEodError {
1217    UnknownValue(serde_json::Value),
1218}
1219
1220/// struct for typed errors of method [`get_exchange_rate`]
1221#[derive(Debug, Clone, Serialize, Deserialize)]
1222#[serde(untagged)]
1223pub enum GetExchangeRateError {
1224    UnknownValue(serde_json::Value),
1225}
1226
1227/// struct for typed errors of method [`get_market_movers`]
1228#[derive(Debug, Clone, Serialize, Deserialize)]
1229#[serde(untagged)]
1230pub enum GetMarketMoversError {
1231    UnknownValue(serde_json::Value),
1232}
1233
1234/// struct for typed errors of method [`get_price`]
1235#[derive(Debug, Clone, Serialize, Deserialize)]
1236#[serde(untagged)]
1237pub enum GetPriceError {
1238    UnknownValue(serde_json::Value),
1239}
1240
1241/// struct for typed errors of method [`get_quote`]
1242#[derive(Debug, Clone, Serialize, Deserialize)]
1243#[serde(untagged)]
1244pub enum GetQuoteError {
1245    UnknownValue(serde_json::Value),
1246}
1247
1248/// struct for typed errors of method [`get_time_series`]
1249#[derive(Debug, Clone, Serialize, Deserialize)]
1250#[serde(untagged)]
1251pub enum GetTimeSeriesError {
1252    UnknownValue(serde_json::Value),
1253}
1254
1255/// struct for typed errors of method [`get_time_series_cross`]
1256#[derive(Debug, Clone, Serialize, Deserialize)]
1257#[serde(untagged)]
1258pub enum GetTimeSeriesCrossError {
1259    UnknownValue(serde_json::Value),
1260}
1261
1262
1263/// 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.
1264pub async fn get_currency_conversion(configuration: &configuration::Configuration, params: GetCurrencyConversionParams) -> Result<models::GetCurrencyConversion200Response, 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", &param_value.to_string())]);
1281    }
1282    if let Some(ref param_value) = p_query_format {
1283        req_builder = req_builder.query(&[("format", &serde_json::to_string(param_value)?)]);
1284    }
1285    if let Some(ref param_value) = p_query_delimiter {
1286        req_builder = req_builder.query(&[("delimiter", &param_value.to_string())]);
1287    }
1288    if let Some(ref param_value) = p_query_dp {
1289        req_builder = req_builder.query(&[("dp", &param_value.to_string())]);
1290    }
1291    if let Some(ref param_value) = p_query_timezone {
1292        req_builder = req_builder.query(&[("timezone", &param_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 Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetCurrencyConversion200Response`"))),
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::GetCurrencyConversion200Response`")))),
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 { status, content, entity }))
1328    }
1329}
1330
1331/// 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.
1332pub async fn get_eod(configuration: &configuration::Configuration, params: GetEodParams) -> Result<models::GetEod200Response, Error<GetEodError>> {
1333    // Extract parameters from params struct
1334    let p_query_symbol = params.symbol;
1335    let p_query_figi = params.figi;
1336    let p_query_isin = params.isin;
1337    let p_query_cusip = params.cusip;
1338    let p_query_exchange = params.exchange;
1339    let p_query_mic_code = params.mic_code;
1340    let p_query_country = params.country;
1341    let p_query_type = params.r#type;
1342    let p_query_date = params.date;
1343    let p_query_prepost = params.prepost;
1344    let p_query_dp = params.dp;
1345
1346    let uri_str = format!("{}/eod", configuration.base_path);
1347    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1348
1349    if let Some(ref param_value) = p_query_symbol {
1350        req_builder = req_builder.query(&[("symbol", &param_value.to_string())]);
1351    }
1352    if let Some(ref param_value) = p_query_figi {
1353        req_builder = req_builder.query(&[("figi", &param_value.to_string())]);
1354    }
1355    if let Some(ref param_value) = p_query_isin {
1356        req_builder = req_builder.query(&[("isin", &param_value.to_string())]);
1357    }
1358    if let Some(ref param_value) = p_query_cusip {
1359        req_builder = req_builder.query(&[("cusip", &param_value.to_string())]);
1360    }
1361    if let Some(ref param_value) = p_query_exchange {
1362        req_builder = req_builder.query(&[("exchange", &param_value.to_string())]);
1363    }
1364    if let Some(ref param_value) = p_query_mic_code {
1365        req_builder = req_builder.query(&[("mic_code", &param_value.to_string())]);
1366    }
1367    if let Some(ref param_value) = p_query_country {
1368        req_builder = req_builder.query(&[("country", &param_value.to_string())]);
1369    }
1370    if let Some(ref param_value) = p_query_type {
1371        req_builder = req_builder.query(&[("type", &serde_json::to_string(param_value)?)]);
1372    }
1373    if let Some(ref param_value) = p_query_date {
1374        req_builder = req_builder.query(&[("date", &param_value.to_string())]);
1375    }
1376    if let Some(ref param_value) = p_query_prepost {
1377        req_builder = req_builder.query(&[("prepost", &param_value.to_string())]);
1378    }
1379    if let Some(ref param_value) = p_query_dp {
1380        req_builder = req_builder.query(&[("dp", &param_value.to_string())]);
1381    }
1382    if let Some(ref user_agent) = configuration.user_agent {
1383        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1384    }
1385    if let Some(ref apikey) = configuration.api_key {
1386        let key = apikey.key.clone();
1387        let value = match apikey.prefix {
1388            Some(ref prefix) => format!("{} {}", prefix, key),
1389            None => key,
1390        };
1391        req_builder = req_builder.header("Authorization", value);
1392    };
1393
1394    let req = req_builder.build()?;
1395    let resp = configuration.client.execute(req).await?;
1396
1397    let status = resp.status();
1398    let content_type = resp
1399        .headers()
1400        .get("content-type")
1401        .and_then(|v| v.to_str().ok())
1402        .unwrap_or("application/octet-stream");
1403    let content_type = super::ContentType::from(content_type);
1404
1405    if !status.is_client_error() && !status.is_server_error() {
1406        let content = resp.text().await?;
1407        match content_type {
1408            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1409            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetEod200Response`"))),
1410            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::GetEod200Response`")))),
1411        }
1412    } else {
1413        let content = resp.text().await?;
1414        let entity: Option<GetEodError> = serde_json::from_str(&content).ok();
1415        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1416    }
1417}
1418
1419/// 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.
1420pub async fn get_exchange_rate(configuration: &configuration::Configuration, params: GetExchangeRateParams) -> Result<models::GetExchangeRate200Response, Error<GetExchangeRateError>> {
1421    // Extract parameters from params struct
1422    let p_query_symbol = params.symbol;
1423    let p_query_date = params.date;
1424    let p_query_format = params.format;
1425    let p_query_delimiter = params.delimiter;
1426    let p_query_dp = params.dp;
1427    let p_query_timezone = params.timezone;
1428
1429    let uri_str = format!("{}/exchange_rate", configuration.base_path);
1430    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1431
1432    req_builder = req_builder.query(&[("symbol", &p_query_symbol.to_string())]);
1433    if let Some(ref param_value) = p_query_date {
1434        req_builder = req_builder.query(&[("date", &param_value.to_string())]);
1435    }
1436    if let Some(ref param_value) = p_query_format {
1437        req_builder = req_builder.query(&[("format", &serde_json::to_string(param_value)?)]);
1438    }
1439    if let Some(ref param_value) = p_query_delimiter {
1440        req_builder = req_builder.query(&[("delimiter", &param_value.to_string())]);
1441    }
1442    if let Some(ref param_value) = p_query_dp {
1443        req_builder = req_builder.query(&[("dp", &param_value.to_string())]);
1444    }
1445    if let Some(ref param_value) = p_query_timezone {
1446        req_builder = req_builder.query(&[("timezone", &param_value.to_string())]);
1447    }
1448    if let Some(ref user_agent) = configuration.user_agent {
1449        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1450    }
1451    if let Some(ref apikey) = configuration.api_key {
1452        let key = apikey.key.clone();
1453        let value = match apikey.prefix {
1454            Some(ref prefix) => format!("{} {}", prefix, key),
1455            None => key,
1456        };
1457        req_builder = req_builder.header("Authorization", value);
1458    };
1459
1460    let req = req_builder.build()?;
1461    let resp = configuration.client.execute(req).await?;
1462
1463    let status = resp.status();
1464    let content_type = resp
1465        .headers()
1466        .get("content-type")
1467        .and_then(|v| v.to_str().ok())
1468        .unwrap_or("application/octet-stream");
1469    let content_type = super::ContentType::from(content_type);
1470
1471    if !status.is_client_error() && !status.is_server_error() {
1472        let content = resp.text().await?;
1473        match content_type {
1474            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1475            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetExchangeRate200Response`"))),
1476            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::GetExchangeRate200Response`")))),
1477        }
1478    } else {
1479        let content = resp.text().await?;
1480        let entity: Option<GetExchangeRateError> = serde_json::from_str(&content).ok();
1481        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1482    }
1483}
1484
1485/// 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.
1486pub async fn get_market_movers(configuration: &configuration::Configuration, params: GetMarketMoversParams) -> Result<models::MarketMoversResponseBody, Error<GetMarketMoversError>> {
1487    // Extract parameters from params struct
1488    let p_path_market = params.market;
1489    let p_query_direction = params.direction;
1490    let p_query_outputsize = params.outputsize;
1491    let p_query_country = params.country;
1492    let p_query_price_greater_than = params.price_greater_than;
1493    let p_query_dp = params.dp;
1494
1495    let uri_str = format!("{}/market_movers/{market}", configuration.base_path, market=crate::apis::urlencode(p_path_market));
1496    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1497
1498    if let Some(ref param_value) = p_query_direction {
1499        req_builder = req_builder.query(&[("direction", &serde_json::to_string(param_value)?)]);
1500    }
1501    if let Some(ref param_value) = p_query_outputsize {
1502        req_builder = req_builder.query(&[("outputsize", &param_value.to_string())]);
1503    }
1504    if let Some(ref param_value) = p_query_country {
1505        req_builder = req_builder.query(&[("country", &param_value.to_string())]);
1506    }
1507    if let Some(ref param_value) = p_query_price_greater_than {
1508        req_builder = req_builder.query(&[("price_greater_than", &param_value.to_string())]);
1509    }
1510    if let Some(ref param_value) = p_query_dp {
1511        req_builder = req_builder.query(&[("dp", &param_value.to_string())]);
1512    }
1513    if let Some(ref user_agent) = configuration.user_agent {
1514        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1515    }
1516    if let Some(ref apikey) = configuration.api_key {
1517        let key = apikey.key.clone();
1518        let value = match apikey.prefix {
1519            Some(ref prefix) => format!("{} {}", prefix, key),
1520            None => key,
1521        };
1522        req_builder = req_builder.header("Authorization", value);
1523    };
1524
1525    let req = req_builder.build()?;
1526    let resp = configuration.client.execute(req).await?;
1527
1528    let status = resp.status();
1529    let content_type = resp
1530        .headers()
1531        .get("content-type")
1532        .and_then(|v| v.to_str().ok())
1533        .unwrap_or("application/octet-stream");
1534    let content_type = super::ContentType::from(content_type);
1535
1536    if !status.is_client_error() && !status.is_server_error() {
1537        let content = resp.text().await?;
1538        match content_type {
1539            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1540            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::MarketMoversResponseBody`"))),
1541            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::MarketMoversResponseBody`")))),
1542        }
1543    } else {
1544        let content = resp.text().await?;
1545        let entity: Option<GetMarketMoversError> = serde_json::from_str(&content).ok();
1546        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1547    }
1548}
1549
1550/// 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.
1551pub async fn get_price(configuration: &configuration::Configuration, params: GetPriceParams) -> Result<models::GetPrice200Response, Error<GetPriceError>> {
1552    // Extract parameters from params struct
1553    let p_query_symbol = params.symbol;
1554    let p_query_figi = params.figi;
1555    let p_query_isin = params.isin;
1556    let p_query_cusip = params.cusip;
1557    let p_query_exchange = params.exchange;
1558    let p_query_mic_code = params.mic_code;
1559    let p_query_country = params.country;
1560    let p_query_type = params.r#type;
1561    let p_query_format = params.format;
1562    let p_query_delimiter = params.delimiter;
1563    let p_query_prepost = params.prepost;
1564    let p_query_dp = params.dp;
1565
1566    let uri_str = format!("{}/price", configuration.base_path);
1567    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1568
1569    if let Some(ref param_value) = p_query_symbol {
1570        req_builder = req_builder.query(&[("symbol", &param_value.to_string())]);
1571    }
1572    if let Some(ref param_value) = p_query_figi {
1573        req_builder = req_builder.query(&[("figi", &param_value.to_string())]);
1574    }
1575    if let Some(ref param_value) = p_query_isin {
1576        req_builder = req_builder.query(&[("isin", &param_value.to_string())]);
1577    }
1578    if let Some(ref param_value) = p_query_cusip {
1579        req_builder = req_builder.query(&[("cusip", &param_value.to_string())]);
1580    }
1581    if let Some(ref param_value) = p_query_exchange {
1582        req_builder = req_builder.query(&[("exchange", &param_value.to_string())]);
1583    }
1584    if let Some(ref param_value) = p_query_mic_code {
1585        req_builder = req_builder.query(&[("mic_code", &param_value.to_string())]);
1586    }
1587    if let Some(ref param_value) = p_query_country {
1588        req_builder = req_builder.query(&[("country", &param_value.to_string())]);
1589    }
1590    if let Some(ref param_value) = p_query_type {
1591        req_builder = req_builder.query(&[("type", &serde_json::to_string(param_value)?)]);
1592    }
1593    if let Some(ref param_value) = p_query_format {
1594        req_builder = req_builder.query(&[("format", &serde_json::to_string(param_value)?)]);
1595    }
1596    if let Some(ref param_value) = p_query_delimiter {
1597        req_builder = req_builder.query(&[("delimiter", &param_value.to_string())]);
1598    }
1599    if let Some(ref param_value) = p_query_prepost {
1600        req_builder = req_builder.query(&[("prepost", &param_value.to_string())]);
1601    }
1602    if let Some(ref param_value) = p_query_dp {
1603        req_builder = req_builder.query(&[("dp", &param_value.to_string())]);
1604    }
1605    if let Some(ref user_agent) = configuration.user_agent {
1606        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1607    }
1608    if let Some(ref apikey) = configuration.api_key {
1609        let key = apikey.key.clone();
1610        let value = match apikey.prefix {
1611            Some(ref prefix) => format!("{} {}", prefix, key),
1612            None => key,
1613        };
1614        req_builder = req_builder.header("Authorization", value);
1615    };
1616
1617    let req = req_builder.build()?;
1618    let resp = configuration.client.execute(req).await?;
1619
1620    let status = resp.status();
1621    let content_type = resp
1622        .headers()
1623        .get("content-type")
1624        .and_then(|v| v.to_str().ok())
1625        .unwrap_or("application/octet-stream");
1626    let content_type = super::ContentType::from(content_type);
1627
1628    if !status.is_client_error() && !status.is_server_error() {
1629        let content = resp.text().await?;
1630        match content_type {
1631            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1632            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetPrice200Response`"))),
1633            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::GetPrice200Response`")))),
1634        }
1635    } else {
1636        let content = resp.text().await?;
1637        let entity: Option<GetPriceError> = serde_json::from_str(&content).ok();
1638        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1639    }
1640}
1641
1642/// 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.
1643pub async fn get_quote(configuration: &configuration::Configuration, params: GetQuoteParams) -> Result<models::GetQuote200Response, Error<GetQuoteError>> {
1644    // Extract parameters from params struct
1645    let p_query_symbol = params.symbol;
1646    let p_query_figi = params.figi;
1647    let p_query_isin = params.isin;
1648    let p_query_cusip = params.cusip;
1649    let p_query_interval = params.interval;
1650    let p_query_exchange = params.exchange;
1651    let p_query_mic_code = params.mic_code;
1652    let p_query_country = params.country;
1653    let p_query_volume_time_period = params.volume_time_period;
1654    let p_query_type = params.r#type;
1655    let p_query_format = params.format;
1656    let p_query_delimiter = params.delimiter;
1657    let p_query_prepost = params.prepost;
1658    let p_query_eod = params.eod;
1659    let p_query_rolling_period = params.rolling_period;
1660    let p_query_dp = params.dp;
1661    let p_query_timezone = params.timezone;
1662
1663    let uri_str = format!("{}/quote", configuration.base_path);
1664    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1665
1666    if let Some(ref param_value) = p_query_symbol {
1667        req_builder = req_builder.query(&[("symbol", &param_value.to_string())]);
1668    }
1669    if let Some(ref param_value) = p_query_figi {
1670        req_builder = req_builder.query(&[("figi", &param_value.to_string())]);
1671    }
1672    if let Some(ref param_value) = p_query_isin {
1673        req_builder = req_builder.query(&[("isin", &param_value.to_string())]);
1674    }
1675    if let Some(ref param_value) = p_query_cusip {
1676        req_builder = req_builder.query(&[("cusip", &param_value.to_string())]);
1677    }
1678    if let Some(ref param_value) = p_query_interval {
1679        req_builder = req_builder.query(&[("interval", &serde_json::to_string(param_value)?)]);
1680    }
1681    if let Some(ref param_value) = p_query_exchange {
1682        req_builder = req_builder.query(&[("exchange", &param_value.to_string())]);
1683    }
1684    if let Some(ref param_value) = p_query_mic_code {
1685        req_builder = req_builder.query(&[("mic_code", &param_value.to_string())]);
1686    }
1687    if let Some(ref param_value) = p_query_country {
1688        req_builder = req_builder.query(&[("country", &param_value.to_string())]);
1689    }
1690    if let Some(ref param_value) = p_query_volume_time_period {
1691        req_builder = req_builder.query(&[("volume_time_period", &param_value.to_string())]);
1692    }
1693    if let Some(ref param_value) = p_query_type {
1694        req_builder = req_builder.query(&[("type", &serde_json::to_string(param_value)?)]);
1695    }
1696    if let Some(ref param_value) = p_query_format {
1697        req_builder = req_builder.query(&[("format", &serde_json::to_string(param_value)?)]);
1698    }
1699    if let Some(ref param_value) = p_query_delimiter {
1700        req_builder = req_builder.query(&[("delimiter", &param_value.to_string())]);
1701    }
1702    if let Some(ref param_value) = p_query_prepost {
1703        req_builder = req_builder.query(&[("prepost", &param_value.to_string())]);
1704    }
1705    if let Some(ref param_value) = p_query_eod {
1706        req_builder = req_builder.query(&[("eod", &param_value.to_string())]);
1707    }
1708    if let Some(ref param_value) = p_query_rolling_period {
1709        req_builder = req_builder.query(&[("rolling_period", &param_value.to_string())]);
1710    }
1711    if let Some(ref param_value) = p_query_dp {
1712        req_builder = req_builder.query(&[("dp", &param_value.to_string())]);
1713    }
1714    if let Some(ref param_value) = p_query_timezone {
1715        req_builder = req_builder.query(&[("timezone", &param_value.to_string())]);
1716    }
1717    if let Some(ref user_agent) = configuration.user_agent {
1718        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1719    }
1720    if let Some(ref apikey) = configuration.api_key {
1721        let key = apikey.key.clone();
1722        let value = match apikey.prefix {
1723            Some(ref prefix) => format!("{} {}", prefix, key),
1724            None => key,
1725        };
1726        req_builder = req_builder.header("Authorization", value);
1727    };
1728
1729    let req = req_builder.build()?;
1730    let resp = configuration.client.execute(req).await?;
1731
1732    let status = resp.status();
1733    let content_type = resp
1734        .headers()
1735        .get("content-type")
1736        .and_then(|v| v.to_str().ok())
1737        .unwrap_or("application/octet-stream");
1738    let content_type = super::ContentType::from(content_type);
1739
1740    if !status.is_client_error() && !status.is_server_error() {
1741        let content = resp.text().await?;
1742        match content_type {
1743            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1744            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetQuote200Response`"))),
1745            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::GetQuote200Response`")))),
1746        }
1747    } else {
1748        let content = resp.text().await?;
1749        let entity: Option<GetQuoteError> = serde_json::from_str(&content).ok();
1750        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1751    }
1752}
1753
1754/// 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.
1755pub async fn get_time_series(configuration: &configuration::Configuration, params: GetTimeSeriesParams) -> Result<models::GetTimeSeries200Response, Error<GetTimeSeriesError>> {
1756    // Extract parameters from params struct
1757    let p_query_interval = params.interval;
1758    let p_query_symbol = params.symbol;
1759    let p_query_isin = params.isin;
1760    let p_query_figi = params.figi;
1761    let p_query_cusip = params.cusip;
1762    let p_query_outputsize = params.outputsize;
1763    let p_query_exchange = params.exchange;
1764    let p_query_mic_code = params.mic_code;
1765    let p_query_country = params.country;
1766    let p_query_type = params.r#type;
1767    let p_query_timezone = params.timezone;
1768    let p_query_start_date = params.start_date;
1769    let p_query_end_date = params.end_date;
1770    let p_query_date = params.date;
1771    let p_query_order = params.order;
1772    let p_query_prepost = params.prepost;
1773    let p_query_format = params.format;
1774    let p_query_delimiter = params.delimiter;
1775    let p_query_dp = params.dp;
1776    let p_query_previous_close = params.previous_close;
1777    let p_query_adjust = params.adjust;
1778
1779    let uri_str = format!("{}/time_series", configuration.base_path);
1780    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1781
1782    if let Some(ref param_value) = p_query_symbol {
1783        req_builder = req_builder.query(&[("symbol", &param_value.to_string())]);
1784    }
1785    if let Some(ref param_value) = p_query_isin {
1786        req_builder = req_builder.query(&[("isin", &param_value.to_string())]);
1787    }
1788    if let Some(ref param_value) = p_query_figi {
1789        req_builder = req_builder.query(&[("figi", &param_value.to_string())]);
1790    }
1791    if let Some(ref param_value) = p_query_cusip {
1792        req_builder = req_builder.query(&[("cusip", &param_value.to_string())]);
1793    }
1794    req_builder = req_builder.query(&[("interval", &p_query_interval.to_string())]);
1795    if let Some(ref param_value) = p_query_outputsize {
1796        req_builder = req_builder.query(&[("outputsize", &param_value.to_string())]);
1797    }
1798    if let Some(ref param_value) = p_query_exchange {
1799        req_builder = req_builder.query(&[("exchange", &param_value.to_string())]);
1800    }
1801    if let Some(ref param_value) = p_query_mic_code {
1802        req_builder = req_builder.query(&[("mic_code", &param_value.to_string())]);
1803    }
1804    if let Some(ref param_value) = p_query_country {
1805        req_builder = req_builder.query(&[("country", &param_value.to_string())]);
1806    }
1807    if let Some(ref param_value) = p_query_type {
1808        req_builder = req_builder.query(&[("type", &serde_json::to_string(param_value)?)]);
1809    }
1810    if let Some(ref param_value) = p_query_timezone {
1811        req_builder = req_builder.query(&[("timezone", &param_value.to_string())]);
1812    }
1813    if let Some(ref param_value) = p_query_start_date {
1814        req_builder = req_builder.query(&[("start_date", &param_value.to_string())]);
1815    }
1816    if let Some(ref param_value) = p_query_end_date {
1817        req_builder = req_builder.query(&[("end_date", &param_value.to_string())]);
1818    }
1819    if let Some(ref param_value) = p_query_date {
1820        req_builder = req_builder.query(&[("date", &param_value.to_string())]);
1821    }
1822    if let Some(ref param_value) = p_query_order {
1823        req_builder = req_builder.query(&[("order", &serde_json::to_string(param_value)?)]);
1824    }
1825    if let Some(ref param_value) = p_query_prepost {
1826        req_builder = req_builder.query(&[("prepost", &param_value.to_string())]);
1827    }
1828    if let Some(ref param_value) = p_query_format {
1829        req_builder = req_builder.query(&[("format", &serde_json::to_string(param_value)?)]);
1830    }
1831    if let Some(ref param_value) = p_query_delimiter {
1832        req_builder = req_builder.query(&[("delimiter", &param_value.to_string())]);
1833    }
1834    if let Some(ref param_value) = p_query_dp {
1835        req_builder = req_builder.query(&[("dp", &param_value.to_string())]);
1836    }
1837    if let Some(ref param_value) = p_query_previous_close {
1838        req_builder = req_builder.query(&[("previous_close", &param_value.to_string())]);
1839    }
1840    if let Some(ref param_value) = p_query_adjust {
1841        req_builder = req_builder.query(&[("adjust", &serde_json::to_string(param_value)?)]);
1842    }
1843    if let Some(ref user_agent) = configuration.user_agent {
1844        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1845    }
1846    if let Some(ref apikey) = configuration.api_key {
1847        let key = apikey.key.clone();
1848        let value = match apikey.prefix {
1849            Some(ref prefix) => format!("{} {}", prefix, key),
1850            None => key,
1851        };
1852        req_builder = req_builder.header("Authorization", value);
1853    };
1854
1855    let req = req_builder.build()?;
1856    let resp = configuration.client.execute(req).await?;
1857
1858    let status = resp.status();
1859    let content_type = resp
1860        .headers()
1861        .get("content-type")
1862        .and_then(|v| v.to_str().ok())
1863        .unwrap_or("application/octet-stream");
1864    let content_type = super::ContentType::from(content_type);
1865
1866    if !status.is_client_error() && !status.is_server_error() {
1867        let content = resp.text().await?;
1868        match content_type {
1869            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1870            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetTimeSeries200Response`"))),
1871            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::GetTimeSeries200Response`")))),
1872        }
1873    } else {
1874        let content = resp.text().await?;
1875        let entity: Option<GetTimeSeriesError> = serde_json::from_str(&content).ok();
1876        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1877    }
1878}
1879
1880/// 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.
1881pub async fn get_time_series_cross(configuration: &configuration::Configuration, params: GetTimeSeriesCrossParams) -> Result<models::GetTimeSeriesCross200Response, Error<GetTimeSeriesCrossError>> {
1882    // Extract parameters from params struct
1883    let p_query_base = params.base;
1884    let p_query_quote = params.quote;
1885    let p_query_interval = params.interval;
1886    let p_query_base_type = params.base_type;
1887    let p_query_base_exchange = params.base_exchange;
1888    let p_query_base_mic_code = params.base_mic_code;
1889    let p_query_quote_type = params.quote_type;
1890    let p_query_quote_exchange = params.quote_exchange;
1891    let p_query_quote_mic_code = params.quote_mic_code;
1892    let p_query_outputsize = params.outputsize;
1893    let p_query_format = params.format;
1894    let p_query_delimiter = params.delimiter;
1895    let p_query_prepost = params.prepost;
1896    let p_query_start_date = params.start_date;
1897    let p_query_end_date = params.end_date;
1898    let p_query_adjust = params.adjust;
1899    let p_query_dp = params.dp;
1900    let p_query_timezone = params.timezone;
1901
1902    let uri_str = format!("{}/time_series/cross", configuration.base_path);
1903    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1904
1905    req_builder = req_builder.query(&[("base", &p_query_base.to_string())]);
1906    if let Some(ref param_value) = p_query_base_type {
1907        req_builder = req_builder.query(&[("base_type", &param_value.to_string())]);
1908    }
1909    if let Some(ref param_value) = p_query_base_exchange {
1910        req_builder = req_builder.query(&[("base_exchange", &param_value.to_string())]);
1911    }
1912    if let Some(ref param_value) = p_query_base_mic_code {
1913        req_builder = req_builder.query(&[("base_mic_code", &param_value.to_string())]);
1914    }
1915    req_builder = req_builder.query(&[("quote", &p_query_quote.to_string())]);
1916    if let Some(ref param_value) = p_query_quote_type {
1917        req_builder = req_builder.query(&[("quote_type", &param_value.to_string())]);
1918    }
1919    if let Some(ref param_value) = p_query_quote_exchange {
1920        req_builder = req_builder.query(&[("quote_exchange", &param_value.to_string())]);
1921    }
1922    if let Some(ref param_value) = p_query_quote_mic_code {
1923        req_builder = req_builder.query(&[("quote_mic_code", &param_value.to_string())]);
1924    }
1925    req_builder = req_builder.query(&[("interval", &p_query_interval.to_string())]);
1926    if let Some(ref param_value) = p_query_outputsize {
1927        req_builder = req_builder.query(&[("outputsize", &param_value.to_string())]);
1928    }
1929    if let Some(ref param_value) = p_query_format {
1930        req_builder = req_builder.query(&[("format", &serde_json::to_string(param_value)?)]);
1931    }
1932    if let Some(ref param_value) = p_query_delimiter {
1933        req_builder = req_builder.query(&[("delimiter", &param_value.to_string())]);
1934    }
1935    if let Some(ref param_value) = p_query_prepost {
1936        req_builder = req_builder.query(&[("prepost", &param_value.to_string())]);
1937    }
1938    if let Some(ref param_value) = p_query_start_date {
1939        req_builder = req_builder.query(&[("start_date", &param_value.to_string())]);
1940    }
1941    if let Some(ref param_value) = p_query_end_date {
1942        req_builder = req_builder.query(&[("end_date", &param_value.to_string())]);
1943    }
1944    if let Some(ref param_value) = p_query_adjust {
1945        req_builder = req_builder.query(&[("adjust", &param_value.to_string())]);
1946    }
1947    if let Some(ref param_value) = p_query_dp {
1948        req_builder = req_builder.query(&[("dp", &param_value.to_string())]);
1949    }
1950    if let Some(ref param_value) = p_query_timezone {
1951        req_builder = req_builder.query(&[("timezone", &param_value.to_string())]);
1952    }
1953    if let Some(ref user_agent) = configuration.user_agent {
1954        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1955    }
1956    if let Some(ref apikey) = configuration.api_key {
1957        let key = apikey.key.clone();
1958        let value = match apikey.prefix {
1959            Some(ref prefix) => format!("{} {}", prefix, key),
1960            None => key,
1961        };
1962        req_builder = req_builder.header("Authorization", value);
1963    };
1964
1965    let req = req_builder.build()?;
1966    let resp = configuration.client.execute(req).await?;
1967
1968    let status = resp.status();
1969    let content_type = resp
1970        .headers()
1971        .get("content-type")
1972        .and_then(|v| v.to_str().ok())
1973        .unwrap_or("application/octet-stream");
1974    let content_type = super::ContentType::from(content_type);
1975
1976    if !status.is_client_error() && !status.is_server_error() {
1977        let content = resp.text().await?;
1978        match content_type {
1979            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1980            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetTimeSeriesCross200Response`"))),
1981            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::GetTimeSeriesCross200Response`")))),
1982        }
1983    } else {
1984        let content = resp.text().await?;
1985        let entity: Option<GetTimeSeriesCrossError> = serde_json::from_str(&content).ok();
1986        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1987    }
1988}
1989