clean: make line length consistent to 120
This commit is contained in:
parent
442ec5cd1a
commit
1c725e28a4
|
@ -33,13 +33,15 @@ pub fn get_stock_from_db(state: &mut GlobalState, searched_symbol: String) -> Re
|
|||
/*
|
||||
* Returns all stock values from database since a time epoch.
|
||||
*/
|
||||
pub fn get_stock_from_db_since_epoch(state: &mut GlobalState, searched_symbol: String, time_epoch: i64) -> Result<Vec<StockVal>, String> {
|
||||
pub fn get_stock_from_db_since_epoch(state: &mut GlobalState, searched_symbol: String,
|
||||
time_epoch: i64) -> Result<Vec<StockVal>, String> {
|
||||
// Connect to database.
|
||||
let mut client = db_connect(state, DB_USER, DB_PASS)?;
|
||||
|
||||
// Query database for table.
|
||||
let mut stocks: Vec<StockVal> = Vec::new();
|
||||
match client.query(format!("SELECT * FROM asset_schema.{} WHERE time_since_epoch >= {}", searched_symbol, time_epoch).as_str(), &[]) {
|
||||
match client.query(format!("SELECT * FROM asset_schema.{} WHERE time_since_epoch >= {}", searched_symbol,
|
||||
time_epoch).as_str(), &[]) {
|
||||
Ok(all_rows) => {
|
||||
for row in all_rows {
|
||||
let mut val: StockVal = StockVal::default();
|
||||
|
@ -60,13 +62,15 @@ pub fn get_stock_from_db_since_epoch(state: &mut GlobalState, searched_symbol: S
|
|||
/*
|
||||
* Returns all stock values from database between two time epochs.
|
||||
*/
|
||||
pub fn get_stock_from_db_between_epochs(state: &mut GlobalState, searched_symbol: String, first_time_epoch: i64, second_time_epoch: i64) -> Result<Vec<StockVal>, String> {
|
||||
pub fn get_stock_from_db_between_epochs(state: &mut GlobalState, searched_symbol: String, first_time_epoch: i64,
|
||||
second_time_epoch: i64) -> Result<Vec<StockVal>, String> {
|
||||
// Connect to database.
|
||||
let mut client = db_connect(state, DB_USER, DB_PASS)?;
|
||||
|
||||
// Query database for table.
|
||||
let mut stocks: Vec<StockVal> = Vec::new();
|
||||
match client.query(format!("SELECT * FROM asset_schema.{} WHERE time_since_epoch >= {} AND time_since_epoch <= {}", searched_symbol, first_time_epoch, second_time_epoch).as_str(), &[]) {
|
||||
match client.query(format!("SELECT * FROM asset_schema.{} WHERE time_since_epoch >= {} AND time_since_epoch <= {}",
|
||||
searched_symbol, first_time_epoch, second_time_epoch).as_str(), &[]) {
|
||||
Ok(all_rows) => {
|
||||
for row in all_rows {
|
||||
let mut val: StockVal = StockVal::default();
|
||||
|
|
|
@ -2,7 +2,8 @@ use crate::db::config::{*};
|
|||
use crate::ds::server::global_state::GlobalState;
|
||||
use crate::ds::generic::company::Company;
|
||||
|
||||
pub fn db_connect(state: &mut GlobalState, user: &'static str, pass: &'static str) -> Result<postgres::Client, String> {
|
||||
pub fn db_connect(state: &mut GlobalState, user: &'static str,
|
||||
pass: &'static str) -> Result<postgres::Client, String> {
|
||||
/* Generate the requested string */
|
||||
state.db_connect_str = format!("host={} port={} dbname={} user={} password={}",
|
||||
DB_HOST, DB_HOST_PORT, DB_NAME, user, pass);
|
||||
|
|
|
@ -12,6 +12,7 @@ pub struct Account {
|
|||
|
||||
impl std::fmt::Display for Account {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "({}, {}, {}, {}, {}, {:#?})", self.username, self.email, self.is_pass, self.pass_hash, self.portfolio, self.transactions)
|
||||
write!(f, "({}, {}, {}, {}, {}, {:#?})", self.username, self.email, self.is_pass, self.pass_hash,
|
||||
self.portfolio, self.transactions)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ pub struct Order {
|
|||
}
|
||||
impl std::fmt::Display for Order {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "({}, {}, {}, {}, {}, {}, {})", self.action_type, self.stock_symbol, self.stock_price, self.stock_amount, self.stock_amount, self.stock_filled, self.is_filled)
|
||||
write!(f, "({}, {}, {}, {}, {}, {}, {})", self.action_type, self.stock_symbol, self.stock_price,
|
||||
self.stock_amount, self.stock_amount, self.stock_filled, self.is_filled)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,8 @@ pub struct Position {
|
|||
}
|
||||
impl std::fmt::Display for Position {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "({}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {})", self.action_type, self.stock_symbol, self.stock_open_amount, self.stock_open_price, self.stock_open_cost, self.stock_close_amount, self.stock_close_price, self.stock_close_cost, self.open_epoch, self.close_epoch, self.is_open)
|
||||
write!(f, "({}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {})", self.action_type, self.stock_symbol,
|
||||
self.stock_open_amount, self.stock_open_price, self.stock_open_cost, self.stock_close_amount,
|
||||
self.stock_close_price, self.stock_close_cost, self.open_epoch, self.close_epoch, self.is_open)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ pub struct Company {
|
|||
}
|
||||
impl std::fmt::Display for Company {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "({}, {}, {}, {}, {}, {}, {}, {}, {})", self.id, self.symbol, self.isin, self.company_name, self.primary_exchange, self.sector, self.industry, self.primary_sic_code, self.employees)
|
||||
write!(f, "({}, {}, {}, {}, {}, {}, {}, {}, {})", self.id, self.symbol, self.isin, self.company_name,
|
||||
self.primary_exchange, self.sector, self.industry, self.primary_sic_code, self.employees)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ pub struct StockVal {
|
|||
}
|
||||
impl std::fmt::Display for StockVal {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "({}, {}, {}, {}, {}, {})", self.id, self.isin, self.time_since_epoch, self.ask_price, self.bid_price, self.volume)
|
||||
write!(f, "({}, {}, {}, {}, {}, {})", self.id, self.isin, self.time_since_epoch, self.ask_price,
|
||||
self.bid_price, self.volume)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ pub struct Message {
|
|||
}
|
||||
impl std::fmt::Display for Message {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "({}, {}, {}, {}, {}, {}, {:#?})", self.message_type, self.instruction, self.data_size, self.argument_count, self.data_message_number, self.data_message_max, self.data)
|
||||
write!(f, "({}, {}, {}, {}, {}, {}, {:#?})", self.message_type, self.instruction, self.data_size,
|
||||
self.argument_count, self.data_message_number, self.data_message_max, self.data)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user