Skip to content

Commit

Permalink
#
Browse files Browse the repository at this point in the history
  • Loading branch information
yutiansut committed Jan 2, 2022
1 parent bd9ae21 commit 45cf6be
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 8 deletions.
21 changes: 14 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion qapro-rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
25 changes: 25 additions & 0 deletions qapro-rs/examples/factorplayground.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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());
}

0 comments on commit 45cf6be

Please sign in to comment.