1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
#![allow(dead_code)]

use serde::{Deserialize, Serialize};

use std::collections::{HashMap, BTreeMap};

use crate::default::{default_string, default_i32};

// 注意当前设置的数据大小 是否可能会出现溢出情况  这需要我们进行考虑
#[allow(dead_code, non_snake_case)]
#[derive(Serialize, Clone, Deserialize, Debug,Default)]
pub struct Account {
    pub user_id: String,
    pub currency: String,
    pub pre_balance: f64,
    pub deposit: f64,
    pub withdraw: f64,
    pub WithdrawQuota: f64,
    pub close_profit: f64,
    pub commission: f32,
    pub premium: f32,
    pub static_balance: f64,
    pub position_profit: f64,
    pub float_profit: f64,
    pub balance: f64,
    pub margin: f64,
    pub frozen_margin: f64,
    pub frozen_commission: f64,
    pub frozen_premium: f64,
    pub available: f64,
    pub risk_ratio: f64,
}

#[allow(dead_code)]
#[derive(Serialize, Clone, Deserialize, Debug,Default)]
pub struct BankDetail {
    pub id: String,
    pub name: String,
    pub bank_account: String,
    pub fetch_amount: f64,
    pub qry_count: i64,
}

#[allow(dead_code)]
#[derive(Serialize, Clone, Deserialize, Debug,Default)]
pub struct Order {
    pub seqno: i32,
    pub user_id: String,
    pub order_id: String,
    pub exchange_id: String,
    pub instrument_id: String,
    pub direction: String,
    pub offset: String,
    pub volume_orign: f64,
    pub price_type: String,
    pub limit_price: f64,
    pub time_condition: String,
    pub volume_condition: String,
    pub insert_date_time: i64,
    pub exchange_order_id: String,
    pub status: String,
    pub volume_left: f64,
    pub last_msg: String,
}

#[allow(dead_code)]
#[derive(Serialize, Clone, Deserialize, Debug,Default)]
pub struct Position {
    pub user_id: String,
    pub exchange_id: String,
    pub instrument_id: String,
    pub volume_long_today: f64,
    pub volume_long_his: f64,
    pub volume_long: f64,
    pub volume_long_frozen_today: f64,
    pub volume_long_frozen_his: f64,
    pub volume_long_frozen: f64,
    pub volume_short_today: f64,
    pub volume_short_his: f64,
    pub volume_short: f64,
    pub volume_short_frozen_today: f64,
    pub volume_short_frozen_his: f64,
    pub volume_short_frozen: f64,
    pub volume_long_yd: f64,
    pub volume_short_yd: f64,
    pub pos_long_his: f64,
    pub pos_long_today: f64,
    pub pos_short_his: f64,
    pub pos_short_today: f64,
    pub open_price_long: f64,
    pub open_price_short: f64,
    pub open_cost_long: f64,
    pub open_cost_short: f64,
    pub position_price_long: f64,
    pub position_price_short: f64,
    pub position_cost_long: f64,
    pub position_cost_short: f64,
    pub last_price: f64,
    pub float_profit_long: f64,
    pub float_profit_short: f64,
    pub float_profit: f64,
    pub position_profit_long: f64,
    pub position_profit_short: f64,
    pub position_profit: f64,
    pub margin_long: f64,
    pub margin_short: f64,
    pub margin: f64,
}

#[allow(dead_code)]
#[derive(Serialize, Clone, Deserialize, Debug,Default)]
pub struct Trade {
    pub seqno: i32,
    pub user_id: String,
    pub trade_id: String,
    pub exchange_id: String,
    pub instrument_id: String,
    pub order_id: String,
    pub exchange_trade_id: String,
    pub direction: String,
    pub offset: String,
    pub volume: f64,
    pub price: f64,
    pub trade_date_time: i64,
    pub commission: f64,
}

#[allow(dead_code)]
#[derive(Serialize, Clone, Deserialize, Debug,Default)]
pub struct Transfer {
    pub datetime: i64,
    pub currency: String,
    pub amount: f64,
    pub error_id: i16,
    pub error_msg: String,
}

/// QIFI账户数据结构
/// Examples
/// ```
///
/// ```
#[allow(dead_code)]
#[derive(Serialize, Clone, Deserialize, Debug, Default)]
pub struct QIFI {
    #[serde(default = "default_string")]
    pub databaseip: String,
    pub account_cookie: String,
    pub password: String,
    pub portfolio: String,
    pub broker_name: String,
    pub capital_password: String,
    pub bank_password: String,
    pub bankid: String,
    pub investor_name: String,
    pub money: f64,
    pub pub_host: String,
    pub settlement: HashMap<String, String>,
    // 是一个字典是否考虑反序列化
    // #[serde(default="default_i32")]
    pub taskid: String,
    pub trade_host: String,
    pub updatetime: String,
    pub wsuri: String,
    pub bankname: String,
    pub trading_day: String,
    pub status: i16,
    pub accounts: Account,
    // 注意下面都是不确定的
    pub banks: HashMap<String, BankDetail>,
    #[serde(default = "Default::default")]
    pub event: HashMap<String, String>,
    pub orders: BTreeMap<String, Order>,
    pub positions: HashMap<String, Position>,
    pub trades: BTreeMap<String, Trade>,
    pub transfers: BTreeMap<String, Transfer>,
    #[serde(default = "default_i32")]
    pub ping_gap: i32,
    pub eventmq_ip: String,
}