add: StockVal

- change 'numeric' to 'bigint' in 002_table_stock
- add StockVal file
- add mod.rs file for ds/generic
- use StockVal and Company in global_state.rs
- make application buildable
This commit is contained in:
realaltffour 2020-07-24 11:19:56 +03:00
parent cb8a6ce2aa
commit e476538035
No known key found for this signature in database
GPG Key ID: C1265D839D44DCB1
7 changed files with 20 additions and 4 deletions

View File

@ -2,7 +2,7 @@ use libtrader::initializer::libtrader_init;
fn main() {
match libtrader_init() {
Ok(()) => println!("connected successfully"),
Ok(state) => println!("inited state: {:?}", state),
Err(err) => println!("Failed with error: {}", err),
}

View File

@ -2,7 +2,7 @@ CREATE TABLE asset_schema.stock_vals (
id BIGSERIAL PRIMARY KEY,
isin text NOT NULL,
time_since_epoch timestamp NOT NULL,
ask_price numeric NOT NULL,
bid_price numeric NOT NULL,
ask_price bigint NOT NULL,
bid_price bigint NOT NULL,
volume bigint NOT NULL
)

View File

@ -1,3 +1,4 @@
#[derive(Default, PartialEq, Debug)]
pub struct Company {
pub id: u8,
pub symbol: String,

View File

@ -0,0 +1,2 @@
pub mod company;
pub mod stock_val;

View File

@ -0,0 +1,9 @@
#[derive(Default, PartialEq, Debug)]
pub struct StockVal {
pub id: u8,
pub isin: String,
pub time_since_epoch: i128,
pub ask_price: i8,
pub bid_price: i8,
pub volume: i8
}

View File

@ -1,3 +1,4 @@
pub mod generic;
pub mod account;
pub mod server;
pub mod message;

View File

@ -5,6 +5,9 @@ use crate::ds::server::master_state::MasterState;
#[allow(unused_imports)]
use crate::ds::server::worker_state::WorkerState;
use crate::ds::generic::company::Company;
use crate::ds::generic::stock_val::StockVal;
#[derive(Default, PartialEq, Debug)]
pub struct GlobalState {
#[cfg(feature="master_server")]
@ -12,6 +15,6 @@ pub struct GlobalState {
#[cfg(feature="worker_server")]
pub state: WorkerState,
pub companies: HashMap<String, Companies>,
pub companies: HashMap<String, Company>,
pub stock_vals: HashMap<String, StockVal>,
}