use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use super::asset::{KAsset, KAssetPair};
use super::{
EndpointInfo, KrakenInput, LedgerType, MethodType, OrderCloseTime, OrderFlags, OrderType,
TradeHistoryType, TradeType,
};
use super::{Input, InputList, InputListItem, IntoInputList, MutateInput, Output, UpdateInput};
pub mod account_balance;
pub mod trade_balance;
pub mod open_orders;
pub mod closed_orders;
pub mod query_orders;
pub mod trade_history;
pub mod query_trades;
pub mod open_positions;
pub mod ledger_info;
pub mod query_ledgers;
pub mod trade_volume;
pub mod add_order;
pub mod cancel_order;
pub mod cancel_all_orders;
pub mod cancel_on_timeout;
#[derive(Deserialize, Serialize, Debug)]
pub struct KOOrderDescription {
pub pair: String,
#[serde(rename = "type")]
pub tradetype: String,
pub ordertype: String,
pub price: String,
pub price2: String,
pub leverage: String,
#[serde(rename = "order")]
pub desc: String,
#[serde(rename = "close")]
pub closedesc: String,
}
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "lowercase")]
pub enum KOOrderStatus {
Pending,
Open,
Closed,
Canceled,
Expired,
}
#[derive(Deserialize, Serialize, Debug)]
pub struct KOOrderInfo {
pub refid: Option<String>,
pub userref: Option<u32>,
pub status: KOOrderStatus,
pub opentm: f64,
pub starttm: f64,
pub expiretm: f64,
pub descr: KOOrderDescription,
pub vol: String,
pub vol_exec: String,
pub cost: String,
pub fee: String,
pub price: String,
pub stopprice: Option<String>,
pub limitprice: Option<String>,
pub misc: String,
pub oflags: String,
pub trades: Option<Vec<String>>,
pub closetm: Option<f64>,
pub reason: Option<String>,
}
#[derive(Deserialize, Serialize, Debug)]
pub struct KOTradeData {
pub ordertxid: String,
pub pair: String,
pub time: f64,
#[serde(rename = "type")]
pub tradetype: String,
pub ordertype: String,
pub price: String,
pub cost: String,
pub fee: String,
pub vol: String,
pub margin: Option<String>,
pub misc: String,
pub posstatus: Option<String>,
pub cprice: Option<String>,
pub cfee: Option<String>,
pub cvol: Option<String>,
pub cmargin: Option<String>,
pub net: Option<String>,
pub trades: Option<String>,
}
#[derive(Deserialize, Serialize, Debug)]
pub struct KOLedgerInfo {
pub refid: String,
pub time: f64,
#[serde(rename = "type")]
pub ledgertype: String,
pub aclass: String,
pub asset: String,
pub amount: String,
pub fee: String,
pub balance: Option<String>,
}
#[derive(Deserialize, Serialize, Debug)]
pub struct KOLedgers {
#[serde(flatten)]
pub ledgers: HashMap<String, KOLedgerInfo>,
}
impl Output for KOLedgers {}