Skip to content

Commit

Permalink
complete
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul-Folbrecht committed Dec 2, 2024
1 parent 54a3d1d commit fd14a52
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 24 deletions.
10 changes: 5 additions & 5 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 Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
members = ["core", "domain", "services", "server", "backtest"]

[workspace.package]
version = "0.1.0"
version = "0.9.0"
authors = ["Paul Folbrecht <[email protected]>"]
edition = "2021"
documentation = ""
Expand Down
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,17 @@ Output will include generated realized P&L and open positions.

## Docker

To build the image:
To build the image for x86-64/AMD64, first run

`docker build -t algo-trading .`
`rustup target add x86_64-unknown-linux-gnu`

then build with

`docker build --platform=linux/amd64 -t algo-trading .`

or

`docker build --platform linux/x86-64 -t algo-trading .`

To tag for GCP Registry:

Expand Down
5 changes: 3 additions & 2 deletions app_config/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
[package]
name = "app-config"
version = "0.1.0"
edition = "2021"
version.workspace = true
edition.workspace = true
authors.workspace = true

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand Down
7 changes: 3 additions & 4 deletions backtest/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
[package]
name = "backtest"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
version.workspace = true
edition.workspace = true
authors.workspace = true

[dependencies]
app-config = { path = "../app_config" }
Expand Down
5 changes: 3 additions & 2 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
[package]
name = "core"
version = "0.1.0"
edition = "2021"
version.workspace = true
edition.workspace = true
authors.workspace = true

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand Down
5 changes: 3 additions & 2 deletions domain/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
[package]
name = "domain"
version = "0.1.0"
edition = "2021"
version.workspace = true
edition.workspace = true
authors.workspace = true

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand Down
5 changes: 3 additions & 2 deletions server/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
[package]
name = "server"
version = "0.1.0"
edition = "2021"
version.workspace = true
edition.workspace = true
authors.workspace = true

[dependencies]
app-config = { path = "../app_config" }
Expand Down
10 changes: 6 additions & 4 deletions server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,27 @@ use services::{historical_data, market_data, orders, trading};
use services::{market_data::MarketDataService, persistence};

fn main() {
log4rs::init_file("config/log4rs.yaml", Default::default()).unwrap();
let config = AppConfig::new().expect("Could not load config");
log4rs::init_file("config/log4rs.yaml", Default::default())
.expect("Failed to load log4rs config");
let config = AppConfig::new().expect("Failed to parse config");
info!("Config:\n{:?}", config);

let mut today = Local::now().naive_local().date();
let (mut shutdown, mut handle) = init_for_new_day(today, config.clone());

loop {
thread::sleep(Duration::from_secs(300));
let now = Local::now().naive_local().date();

if Local::now().naive_local().date() > today {
if now > today {
shutdown.store(true, std::sync::atomic::Ordering::Relaxed);

handle
.join()
.expect("Failed to join MarketDataService thread");
info!("All threads exited successfully");

today = Local::now().naive_local().date();
today = now;
info!("Trading day ended - resetting for {}", today);
(shutdown, handle) = init_for_new_day(today, config.clone());
}
Expand Down

0 comments on commit fd14a52

Please sign in to comment.