Skip to content

Commit d6519b6

Browse files
committed
fix(a lot of things): bump to v0.4.0
rustdx-cmd: * 移除所有异步依赖,因为请求量很少,不需要引入复杂的代码 * 移除所有不需要的代码和依赖(使用 cargo-udeps 检测到未使用的依赖)
1 parent 96ce220 commit d6519b6

16 files changed

+301
-1985
lines changed

Cargo.lock

Lines changed: 81 additions & 1119 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "rustdx"
3-
version = "0.3.0"
4-
edition = "2018"
3+
version = "0.4.0"
4+
edition = "2021"
55
license = "MIT"
66
description = "受 pytdx 启发的 A 股数据获取库"
77
repository = "https://github.com/zjp-CN/rustdx"

rustdx-cmd/Cargo.toml

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "rustdx-cmd"
3-
version = "0.3.0"
4-
edition = "2018"
3+
version = "0.4.0"
4+
edition = "2021"
55
license = "MIT"
66
build = "build.rs"
77
readme = "../README.md"
@@ -15,31 +15,29 @@ exclude = [
1515

1616
[dependencies]
1717
anyhow = "1"
18-
argh = {version = "0.1" }
19-
calamine = {version = "0.19"}
20-
futures = {version = "0.3" }
21-
tokio = {version = "1", features = ["rt-multi-thread", "macros"] }
22-
# rustdx = {path = "../" }
23-
reqwest = {version = "0.11"}
24-
bytes = {version = "1.1" }
25-
csv = {version = "1.1" }
26-
log = {version = "0.4" }
27-
chrono = {version = "0.4" }
28-
serde_json = {version = "1"}
29-
lazy_static = {version = "1"}
30-
mini-redis = {version = "0.4"}
31-
subprocess = {version = "0.2"}
32-
simplelog = {version ="0.12"}
33-
miniz_oxide = {version ="0.7"}
18+
argh = "0.1"
19+
calamine = "0.19"
20+
csv = "1.1"
21+
log = "0.4"
22+
chrono = "0.4"
23+
serde_json = "1"
24+
lazy_static = "1"
25+
subprocess = "0.2"
26+
miniz_oxide = "0.7"
3427

3528
[dependencies.rustdx]
36-
version = "0.3.0"
29+
version = "0.4.0"
3730
path = "../"
3831

3932
[dependencies.serde]
4033
version = "1"
4134
features = ["derive"]
4235

36+
[dependencies.ureq]
37+
version = "2"
38+
default_features = false
39+
features = ["rustls"]
40+
4341
[[bin]]
4442
name = "rustdx"
4543
path = "src/main.rs"

rustdx-cmd/examples/clickhouse-cmd.rs

Lines changed: 0 additions & 133 deletions
This file was deleted.

rustdx-cmd/examples/csv.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ fn example() -> Result<(), Box<dyn Error>> {
1414
.filter_map(|f| f.ok())
1515
.map(|f: Factor| (f.code.clone(), f))
1616
.collect();
17-
println!("{:?}", hm);
17+
println!("{hm:?}");
1818
Ok(())
1919
}
2020

2121
fn main() {
2222
if let Err(err) = example() {
23-
println!("error running example: {}", err);
23+
println!("error running example: {err}");
2424
process::exit(1);
2525
}
2626
}

rustdx-cmd/examples/excel.rs

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,22 @@ fn main() -> Result<()> {
1212
read_excel("../assets/xlsx/主板A股-sse.xlsx", Sse)?;
1313
read_excel("../assets/xlsx/主板A股-sse.xls", Sse)?;
1414

15-
let rt = tokio::runtime::Runtime::new()?;
16-
// rt.block_on(async {
17-
// // get_xlsx(Sse).await?;
18-
// get_xlsx(Szse).await?;
19-
// Ok::<(), anyhow::Error>(())
20-
// })?;
21-
rt.block_on(get_xlsx(Szse))?;
15+
get_xlsx(Szse)?;
2216
read_excel("../assets/xlsx/szse.xlsx", Szse)?;
2317

2418
Ok(())
2519
}
2620

2721
/// Sse 股票列表数据暂时无法直接获取到,而且获取到的 xls 签名不是 ole ,无法解析。
2822
/// 所以只能手动下载,用 excel 保存为 xlsx 或 xls 。
29-
async fn get_xlsx(ex: Exchange) -> Result<()> {
23+
fn get_xlsx(ex: Exchange) -> Result<()> {
3024
let (url, fname) = match ex{
3125
Exchange::Szse=>("http://www.szse.cn/api/report/ShowReport?SHOWTYPE=xlsx&CATALOGID=1110&TABKEY=tab1&random=0.8587844061443386","../assets/xlsx/szse.xlsx"),
3226
Exchange::Sse => ("http://query.sse.com.cn/security/stock/downloadStockListFile.do?csrcCode=&stockCode=&areaName=&stockType=1", "../assets/xlsx/sse.xls")
3327
};
34-
let bytes = reqwest::get(url).await?.bytes().await?;
35-
std::fs::write(fname, bytes)?;
28+
let buf = &mut Vec::with_capacity(1 << 20);
29+
ureq::get(url).call()?.into_reader().read_to_end(buf)?;
30+
std::fs::write(fname, buf)?;
3631
Ok(())
3732
}
3833

@@ -44,10 +39,10 @@ enum Exchange {
4439
Szse,
4540
}
4641

47-
type Reader = std::io::BufReader<std::fs::File>;
48-
fn read_excel(path: &str, ex: Exchange) -> Result<Sheets<Reader>> {
42+
type FsReader = std::io::BufReader<std::fs::File>;
43+
fn read_excel(path: &str, ex: Exchange) -> Result<Sheets<FsReader>> {
4944
let now = Instant::now();
50-
let mut workbook = open_workbook_auto(&path)?;
45+
let mut workbook = open_workbook_auto(path)?;
5146
println!(
5247
"{:30}:{} s",
5348
path,
@@ -90,7 +85,7 @@ const fn match_ex(ex: Exchange) -> usize {
9085
}
9186

9287
/// 每个单元格被解析的类型可能会不一样,所以把股票代码统一转化成字符型
93-
fn get_string<'a>(cell: &'a DataType) -> std::borrow::Cow<'a, str> {
88+
fn get_string(cell: &DataType) -> std::borrow::Cow<'_, str> {
9489
match cell {
9590
DataType::Int(x) => x.to_string().into(),
9691
DataType::Float(x) => (*x as i64).to_string().into(),

0 commit comments

Comments
 (0)