use crate::core::types::Symbol;
pub struct JQuantsUrls {
pub rest_base: &'static str,
}
impl Default for JQuantsUrls {
fn default() -> Self {
Self {
rest_base: "https://api.jquants.com/v1",
}
}
}
#[derive(Debug, Clone)]
pub enum JQuantsEndpoint {
AuthUser, AuthRefresh,
DailyQuotes,
ListedInfo,
Indices, IndicesTopix,
DerivativesFutures, DerivativesOptions,
FinStatements, FinDividend, FinAnnouncement,
MarketsTradingByType, MarketsShortSelling, MarketsBreakdown, MarketsMargin, MarketsTradingCalendar,
OptionIndexOption, }
impl JQuantsEndpoint {
pub fn path(&self) -> &'static str {
match self {
Self::AuthUser => "/token/auth_user",
Self::AuthRefresh => "/token/auth_refresh",
Self::DailyQuotes => "/prices/daily_quotes",
Self::ListedInfo => "/listed/info",
Self::Indices => "/indices",
Self::IndicesTopix => "/indices/topix",
Self::DerivativesFutures => "/derivatives/futures",
Self::DerivativesOptions => "/derivatives/options",
Self::FinStatements => "/fins/statements",
Self::FinDividend => "/fins/dividend",
Self::FinAnnouncement => "/fins/announcement",
Self::MarketsTradingByType => "/markets/trading_by_type",
Self::MarketsShortSelling => "/markets/short_selling",
Self::MarketsBreakdown => "/markets/breakdown",
Self::MarketsMargin => "/markets/margin",
Self::MarketsTradingCalendar => "/markets/trading_calendar",
Self::OptionIndexOption => "/option/index_option",
}
}
}
pub fn _parse_symbol(code: &str) -> Symbol {
Symbol {
base: code.to_string(),
quote: "JPY".to_string(),
raw: Some(code.to_string()),
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_parse_symbol() {
let symbol = _parse_symbol("6758");
assert_eq!(symbol.base, "6758");
assert_eq!(symbol.quote, "JPY");
}
}