diff --git a/Cargo.lock b/Cargo.lock index c30ea2557..199f268ed 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1967,6 +1967,12 @@ version = "0.26.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78cc372d058dcf6d5ecd98510e7fbc9e5aec4d21de70f65fea8fecebcd881bd4" +[[package]] +name = "glob" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" + [[package]] name = "gloo-timers" version = "0.2.2" @@ -3335,7 +3341,7 @@ checksum = "58893f751c9b0412871a09abd62ecd2a00298c6c83befa223ef98c52aef40cbe" [[package]] name = "polars" version = "0.18.0" -source = "git+https://github.com/yutiansut/polars.git?rev=cb5b36e897c35404d5e9e77b040b741c1841c81f#cb5b36e897c35404d5e9e77b040b741c1841c81f" +source = "git+https://github.com/yutiansut/polars.git?rev=926a57c874d224119b124bc500be97d6ddb7fc7f#926a57c874d224119b124bc500be97d6ddb7fc7f" dependencies = [ "polars-core", "polars-io", @@ -3345,7 +3351,7 @@ dependencies = [ [[package]] name = "polars-arrow" version = "0.18.0" -source = "git+https://github.com/yutiansut/polars.git?rev=cb5b36e897c35404d5e9e77b040b741c1841c81f#cb5b36e897c35404d5e9e77b040b741c1841c81f" +source = "git+https://github.com/yutiansut/polars.git?rev=926a57c874d224119b124bc500be97d6ddb7fc7f#926a57c874d224119b124bc500be97d6ddb7fc7f" dependencies = [ "arrow2", "hashbrown", @@ -3356,7 +3362,7 @@ dependencies = [ [[package]] name = "polars-core" version = "0.18.0" -source = "git+https://github.com/yutiansut/polars.git?rev=cb5b36e897c35404d5e9e77b040b741c1841c81f#cb5b36e897c35404d5e9e77b040b741c1841c81f" +source = "git+https://github.com/yutiansut/polars.git?rev=926a57c874d224119b124bc500be97d6ddb7fc7f#926a57c874d224119b124bc500be97d6ddb7fc7f" dependencies = [ "ahash", "anyhow", @@ -3383,7 +3389,7 @@ dependencies = [ [[package]] name = "polars-io" version = "0.18.0" -source = "git+https://github.com/yutiansut/polars.git?rev=cb5b36e897c35404d5e9e77b040b741c1841c81f#cb5b36e897c35404d5e9e77b040b741c1841c81f" +source = "git+https://github.com/yutiansut/polars.git?rev=926a57c874d224119b124bc500be97d6ddb7fc7f#926a57c874d224119b124bc500be97d6ddb7fc7f" dependencies = [ "ahash", "anyhow", @@ -3407,9 +3413,10 @@ dependencies = [ [[package]] name = "polars-lazy" version = "0.18.0" -source = "git+https://github.com/yutiansut/polars.git?rev=cb5b36e897c35404d5e9e77b040b741c1841c81f#cb5b36e897c35404d5e9e77b040b741c1841c81f" +source = "git+https://github.com/yutiansut/polars.git?rev=926a57c874d224119b124bc500be97d6ddb7fc7f#926a57c874d224119b124bc500be97d6ddb7fc7f" dependencies = [ "ahash", + "glob", "polars-arrow", "polars-core", "polars-io", @@ -3421,7 +3428,7 @@ dependencies = [ [[package]] name = "polars-time" version = "0.18.0" -source = "git+https://github.com/yutiansut/polars.git?rev=cb5b36e897c35404d5e9e77b040b741c1841c81f#cb5b36e897c35404d5e9e77b040b741c1841c81f" +source = "git+https://github.com/yutiansut/polars.git?rev=926a57c874d224119b124bc500be97d6ddb7fc7f#926a57c874d224119b124bc500be97d6ddb7fc7f" dependencies = [ "chrono", "polars-arrow", @@ -3430,7 +3437,7 @@ dependencies = [ [[package]] name = "polars-utils" version = "0.1.0" -source = "git+https://github.com/yutiansut/polars.git?rev=cb5b36e897c35404d5e9e77b040b741c1841c81f#cb5b36e897c35404d5e9e77b040b741c1841c81f" +source = "git+https://github.com/yutiansut/polars.git?rev=926a57c874d224119b124bc500be97d6ddb7fc7f#926a57c874d224119b124bc500be97d6ddb7fc7f" dependencies = [ "parking_lot 0.11.2", ] diff --git a/qapro-rs/Cargo.toml b/qapro-rs/Cargo.toml index 79b391790..67fb26a07 100644 --- a/qapro-rs/Cargo.toml +++ b/qapro-rs/Cargo.toml @@ -66,7 +66,7 @@ evalexpr = "6.6.0" [dependencies.polars] #version = "0.18.0" git = "https://github.com/yutiansut/polars.git" -rev = "cb5b36e897c35404d5e9e77b040b741c1841c81f" +rev = "926a57c874d224119b124bc500be97d6ddb7fc7f" features = [ "zip_with", "strings", diff --git a/qapro-rs/examples/factorplayground.rs b/qapro-rs/examples/factorplayground.rs index a1d55c29f..dbc72af88 100644 --- a/qapro-rs/examples/factorplayground.rs +++ b/qapro-rs/examples/factorplayground.rs @@ -12,6 +12,7 @@ use qapro_rs::qaconnector::clickhouse::ckclient; use qapro_rs::qaconnector::clickhouse::ckclient::DataConnector; use qapro_rs::qadatastruct::stockday::QADataStruct_StockDay; use qapro_rs::qaenv::localenv::CONFIG; +use qapro_rs::qaaccount::account::QA_Account; #[actix_rt::main] async fn main() { @@ -133,11 +134,35 @@ async fn main() { let dates = rank4["date"].utf8().unwrap(); sw.restart(); + let mut acc = QA_Account::new("test2", "test", "test", 1000000000.0, false, "backtest"); + let mut curdate = ""; for (code, date, close) in izip!(codes, dates, closes) { let code2: &str = code.unwrap(); let date2: &str = date.unwrap(); let close2: f32 = close.unwrap(); + if curdate != date2 { + acc.settle(); + curdate = date2; + } else { + let posx = acc.get_position(code2); + match posx { + Some(pos) => { + if pos.volume_long_his > 0.0 { + acc.sell(code2, 100.0, date2, close2 as f64); + } else { + if rand::random() { + acc.buy(code2, 100.0, date2, close2 as f64); + } + } + } + _ => { + acc.init_h(code2); + } + } + } } + println!("calc get row time {:#?}", sw.elapsed()); + acc.to_csv("".to_string()); }