#![allow(dead_code)]
use crate::client::AkShareClient;
use crate::error::Result;
use crate::types::MacroDataPoint;
use super::shared::fetch_jin10_report;
impl AkShareClient {
pub async fn euro_gdp_yoy(&self) -> Result<Vec<MacroDataPoint>> {
fetch_jin10_report(self, "84", "Euro GDP YoY").await
}
pub async fn euro_cpi_mom(&self) -> Result<Vec<MacroDataPoint>> {
fetch_jin10_report(self, "84", "Euro CPI MoM").await
}
pub async fn euro_cpi_yoy(&self) -> Result<Vec<MacroDataPoint>> {
fetch_jin10_report(self, "8", "Euro CPI YoY").await
}
pub async fn euro_ppi_mom(&self) -> Result<Vec<MacroDataPoint>> {
fetch_jin10_report(self, "36", "Euro PPI MoM").await
}
pub async fn euro_retail_sales_mom(&self) -> Result<Vec<MacroDataPoint>> {
fetch_jin10_report(self, "38", "Euro Retail Sales MoM").await
}
pub async fn euro_employment_change_qoq(&self) -> Result<Vec<MacroDataPoint>> {
fetch_jin10_report(self, "14", "Euro Employment Change QoQ").await
}
pub async fn euro_unemployment_rate(&self) -> Result<Vec<MacroDataPoint>> {
fetch_jin10_report(self, "46", "Euro Unemployment Rate").await
}
pub async fn euro_trade_balance(&self) -> Result<Vec<MacroDataPoint>> {
fetch_jin10_report(self, "43", "Euro Trade Balance").await
}
pub async fn euro_current_account_mom(&self) -> Result<Vec<MacroDataPoint>> {
fetch_jin10_report(self, "11", "Euro Current Account MoM").await
}
pub async fn euro_industrial_production_mom(&self) -> Result<Vec<MacroDataPoint>> {
fetch_jin10_report(self, "19", "Euro Industrial Production MoM").await
}
pub async fn euro_manufacturing_pmi(&self) -> Result<Vec<MacroDataPoint>> {
fetch_jin10_report(self, "30", "Euro Manufacturing PMI").await
}
pub async fn euro_services_pmi(&self) -> Result<Vec<MacroDataPoint>> {
fetch_jin10_report(self, "41", "Euro Services PMI").await
}
pub async fn euro_zew_economic_sentiment(&self) -> Result<Vec<MacroDataPoint>> {
fetch_jin10_report(self, "48", "Euro ZEW Economic Sentiment").await
}
pub async fn euro_sentix_investor_confidence(&self) -> Result<Vec<MacroDataPoint>> {
fetch_jin10_report(self, "40", "Euro Sentix Investor Confidence").await
}
}
use serde::Deserialize;
#[derive(Debug, Deserialize)]
struct Jin10CdnResp {
values: Option<serde_json::Value>,
keys: Option<Vec<serde_json::Value>>,
}
impl AkShareClient {
pub async fn euro_lme_holding(&self) -> Result<Vec<MacroDataPoint>> {
let url = "https://cdn.jin10.com/data_center/reports/lme_position.json";
let resp: Jin10CdnResp = self.get(url).send().await?.json().await?;
let values = resp.values.unwrap_or_default();
let mut items = Vec::new();
if let Some(obj) = values.as_object() {
for (date, row) in obj {
if let Some(cols) = row.as_object() {
for (col_name, col_data) in cols {
if let Some(arr) = col_data.as_array()
&& let Some(val) = arr.first().and_then(serde_json::Value::as_f64)
{
items.push(MacroDataPoint {
date: date.clone(),
value: val,
name: format!("LME Holding {col_name}"),
});
}
}
}
}
}
items.sort_by(|a, b| a.date.cmp(&b.date));
Ok(items)
}
pub async fn euro_lme_stock(&self) -> Result<Vec<MacroDataPoint>> {
let url = "https://cdn.jin10.com/data_center/reports/lme_stock.json";
let resp: Jin10CdnResp = self.get(url).send().await?.json().await?;
let values = resp.values.unwrap_or_default();
let mut items = Vec::new();
if let Some(obj) = values.as_object() {
for (date, row) in obj {
if let Some(cols) = row.as_object() {
for (col_name, col_data) in cols {
if let Some(arr) = col_data.as_array()
&& let Some(val) = arr.first().and_then(serde_json::Value::as_f64)
{
items.push(MacroDataPoint {
date: date.clone(),
value: val,
name: format!("LME Stock {col_name}"),
});
}
}
}
}
}
items.sort_by(|a, b| a.date.cmp(&b.date));
Ok(items)
}
}
impl AkShareClient {
pub async fn macro_euro_cpi_mom(&self) -> Result<Vec<MacroDataPoint>> {
self.euro_cpi_mom().await
}
pub async fn macro_euro_cpi_yoy(&self) -> Result<Vec<MacroDataPoint>> {
self.euro_cpi_yoy().await
}
pub async fn macro_euro_current_account_mom(&self) -> Result<Vec<MacroDataPoint>> {
self.euro_current_account_mom().await
}
pub async fn macro_euro_employment_change_qoq(&self) -> Result<Vec<MacroDataPoint>> {
self.euro_employment_change_qoq().await
}
pub async fn macro_euro_gdp_yoy(&self) -> Result<Vec<MacroDataPoint>> {
self.euro_gdp_yoy().await
}
pub async fn macro_euro_industrial_production_mom(&self) -> Result<Vec<MacroDataPoint>> {
self.euro_industrial_production_mom().await
}
pub async fn macro_euro_lme_holding(&self) -> Result<Vec<MacroDataPoint>> {
self.euro_lme_holding().await
}
pub async fn macro_euro_lme_stock(&self) -> Result<Vec<MacroDataPoint>> {
self.euro_lme_stock().await
}
pub async fn macro_euro_manufacturing_pmi(&self) -> Result<Vec<MacroDataPoint>> {
self.euro_manufacturing_pmi().await
}
pub async fn macro_euro_ppi_mom(&self) -> Result<Vec<MacroDataPoint>> {
self.euro_ppi_mom().await
}
pub async fn macro_euro_retail_sales_mom(&self) -> Result<Vec<MacroDataPoint>> {
self.euro_retail_sales_mom().await
}
pub async fn macro_euro_sentix_investor_confidence(&self) -> Result<Vec<MacroDataPoint>> {
self.euro_sentix_investor_confidence().await
}
pub async fn macro_euro_services_pmi(&self) -> Result<Vec<MacroDataPoint>> {
self.euro_services_pmi().await
}
pub async fn macro_euro_trade_balance(&self) -> Result<Vec<MacroDataPoint>> {
self.euro_trade_balance().await
}
pub async fn macro_euro_zew_economic_sentiment(&self) -> Result<Vec<MacroDataPoint>> {
self.euro_zew_economic_sentiment().await
}
pub async fn macro_euro_unemployment_rate_mom(&self) -> Result<Vec<MacroDataPoint>> {
self.euro_unemployment_rate().await
}
}