From 3e5e308e6cff98e97357c5930323b25429e37de9 Mon Sep 17 00:00:00 2001 From: Sebastian Rollen Date: Tue, 12 Oct 2021 15:05:02 -0400 Subject: [PATCH] try to fix timezone --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/trading/trade_generator.rs | 18 +++++++++--------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b11aed9..0a48d29 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -215,7 +215,7 @@ checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f" [[package]] name = "double-trouble" -version = "0.4.5" +version = "0.4.6" dependencies = [ "anyhow", "bdays", diff --git a/Cargo.toml b/Cargo.toml index ff8231d..4f298a2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "double-trouble" -version = "0.4.5" +version = "0.4.6" authors = ["Sebastian Rollen "] edition = "2018" diff --git a/src/trading/trade_generator.rs b/src/trading/trade_generator.rs index 889aa02..a3d1204 100644 --- a/src/trading/trade_generator.rs +++ b/src/trading/trade_generator.rs @@ -1,7 +1,7 @@ use crate::trading::domain::Position; use crate::trading::relay::RelayMessage; use crate::trading::TradeBands; -use chrono::{DateTime, Local}; +use chrono::{Local, Utc}; use polygon::ws::Aggregate; use rdkafka::producer::{FutureProducer, FutureRecord}; use rust_decimal::prelude::*; @@ -69,7 +69,7 @@ impl TradeGenerator { .update_policy(UpdatePolicy::RetainLong) .limit_price(p1 * Decimal::new(1005, 3)) .sub_strategy(pair_string.clone()) - .before(DateTime::from(Local::today().and_hms(15, 50, 0))) + .before(Local::today().and_hms(19, 50, 0).with_timezone(&Utc)) .build() .expect("Always works"), ); @@ -82,7 +82,7 @@ impl TradeGenerator { .update_policy(UpdatePolicy::RetainShort) .limit_price(p2 * Decimal::new(995, 3)) .sub_strategy(pair_string.clone()) - .before(DateTime::from(Local::today().and_hms(15, 50, 0))) + .before(Local::today().and_hms(19, 50, 0).with_timezone(&Utc)) .build() .expect("Always works"), ); @@ -97,7 +97,7 @@ impl TradeGenerator { .update_policy(UpdatePolicy::RetainShort) .limit_price(p1 * Decimal::new(995, 3)) .sub_strategy(pair_string.clone()) - .before(DateTime::from(Local::today().and_hms(15, 50, 0))) + .before(Local::today().and_hms(19, 50, 0).with_timezone(&Utc)) .build() .expect("Always works"), ); @@ -110,7 +110,7 @@ impl TradeGenerator { .update_policy(UpdatePolicy::RetainLong) .limit_price(p2 * Decimal::new(1005, 3)) .sub_strategy(pair_string.clone()) - .before(DateTime::from(Local::today().and_hms(15, 50, 0))) + .before(Local::today().and_hms(19, 50, 0).with_timezone(&Utc)) .build() .expect("Always works"), ); @@ -124,7 +124,7 @@ impl TradeGenerator { ) .sub_strategy(pair_string.clone()) .update_policy(UpdatePolicy::RetainLong) - .before(DateTime::from(Local::today().and_hms(15, 50, 0))) + .before(Local::today().and_hms(19, 50, 0).with_timezone(&Utc)) .build() .expect("Always works"), ); @@ -136,7 +136,7 @@ impl TradeGenerator { ) .update_policy(UpdatePolicy::RetainShort) .sub_strategy(pair_string.clone()) - .before(DateTime::from(Local::today().and_hms(15, 50, 0))) + .before(Local::today().and_hms(19, 50, 0).with_timezone(&Utc)) .build() .expect("Always works"), ); @@ -150,7 +150,7 @@ impl TradeGenerator { ) .update_policy(UpdatePolicy::RetainShort) .sub_strategy(pair_string.clone()) - .before(DateTime::from(Local::today().and_hms(15, 50, 0))) + .before(Local::today().and_hms(19, 50, 0).with_timezone(&Utc)) .build() .expect("Always works"), ); @@ -162,7 +162,7 @@ impl TradeGenerator { ) .update_policy(UpdatePolicy::RetainLong) .sub_strategy(pair_string.clone()) - .before(DateTime::from(Local::today().and_hms(15, 50, 0))) + .before(Local::today().and_hms(19, 50, 0).with_timezone(&Utc)) .build() .expect("Always works"), );