From 94f2279762a260edc821ad55285c9b568194cf50 Mon Sep 17 00:00:00 2001 From: Ojietohamen Samuel Date: Thu, 12 Sep 2024 18:11:17 +0100 Subject: [PATCH] chore: remove irrelevant trade_flow_core --- .cargo/config.toml | 29 ---- trade_flow_core/Cargo.toml | 95 ------------ trade_flow_core/README.md | 21 --- trade_flow_core/clippy.toml | 3 - trade_flow_core/daemon/Cargo.toml | 26 ---- trade_flow_core/daemon/src/bin/cli.rs | 30 ---- trade_flow_core/daemon/src/bin/server.rs | 145 ------------------ .../daemon/src/database/postgres.rs | 58 ------- trade_flow_core/daemon/src/lib.rs | 29 ---- trade_flow_core/daemon/src/opt.rs | 66 -------- trade_flow_core/rust-toolchain.toml | 3 - trade_flow_core/rustfmt.toml | 5 - 12 files changed, 510 deletions(-) delete mode 100644 .cargo/config.toml delete mode 100644 trade_flow_core/Cargo.toml delete mode 100644 trade_flow_core/README.md delete mode 100644 trade_flow_core/clippy.toml delete mode 100644 trade_flow_core/daemon/Cargo.toml delete mode 100644 trade_flow_core/daemon/src/bin/cli.rs delete mode 100644 trade_flow_core/daemon/src/bin/server.rs delete mode 100644 trade_flow_core/daemon/src/database/postgres.rs delete mode 100644 trade_flow_core/daemon/src/lib.rs delete mode 100644 trade_flow_core/daemon/src/opt.rs delete mode 100644 trade_flow_core/rust-toolchain.toml delete mode 100644 trade_flow_core/rustfmt.toml diff --git a/.cargo/config.toml b/.cargo/config.toml deleted file mode 100644 index 359dff8..0000000 --- a/.cargo/config.toml +++ /dev/null @@ -1,29 +0,0 @@ -[target.'cfg(all())'] -rustflags = [ - # https://rust-lang.github.io/rust-clippy/master/index.html#drop_non_drop - # Disable this lint as we explicitly drop even when `Drop` is not implemented - "-Aclippy::drop_non_drop", -] - -[target.x86_64-pc-windows-msvc] -rustflags = [ - "-C", "target-feature=+crt-static", -] - -[target.x86_64-apple-darwin] -rustflags = [ - "-C", "link-arg=-undefined", - "-C", "link-arg=dynamic_lookup", -] - -[target.aarch64-apple-darwin] -rustflags = [ - "-C", "link-arg=-undefined", - "-C", "link-arg=dynamic_lookup", -] - -[target.x86_64-unknown-linux-musl] -linker = "rust-lld" -rustflags = [ - "-C", "target-feature=-crt-static", -] diff --git a/trade_flow_core/Cargo.toml b/trade_flow_core/Cargo.toml deleted file mode 100644 index b238994..0000000 --- a/trade_flow_core/Cargo.toml +++ /dev/null @@ -1,95 +0,0 @@ -[workspace] -resolver = "2" -members = ["daemon"] - -[workspace.package] -rust-version = "1.80.1" -version = "0.30.0" -edition = "2021" -authors = ["Nautech Systems "] -description = "A high-performance algorithmic trading platform and event-driven backtester" -documentation = "https://nautilustrader.io/docs" - -[workspace.dependencies] -anyhow = "1.0.86" -bytes = { version = "1.7.1", features = ["serde"] } -chrono = "0.4.38" -derive_builder = "0.20.1" -futures = "0.3.30" -indexmap = { version = "2.5.0", features = ["serde"] } -itertools = "0.12.1" -itoa = "1.0.11" -once_cell = "1.19.0" -log = { version = "0.4.22", features = [ - "std", - "kv_unstable", - "serde", - "release_max_level_debug", -] } -pyo3 = { version = "0.21.2", features = ["rust_decimal"] } -pyo3-asyncio-0-21 = { version = "0.21.0", features = [ - "tokio-runtime", - "tokio", - "attributes", -] } -rand = "0.8.5" -rmp-serde = "1.3.0" -rust_decimal = "1.36.0" -rust_decimal_macros = "1.36.0" -semver = "1.0.23" -serde = { version = "1.0.209", features = ["derive"] } -serde_json = "1.0.127" -strum = { version = "0.26.3", features = ["derive"] } -thiserror = "1.0.63" -thousands = "0.2.0" -tracing = "0.1.40" -tokio = { version = "1.40.0", features = ["full"] } -ustr = { version = "1.0.0", features = ["serde"] } -uuid = { version = "1.10.0", features = ["v4"] } - -# dev-dependencies -criterion = "0.5.1" -float-cmp = "0.9.0" -iai = "0.1.1" -pretty_assertions = "1.4.0" -rstest = "0.21.0" -tempfile = "3.12.0" - -# build-dependencies -cbindgen = "0.26.0" - -[profile.dev] -opt-level = 0 -debug = true -debug-assertions = false # Fails Cython build if true -overflow-checks = true -lto = false -panic = "unwind" -incremental = true -codegen-units = 256 - -[profile.test] -opt-level = 0 -debug = true -debug-assertions = true # Fails Cython build if true (OK for cargo test) -overflow-checks = true -lto = false -incremental = true -codegen-units = 256 - -[profile.release] -opt-level = 3 -debug = false -debug-assertions = false -overflow-checks = false -lto = true -strip = true -panic = "abort" -incremental = false -codegen-units = 1 - -[profile.release-debugging] -inherits = "release" -incremental = true -debug = true -strip = false diff --git a/trade_flow_core/README.md b/trade_flow_core/README.md deleted file mode 100644 index ac984a1..0000000 --- a/trade_flow_core/README.md +++ /dev/null @@ -1,21 +0,0 @@ -# TradeFlow Core - -TradeFlow Core is the backbone of the TradeFlow platform, including Rust libraries for event-driven trading, reinforcement learning, and real-time agents. This program is ideal for quantitative traders due to its dependability, performance, modularity, testability, maintenance, and ease of deployment. - -# Resources - -- https://github.com/MrRobb/gym-rs/ -- https://github.com/MathisWellmann/gym-rs/ -- https://github.com/toybox-rs/Toybox -- https://github.com/LaurentMazare/tch-rs -- https://cffi.readthedocs.io/en/latest/ -- https://github.com/google-deepmind/open_spiel -- https://github.com/PyO3/pyo3 -- https://github.com/tracel-ai/burn/ -- https://github.com/tracel-ai/models -- https://github.com/firecracker-microvm/firecracker -- https://github.com/sonos/tract -- https://github.com/nogibjj/rust-pytorch-gpu-template -- https://www.reddit.com/r/reinforcementlearning/comments/m6nlyl/p_is_anyone_considering_implementing_gym_or_a/ -- https://www.reddit.com/r/rust/comments/101fpkl/deep_learning_in_rust_burn_040_released_and_plans/ -- https://dev.to/louisfd/why-rust-is-the-optimal-choice-for-deep-learning-and-how-to-start-your-journey-with-the-burn-deep-learning-framework-28d7 diff --git a/trade_flow_core/clippy.toml b/trade_flow_core/clippy.toml deleted file mode 100644 index 4c4175b..0000000 --- a/trade_flow_core/clippy.toml +++ /dev/null @@ -1,3 +0,0 @@ -cognitive-complexity-threshold = 15 -allow-expect-in-tests = true -allow-unwrap-in-tests = true diff --git a/trade_flow_core/daemon/Cargo.toml b/trade_flow_core/daemon/Cargo.toml deleted file mode 100644 index 3010e98..0000000 --- a/trade_flow_core/daemon/Cargo.toml +++ /dev/null @@ -1,26 +0,0 @@ -[package] -name = "tradeflow-daemon" -version.workspace = true -edition.workspace = true -authors.workspace = true -description.workspace = true -documentation.workspace = true - -[[bin]] -name = "nautilus" -path = "src/bin/cli.rs" - -[dependencies] -nautilus-common = { path = "../common" } -nautilus-model = { path = "../model" } -nautilus-core = { path = "../core" } -nautilus-infrastructure = { path = "../infrastructure", features = [ - "postgres", -] } -anyhow = { workspace = true } -log = { workspace = true } -tokio = { workspace = true } -clap = { version = "4.5.16", features = ["derive", "env"] } -clap_derive = { version = "4.5.13" } -dotenvy = { version = "0.15.7" } -simple_logger = "5.0.0" diff --git a/trade_flow_core/daemon/src/bin/cli.rs b/trade_flow_core/daemon/src/bin/cli.rs deleted file mode 100644 index f83d1aa..0000000 --- a/trade_flow_core/daemon/src/bin/cli.rs +++ /dev/null @@ -1,30 +0,0 @@ -// ------------------------------------------------------------------------------------------------- -// Copyright (C) 2015-2024 Nautech Systems Pty Ltd. All rights reserved. -// https://nautechsystems.io -// -// Licensed under the GNU Lesser General Public License Version 3.0 (the "License"); -// You may not use this file except in compliance with the License. -// You may obtain a copy of the License at https://www.gnu.org/licenses/lgpl-3.0.en.html -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ------------------------------------------------------------------------------------------------- - -use clap::Parser; -use log::LevelFilter; -use nautilus_cli::opt::NautilusCli; - -#[tokio::main] -async fn main() { - dotenvy::dotenv().ok(); - simple_logger::SimpleLogger::new() - .with_module_level("sqlx", LevelFilter::Off) - .init() - .unwrap(); - if let Err(e) = nautilus_cli::run(NautilusCli::parse()).await { - log::error!("Error executing Nautilus CLI: {}", e); - } -} diff --git a/trade_flow_core/daemon/src/bin/server.rs b/trade_flow_core/daemon/src/bin/server.rs deleted file mode 100644 index eb1f204..0000000 --- a/trade_flow_core/daemon/src/bin/server.rs +++ /dev/null @@ -1,145 +0,0 @@ -use std::collections::HashMap; -use std::fs; -use std::path::PathBuf; -use std::sync::{Arc, Mutex}; - -use actix_web::{web, App, HttpResponse, HttpServer, Responder}; -use serde::{Deserialize, Serialize}; -use log::{info, error}; -use tokio::task; - -// Constants -const TRADE_FLOW_SERVER_PORT: u16 = 9165; - -// Struct to hold the server state -struct ServerState { - basedir: PathBuf, - flows: Arc>>, - task_manager: TaskManager, -} - -// Flow struct placeholder (to be implemented) -#[derive(Serialize, Deserialize)] -struct Flow { - name: String, -} - -impl Flow { - fn from_file(flow: &str) -> Result { - // Implement reading from a file and creating Flow - Ok(Flow { - name: flow.to_string(), - }) - } -} - -// TaskManager placeholder (to be implemented) -struct TaskManager; - -impl TaskManager { - fn new() -> Self { - TaskManager - } - - fn start_process_in_thread(&self, task_name: &str, target_function: F) - where - F: FnOnce() + Send + 'static, - { - // Use tokio::spawn or similar to create tasks - task::spawn(target_function); - } - - fn stop_process(&self, _task_name: &str) -> bool { - // Implement task stopping logic - true - } - - fn list_tasks(&self) -> HashMap { - // Implement logic to list all running tasks - HashMap::new() - } -} - -// Helper function to create basedir based on OS -fn get_basedir() -> PathBuf { - match std::env::consts::OS { - "windows" => PathBuf::from(format!("{}/trade_flow", std::env::var("USERPROFILE").unwrap())), - "linux" | "macos" => { - let home = std::env::var("XDG_STATE_HOME").unwrap_or(std::env::var("HOME").unwrap()); - PathBuf::from(format!("{}/.trade_flow", home)) - } - _ => panic!("Unsupported operating system"), - } -} - -// Routes for the Actix web server - -async fn healthy() -> impl Responder { - HttpResponse::Ok().body("trade_flow is healthy") -} - -async fn environments_available(data: web::Data) -> impl Responder { - // Sample response placeholder (real implementation should load environments) - let environments = vec![ - ("env1", "Description 1", "v1.0"), - ("env2", "Description 2", "v1.1"), - ]; - HttpResponse::Ok().json(environments) -} - -async fn start_task( - data: web::Data, - web::Path((task_name, target_function_name)): web::Path<(String, String)>, -) -> impl Responder { - // Example of starting a task (real function needs to be invoked) - let server_state = data.into_inner(); - let task_manager = &server_state.task_manager; - - task_manager.start_process_in_thread(&task_name, || { - println!("Task {} started!", task_name); - }); - - HttpResponse::Ok().body(format!("Task '{}' started successfully.", task_name)) -} - -async fn stop_task( - data: web::Data, - web::Path(task_name): web::Path, -) -> impl Responder { - let server_state = data.into_inner(); - let task_manager = &server_state.task_manager; - - if task_manager.stop_process(&task_name) { - HttpResponse::Ok().body(format!("Task '{}' stopped successfully.", task_name)) - } else { - HttpResponse::Ok().body(format!("Failed to stop task '{}'.", task_name)) - } -} - -// Main function to start the server -#[actix_web::main] -async fn main() -> std::io::Result<()> { - // Initialize logging - env_logger::init(); - - let basedir = get_basedir(); - let server_state = web::Data::new(ServerState { - basedir, - flows: Arc::new(Mutex::new(HashMap::new())), - task_manager: TaskManager::new(), - }); - - info!("Started server"); - - HttpServer::new(move || { - App::new() - .app_data(server_state.clone()) - .route("/healthy", web::get().to(healthy)) - .route("/environments", web::get().to(environments_available)) - .route("/start_task/{task_name}/{target_function_name}", web::post().to(start_task)) - .route("/stop_task/{task_name}", web::post().to(stop_task)) - }) - .bind(("0.0.0.0", TRADE_FLOW_SERVER_PORT))? - .run() - .await -} diff --git a/trade_flow_core/daemon/src/database/postgres.rs b/trade_flow_core/daemon/src/database/postgres.rs deleted file mode 100644 index 39f3748..0000000 --- a/trade_flow_core/daemon/src/database/postgres.rs +++ /dev/null @@ -1,58 +0,0 @@ -// ------------------------------------------------------------------------------------------------- -// Copyright (C) 2015-2024 Nautech Systems Pty Ltd. All rights reserved. -// https://nautechsystems.io -// -// Licensed under the GNU Lesser General Public License Version 3.0 (the "License"); -// You may not use this file except in compliance with the License. -// You may obtain a copy of the License at https://www.gnu.org/licenses/lgpl-3.0.en.html -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ------------------------------------------------------------------------------------------------- - -use nautilus_infrastructure::sql::pg::{ - connect_pg, drop_postgres, get_postgres_connect_options, init_postgres, -}; - -use crate::opt::{DatabaseCommand, DatabaseOpt}; - -pub async fn run_database_command(opt: DatabaseOpt) -> anyhow::Result<()> { - let command = opt.command.clone(); - - match command { - DatabaseCommand::Init(config) => { - let pg_connect_options = get_postgres_connect_options( - config.host, - config.port, - config.username, - config.password, - config.database, - ) - .unwrap(); - let pg = connect_pg(pg_connect_options.clone().into()).await?; - init_postgres( - &pg, - pg_connect_options.database, - pg_connect_options.password, - config.schema, - ) - .await?; - } - DatabaseCommand::Drop(config) => { - let pg_connect_options = get_postgres_connect_options( - config.host, - config.port, - config.username, - config.password, - config.database, - ) - .unwrap(); - let pg = connect_pg(pg_connect_options.clone().into()).await?; - drop_postgres(&pg, pg_connect_options.database).await?; - } - } - Ok(()) -} diff --git a/trade_flow_core/daemon/src/lib.rs b/trade_flow_core/daemon/src/lib.rs deleted file mode 100644 index 1ede332..0000000 --- a/trade_flow_core/daemon/src/lib.rs +++ /dev/null @@ -1,29 +0,0 @@ -// ------------------------------------------------------------------------------------------------- -// Copyright (C) 2015-2024 Nautech Systems Pty Ltd. All rights reserved. -// https://nautechsystems.io -// -// Licensed under the GNU Lesser General Public License Version 3.0 (the "License"); -// You may not use this file except in compliance with the License. -// You may obtain a copy of the License at https://www.gnu.org/licenses/lgpl-3.0.en.html -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ------------------------------------------------------------------------------------------------- - -use crate::{ - database::postgres::run_database_command, - opt::{Commands, NautilusCli}, -}; - -mod database; -pub mod opt; - -pub async fn run(opt: NautilusCli) -> anyhow::Result<()> { - match opt.command { - Commands::Database(database_opt) => run_database_command(database_opt).await?, - } - Ok(()) -} diff --git a/trade_flow_core/daemon/src/opt.rs b/trade_flow_core/daemon/src/opt.rs deleted file mode 100644 index 1df35a0..0000000 --- a/trade_flow_core/daemon/src/opt.rs +++ /dev/null @@ -1,66 +0,0 @@ -// ------------------------------------------------------------------------------------------------- -// Copyright (C) 2015-2024 Nautech Systems Pty Ltd. All rights reserved. -// https://nautechsystems.io -// -// Licensed under the GNU Lesser General Public License Version 3.0 (the "License"); -// You may not use this file except in compliance with the License. -// You may obtain a copy of the License at https://www.gnu.org/licenses/lgpl-3.0.en.html -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ------------------------------------------------------------------------------------------------- - -use clap::Parser; - -#[derive(Parser)] -#[clap(version, about, author)] -pub struct NautilusCli { - #[clap(subcommand)] - pub command: Commands, -} - -#[derive(Parser, Debug)] -pub enum Commands { - Database(DatabaseOpt), -} - -#[derive(Parser, Debug)] -#[command(about = "Postgres database operations", long_about = None)] -pub struct DatabaseOpt { - #[clap(subcommand)] - pub command: DatabaseCommand, -} - -#[derive(Parser, Debug, Clone)] -pub struct DatabaseConfig { - /// Hostname or IP address of the database server - #[arg(long)] - pub host: Option, - /// Port number of the database server - #[arg(long)] - pub port: Option, - /// Username for connecting to the database - #[arg(long)] - pub username: Option, - /// Name of the database - #[arg(long)] - pub database: Option, - /// Password for connecting to the database - #[arg(long)] - pub password: Option, - /// Directory path to the schema files - #[arg(long)] - pub schema: Option, -} - -#[derive(Parser, Debug, Clone)] -#[command(about = "Postgres database operations", long_about = None)] -pub enum DatabaseCommand { - /// Initializes a new Postgres database with the latest schema - Init(DatabaseConfig), - /// Drops roles, privileges and deletes all data from the database - Drop(DatabaseConfig), -} diff --git a/trade_flow_core/rust-toolchain.toml b/trade_flow_core/rust-toolchain.toml deleted file mode 100644 index 3628336..0000000 --- a/trade_flow_core/rust-toolchain.toml +++ /dev/null @@ -1,3 +0,0 @@ -[toolchain] -version = "1.80.1" -channel = "stable" diff --git a/trade_flow_core/rustfmt.toml b/trade_flow_core/rustfmt.toml deleted file mode 100644 index 16f7ddf..0000000 --- a/trade_flow_core/rustfmt.toml +++ /dev/null @@ -1,5 +0,0 @@ -# This project uses rustfmt to format source code. Run `cargo +nightly fmt [-- --check]`. -# https://github.com/rust-lang/rustfmt/blob/master/Configurations.md - -group_imports = "StdExternalCrate" -imports_granularity = "Crate"