|
|
@@ -79,12 +79,14 @@ impl Account {
|
|
|
}
|
|
|
|
|
|
/// 交易结构体(订单流)
|
|
|
+/// - `id(String)`: id
|
|
|
/// - `time(Decimal)`: 交易更新时间戳(ms)
|
|
|
/// - `size(Decimal)`: 交易量,负数是卖方
|
|
|
/// - `price(Decimal)`: 成交价格
|
|
|
/// - `symbol(String)`: 成交符号
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
|
|
pub struct Trade {
|
|
|
+ pub id: String,
|
|
|
pub time: Decimal,
|
|
|
pub size: Decimal,
|
|
|
pub price: Decimal,
|
|
|
@@ -96,25 +98,25 @@ pub struct Trade {
|
|
|
/// - `1(Decimal)`: 交易量,负数是卖方
|
|
|
/// - `2(Decimal)`: 成交价格
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
|
|
-pub struct SpecialTrade(pub Vec<Decimal>);
|
|
|
+pub struct SpecialTrade(pub Vec<String>);
|
|
|
impl SpecialTrade {
|
|
|
// 获取内部 Vec<Decimal> 的引用
|
|
|
- pub fn inner(&self) -> &Vec<Decimal> {
|
|
|
+ pub fn inner(&self) -> &Vec<String> {
|
|
|
&self.0
|
|
|
}
|
|
|
|
|
|
// 获取内部 Vec<Decimal> 的可变引用
|
|
|
- pub fn inner_mut(&mut self) -> &mut Vec<Decimal> {
|
|
|
+ pub fn inner_mut(&mut self) -> &mut Vec<String> {
|
|
|
&mut self.0
|
|
|
}
|
|
|
|
|
|
// 索引访问特定元素
|
|
|
- pub fn get(&self, index: usize) -> Option<&Decimal> {
|
|
|
+ pub fn get(&self, index: usize) -> Option<&String> {
|
|
|
self.0.get(index)
|
|
|
}
|
|
|
|
|
|
pub fn new(trade: &Trade) -> SpecialTrade {
|
|
|
- SpecialTrade(vec![trade.time, trade.size, trade.price])
|
|
|
+ SpecialTrade(vec![trade.id.clone(), trade.time.to_string(), trade.size.to_string(), trade.price.to_string()])
|
|
|
}
|
|
|
}
|
|
|
|