Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[cfg(test)] | |
mod tests { | |
use super::*; | |
#[test] | |
fn test_new_aircraft() { | |
let ac312 = PassengerAircraft::new("ac312_toronto_newyork_1700"); | |
assert_eq!(ac312.id(), "ac312_toronto_newyork_1700"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
impl TradingBot { | |
// main trading logic | |
// high sell, low buy | |
pub async fn start(&mut self) -> Result<(), Box<dyn Error>> { | |
let current_price = self.get_market_price().await?; | |
info!("[PRICE] current market price: {:?} $", current_price); | |
let percentage_diff = (current_price - self.trading_config.last_operation_price) | |
/ self.trading_config.last_operation_price | |
* 100 as f32; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub struct Airport { | |
name: String, | |
aircrafts: HashMap<String, Box<dyn Aircraft>>, | |
aircraft_on_gate: HashMap<i8, String>, | |
aircraft_queue: VecDeque<String>, | |
gates: HashMap<i8, bool>, | |
} | |
impl Airport { | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Coordinator is playing a mediator role which ensure the only place to | |
pub trait Coordinator { | |
fn arrival(&mut self, aircraft_id: &str) -> bool; | |
fn gate_available(&mut self) -> Option<i8>; | |
fn departure(&mut self, aircraft_id: &str); | |
} | |
impl Coordinator for Airport { | |
fn arrival(&mut self, aircraft_id: &str) -> bool { | |
/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub struct PassengerAircraft { | |
id: String, | |
} | |
impl PassengerAircraft { | |
pub fn new(id: impl Into<String>) -> Self { | |
Self { | |
id: id.into(), | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Rust | |
on: | |
push: | |
branches: [ "main" ] | |
env: | |
CARGO_TERM_COLOR: always | |
BUILD_HOME: /home/runner/work/bot/bot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# build | |
cargo build --release --target=x86_64-unknown-linux-musl | |
# move to the bootstrap name | |
cp target/x86_64-unknown-linux-musl/release/rstvb bootstrap | |
# zip as lambda.zip | |
zip lambda.zip bootstrap |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[[bin]] | |
name = "bootstrap" | |
path = "src/bootstrap.rs" | |
[[bin]] | |
name = "main" | |
path = "src/main.rs" |
NewerOlder