db: add sandbox deployment & fix master deployment
This commit is contained in:
parent
cbf03bcaed
commit
c8ebe26078
|
@ -19,3 +19,4 @@ bench = false
|
||||||
[dependencies]
|
[dependencies]
|
||||||
chrono = "0.4"
|
chrono = "0.4"
|
||||||
postgres = "0.17.3"
|
postgres = "0.17.3"
|
||||||
|
postgres-types = {version = "0.1.1", features = ["derive"]}
|
||||||
|
|
|
@ -8,6 +8,8 @@ services:
|
||||||
POSTGRES_DB: pt_db
|
POSTGRES_DB: pt_db
|
||||||
POSTGRES_USER: pt_usr
|
POSTGRES_USER: pt_usr
|
||||||
POSTGRES_PASSWORD: test
|
POSTGRES_PASSWORD: test
|
||||||
|
ports:
|
||||||
|
- 5432:5432
|
||||||
adminer:
|
adminer:
|
||||||
image: adminer
|
image: adminer
|
||||||
restart: always
|
restart: always
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
version: '3.1'
|
||||||
|
|
||||||
|
services:
|
||||||
|
db:
|
||||||
|
image: postgres
|
||||||
|
restart: always
|
||||||
|
environment:
|
||||||
|
POSTGRES_DB: pt_db
|
||||||
|
POSTGRES_USER: pt_usr
|
||||||
|
POSTGRES_PASSWORD: test
|
||||||
|
ports:
|
||||||
|
- 5432:5432
|
||||||
|
adminer:
|
||||||
|
image: adminer
|
||||||
|
restart: always
|
||||||
|
ports:
|
||||||
|
- 8080:8080
|
|
@ -0,0 +1,7 @@
|
||||||
|
FROM rust
|
||||||
|
|
||||||
|
# Set up Root directory project
|
||||||
|
RUN mkdir /pt_proj/
|
||||||
|
WORKDIR pt_proj
|
||||||
|
|
||||||
|
ENTRYPOINT [ "cargo", "run", "sandbox" ]
|
|
@ -0,0 +1,3 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
docker-compose -f ../DockerFiles/dockComp_sandbox.yml up
|
|
@ -1,4 +1,28 @@
|
||||||
|
use libtrader::ds::account::account::Account;
|
||||||
|
use libtrader::ds::account::portfolio::Portfolio;
|
||||||
|
|
||||||
|
use postgres::{Client, NoTls};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
let account = Account{
|
||||||
|
username: "test".to_string(),
|
||||||
|
email: "email".to_string(),
|
||||||
|
is_pass: true,
|
||||||
|
pass_hash: "passhash".to_string(),
|
||||||
|
portfolio: Portfolio{
|
||||||
|
position_history: Vec::new(),
|
||||||
|
open_positions: Vec::new()
|
||||||
|
},
|
||||||
|
transactions: Vec::new()
|
||||||
|
};
|
||||||
|
|
||||||
|
let mut client = Client::connect("host=localhost port=5432 user=pt_usr password=test dbname=pt_db", NoTls).unwrap();
|
||||||
|
client.batch_execute("
|
||||||
|
CREATE TABLE accounts (
|
||||||
|
id SERIAL PRIMARY KEY,
|
||||||
|
acct CHAR
|
||||||
|
)").unwrap();
|
||||||
|
|
||||||
println!("Hello World!");
|
println!("Hello World!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
|
use postgres_types::{ToSql, FromSql};
|
||||||
|
|
||||||
use crate::ds::account::portfolio::Portfolio;
|
use crate::ds::account::portfolio::Portfolio;
|
||||||
|
|
||||||
#[derive(PartialEq, Debug)]
|
#[derive(PartialEq, Debug, ToSql, FromSql)]
|
||||||
pub struct Account {
|
pub struct Account {
|
||||||
pub username: String,
|
pub username: String,
|
||||||
pub email: String,
|
pub email: String,
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
|
use postgres_types::{ToSql, FromSql};
|
||||||
|
|
||||||
use crate::ds::account::position::Position;
|
use crate::ds::account::position::Position;
|
||||||
|
|
||||||
#[derive(PartialEq, Debug)]
|
#[derive(PartialEq, Debug, ToSql, FromSql)]
|
||||||
pub struct Portfolio {
|
pub struct Portfolio {
|
||||||
pub position_history: Vec<Position>,
|
pub position_history: Vec<Position>,
|
||||||
pub open_positions: Vec<Position>
|
pub open_positions: Vec<Position>
|
||||||
|
|
|
@ -1,19 +1,21 @@
|
||||||
|
use postgres_types::{ToSql, FromSql};
|
||||||
|
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
|
|
||||||
#[derive(PartialEq, Debug)]
|
#[derive(PartialEq, Debug, ToSql, FromSql)]
|
||||||
pub enum PositionType { Sell, Buy }
|
pub enum PositionType { Sell, Buy }
|
||||||
|
|
||||||
#[derive(PartialEq, Debug)]
|
#[derive(PartialEq, Debug, ToSql, FromSql)]
|
||||||
pub struct Position {
|
pub struct Position {
|
||||||
pub action_type: PositionType,
|
pub action_type: PositionType,
|
||||||
pub stock_symbol: String,
|
pub stock_symbol: String,
|
||||||
pub stock_open_amount: isize,
|
pub stock_open_amount: i64,
|
||||||
pub stock_open_price: f64,
|
pub stock_open_price: f64,
|
||||||
pub stock_open_cost: f64,
|
pub stock_open_cost: f64,
|
||||||
pub stock_close_amount: isize,
|
pub stock_close_amount: i64,
|
||||||
pub stock_close_price: f64,
|
pub stock_close_price: f64,
|
||||||
pub stock_close_cost: f64,
|
pub stock_close_cost: f64,
|
||||||
pub open_date: DateTime<Utc>,
|
//pub open_date: DateTime<Utc>,
|
||||||
pub close_date: DateTime<Utc>,
|
//pub close_date: DateTime<Utc>,
|
||||||
pub is_open: bool,
|
pub is_open: bool,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue