diff options
| author | kboz <kutayboz@gmail.com> | 2026-04-24 01:11:23 +0200 |
|---|---|---|
| committer | kboz <kutayboz@gmail.com> | 2026-04-24 01:11:23 +0200 |
| commit | 29c4b57db9a34e0f815d93cac6a2cae543778a93 (patch) | |
| tree | 68628e0b67353bcf74b5c516e5a2f0893cd598b7 /rust_backend/src/market/trade.rs | |
| parent | e43c98997b0de6a8da989f68d97f1d4f7fb7bb6f (diff) | |
| download | haul-29c4b57db9a34e0f815d93cac6a2cae543778a93.tar.gz | |
- Added a 2026 copyright statement under the original creator's in `license.md` to properly establish new fork logic.
- Updated `readme.md` to explicitly state this repository is a maintained fork.
- Eliminated the `rust_backend/` directory, Actix codebase, and its associated launch configurations.
- Purged all references specifying a Python/Rust/React tri-split from `AGENTS.md` and the frontend `.instructions.md` configuration.
Co-authored-by: Copilot <copilot@github.com>
Diffstat (limited to 'rust_backend/src/market/trade.rs')
| -rw-r--r-- | rust_backend/src/market/trade.rs | 63 |
1 files changed, 0 insertions, 63 deletions
diff --git a/rust_backend/src/market/trade.rs b/rust_backend/src/market/trade.rs deleted file mode 100644 index 362acbf..0000000 --- a/rust_backend/src/market/trade.rs +++ /dev/null @@ -1,63 +0,0 @@ -use crate::order::Order; - -pub struct Trade<'a> { - from: &'a Order, - to: &'a Order, - quantity: usize, - gross_profit: f64, -} - -const TAX_RATE: f64 = 0.08 - -impl<'a> Trade<'a> { - pub fn new(from: &'a Order, to: &'a Order, quantity: usize) -> Self { - Self { from, to, quantity } - } - - pub fn create_trades(sell_orders: &'a [Order], buy_orders: &'a [Order]) -> Vec<Trade<'a>> { - let mut trades: Vec<Trade<'a>> = Vec::new(); - let mut grouped_orders: HashMap<i32, (Vec<&'a Order>, Vec<&'a Order>)> = HashMap::new(); - - // Grouping sell orders - for order in sell_orders { - grouped_orders.entry(order.type_id) - .or_insert((Vec::new(), Vec::new())) - .0 - .push(order); - } - - // Grouping buy orders - for order in buy_orders { - grouped_orders.entry(order.type_id) - .or_insert((Vec::new(), Vec::new())) - .1 - .push(order); - } - - // Iterating over each type_id's sell and buy orders to create trades - for (_type_id, (sells, buys)) in grouped_orders { - for &sell_order in sells { - for &buy_order in buys { - let quantity = std::cmp::min(sell_order.volume_remain, buy_order.volume_remain); - let gross_profit = quantity as f64 * (buy_order.price * (1-TAX_RATE) - sell_order.price); - - if gross_profit <= 0.0 { - continue; - } - - let trade = Trade::new( - sell_order, - buy_order, - quantity, - gross_profit, - ); - - trades.push(trade); - } - } - } - - trades - } - -} |
