forked from yutiansut/qatrader-rs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
128 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
pub mod qamongo; | ||
pub mod qawebsocket; | ||
pub mod qaeventmq; | ||
|
||
extern crate ndarray; | ||
|
||
extern crate chrono; | ||
|
@@ -9,43 +10,49 @@ use ndarray::array; | |
|
||
use std::time::Duration; | ||
use std::thread; | ||
use qaeventmq::Subscriber; | ||
use crate::qaeventmq::{Publisher, Callback}; | ||
|
||
use crate::qaeventmq::{Publisher,Subscriber, Callback}; | ||
|
||
fn main() { | ||
|
||
qamongo::query_account("192.168.2.24".to_string(), "288870".to_string()); | ||
let mut puber = qaeventmq::QAEventMQ{ | ||
amqp: "amqp:https://admin:[email protected]:5672/".to_string(), | ||
exchange: "tick".to_string(), | ||
model: "direct".to_string(), | ||
routing_key: "rb2001".to_string() | ||
}; | ||
|
||
|
||
let mut i = 1; | ||
thread::spawn(move|| { | ||
while i<1000 { | ||
puber.publish_routing("s".to_string()); | ||
i+=1; | ||
thread::sleep(Duration::from_secs(1)); | ||
} | ||
}); | ||
// qamongo::query_account("192.168.2.24".to_string(), "288870".to_string()); | ||
// let mut puber = qaeventmq::QAEventMQ{ | ||
// amqp: "amqp:https://admin:[email protected]:5672/".to_string(), | ||
// exchange: "tick".to_string(), | ||
// model: "direct".to_string(), | ||
// routing_key: "rb2001".to_string() | ||
// }; | ||
// | ||
// | ||
// let mut i = 1; | ||
// thread::spawn(move|| { | ||
// while i<1000 { | ||
// puber.publish_routing("s".to_string()); | ||
// i+=1; | ||
// thread::sleep(Duration::from_secs(1)); | ||
// } | ||
// }); | ||
// | ||
// impl Callback for qaeventmq::QAEventMQ{ | ||
// fn callback(&mut self, message:String) -> Option<i32>{ | ||
// println!("receive x! {}",message); | ||
// Some(1) | ||
// } | ||
//} | ||
// let mut client = qaeventmq::QAEventMQ{ | ||
// amqp: "amqp:https://admin:[email protected]:5672/".to_string(), | ||
// exchange: "tick".to_string(), | ||
// model: "direct".to_string(), | ||
// routing_key: "rb2001".to_string() | ||
// }; | ||
// client.subscribe_routing(); | ||
// println!("12212"); | ||
|
||
|
||
qawebsocket::QAtradeR( | ||
"test1".to_string(),"test1".to_string(), "QUANTAXIS".to_string(), "192.168.2.24".to_string(), | ||
"ws:https://192.168.2.118:7988".to_string(), "amqp:https://admin:[email protected]:5672/".to_string()); | ||
|
||
impl Callback for qaeventmq::QAEventMQ{ | ||
fn callback(&mut self, message:String) -> Option<i32>{ | ||
println!("receive x! {}",message); | ||
Some(1) | ||
} | ||
} | ||
let mut client = qaeventmq::QAEventMQ{ | ||
amqp: "amqp:https://admin:[email protected]:5672/".to_string(), | ||
exchange: "tick".to_string(), | ||
model: "direct".to_string(), | ||
routing_key: "rb2001".to_string() | ||
}; | ||
client.subscribe_routing(); | ||
println!("12212"); | ||
// thread::sleep(Duration::from_secs(200)); | ||
// thread::spawn(move || { | ||
// client.subscribe_routing(); | ||
|
@@ -78,25 +85,6 @@ fn main() { | |
|
||
|
||
|
||
fn qatrader(account_cookie:String, password:String, broker:String, wsuri:String){ | ||
|
||
|
||
let mut client = qaeventmq::QAEventMQ{ | ||
amqp: "amqp:https://admin:[email protected]:5672/".to_string(), | ||
exchange: "QAORDER_ROUTER".to_string(), | ||
model: "direct".to_string(), | ||
routing_key: account_cookie | ||
}; | ||
|
||
thread::spawn(move || { | ||
client.subscribe_routing(); | ||
|
||
}); | ||
|
||
|
||
|
||
} | ||
|
||
|
||
fn test_ndarray() { | ||
let a3 = array![[[1, 2], [3, 4]], | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters