浏览代码

ran clippy for linting

Berke 1 年之前
父节点
当前提交
3e1f576672
共有 4 个文件被更改,包括 107 次插入117 次删除
  1. 17 17
      src/charts/custom_line.rs
  2. 30 36
      src/charts/footprint.rs
  3. 23 23
      src/charts/heatmap.rs
  4. 37 41
      src/main.rs

+ 17 - 17
src/charts/custom_line.rs

@@ -1,7 +1,7 @@
 use std::{collections::BTreeMap, vec};
 use chrono::{DateTime, Utc, TimeZone, LocalResult, Duration, NaiveDateTime, Timelike};
 use iced::{
-    alignment, color, mouse, widget::{button, canvas::{self, event::{self, Event}, path, stroke::Stroke, Cache, Canvas, Geometry, Path}}, window, Border, Color, Element, Length, Point, Rectangle, Renderer, Size, Theme, Vector
+    alignment, mouse, widget::{button, canvas::{self, event::{self, Event}, stroke::Stroke, Cache, Canvas, Geometry, Path}}, window, Border, Color, Element, Length, Point, Rectangle, Renderer, Size, Theme, Vector
 };
 use iced::widget::{Column, Row, Container, Text};
 use crate::{market_data::Kline, Timeframe};
@@ -496,12 +496,12 @@ impl canvas::Program<Message> for CustomLine {
                     if x_position >= 0.0 && x_position <= bounds.width as f64 {
                         let line = Path::line(
                             Point::new(x_position as f32, 0.0), 
-                            Point::new(x_position as f32, bounds.height as f32)
+                            Point::new(x_position as f32, bounds.height)
                         );
                         frame.stroke(&line, Stroke::default().with_color(Color::from_rgba8(27, 27, 27, 1.0)).with_width(1.0))
                     }
                     
-                    time = time + time_step;
+                    time += time_step;
                 }
             });
             
@@ -512,7 +512,7 @@ impl canvas::Program<Message> for CustomLine {
                     let y_position = candlesticks_area_height - ((y - lowest) / y_range * candlesticks_area_height);
                     let line = Path::line(
                         Point::new(0.0, y_position), 
-                        Point::new(bounds.width as f32, y_position)
+                        Point::new(bounds.width, y_position)
                     );
                     frame.stroke(&line, Stroke::default().with_color(Color::from_rgba8(27, 27, 27, 1.0)).with_width(1.0));
                     y += step;
@@ -547,14 +547,14 @@ impl canvas::Program<Message> for CustomLine {
                 let sell_bar_height = (sell_volume / max_volume) * volume_area_height;
                 
                 let buy_bar = Path::rectangle(
-                    Point::new(x_position as f32, (bounds.height - buy_bar_height) as f32), 
-                    Size::new(2.0 * self.scaling, buy_bar_height as f32)
+                    Point::new(x_position as f32, bounds.height - buy_bar_height), 
+                    Size::new(2.0 * self.scaling, buy_bar_height)
                 );
                 frame.fill(&buy_bar, Color::from_rgb8(81, 205, 160)); 
                 
                 let sell_bar = Path::rectangle(
-                    Point::new(x_position as f32 - (2.0 * self.scaling), (bounds.height - sell_bar_height) as f32), 
-                    Size::new(2.0 * self.scaling, sell_bar_height as f32)
+                    Point::new(x_position as f32 - (2.0 * self.scaling), bounds.height - sell_bar_height), 
+                    Size::new(2.0 * self.scaling, sell_bar_height)
                 );
                 frame.fill(&sell_bar, Color::from_rgb8(192, 80, 77)); 
             }
@@ -565,7 +565,7 @@ impl canvas::Program<Message> for CustomLine {
                 if let Some(cursor_position) = cursor.position_in(bounds) {
                     let line = Path::line(
                         Point::new(0.0, cursor_position.y), 
-                        Point::new(bounds.width as f32, cursor_position.y)
+                        Point::new(bounds.width, cursor_position.y)
                     );
                     frame.stroke(&line, Stroke::default().with_color(Color::from_rgba8(200, 200, 200, 0.6)).with_width(1.0));
 
@@ -581,7 +581,7 @@ impl canvas::Program<Message> for CustomLine {
 
                     let line = Path::line(
                         Point::new(snap_x as f32, 0.0), 
-                        Point::new(snap_x as f32, bounds.height as f32)
+                        Point::new(snap_x as f32, bounds.height)
                     );
                     frame.stroke(&line, Stroke::default().with_color(Color::from_rgba8(200, 200, 200, 0.6)).with_width(1.0));
 
@@ -605,9 +605,9 @@ impl canvas::Program<Message> for CustomLine {
                 }
             });
 
-            return vec![background, crosshair, candlesticks];
+            vec![background, crosshair, candlesticks]
         }   else {
-            return vec![background, candlesticks];
+            vec![background, candlesticks]
         }
     }
 
@@ -683,7 +683,7 @@ fn calculate_time_step(earliest: i64, latest: i64, labels_can_fit: i32) -> (Dura
     let step_minutes = selected_step.num_minutes() as u32;
     let remainder = minutes % step_minutes;
     if remainder > 0 {
-        rounded_earliest = rounded_earliest + Duration::minutes((step_minutes - remainder) as i64);
+        rounded_earliest += Duration::minutes((step_minutes - remainder) as i64)
     }
 
     (selected_step, rounded_earliest)
@@ -742,7 +742,7 @@ impl canvas::Program<Message> for AxisLabelXCanvas<'_> {
                         let text_size = 12.0;
                         let label = canvas::Text {
                             content: time.format("%H:%M").to_string(),
-                            position: Point::new(x_position as f32 - text_size, bounds.height as f32 - 20.0),
+                            position: Point::new(x_position as f32 - text_size, bounds.height - 20.0),
                             size: iced::Pixels(text_size),
                             color: Color::from_rgba8(200, 200, 200, 1.0),
                             ..canvas::Text::default()
@@ -753,7 +753,7 @@ impl canvas::Program<Message> for AxisLabelXCanvas<'_> {
                         });
                     }
                     
-                    time = time + time_step;
+                    time += time_step;
                 }
             });
         });
@@ -773,8 +773,8 @@ impl canvas::Program<Message> for AxisLabelXCanvas<'_> {
                 let text_size = 12.0;
                 let text_content = rounded_time.format("%H:%M").to_string();
                 let growth_amount = 6.0; 
-                let rectangle_position = Point::new(snap_x as f32 - 14.0 - growth_amount, bounds.height as f32 - 20.0);
-                let text_position = Point::new(snap_x as f32 - 14.0, bounds.height as f32 - 20.0);
+                let rectangle_position = Point::new(snap_x as f32 - (text_size*4.0/3.0) - growth_amount, bounds.height - 20.0);
+                let text_position = Point::new(snap_x as f32 - (text_size*4.0/3.0), bounds.height - 20.0);
 
                 let text_background = canvas::Path::rectangle(rectangle_position, Size::new(text_content.len() as f32 * text_size/2.0 + 2.0 * growth_amount + 1.0, text_size + text_size/2.0));
                 frame.fill(&text_background, Color::from_rgba8(200, 200, 200, 1.0));

+ 30 - 36
src/charts/footprint.rs

@@ -69,12 +69,10 @@ impl Footprint {
                 } else {
                     *buy_qty += trade.qty;
                 }
+            } else if trade.is_sell {
+                entry.0.insert(price_level, (0.0, trade.qty));
             } else {
-                if trade.is_sell {
-                    entry.0.insert(price_level, (0.0, trade.qty));
-                } else {
-                    entry.0.insert(price_level, (trade.qty, 0.0));
-                }
+                entry.0.insert(price_level, (trade.qty, 0.0));
             }
         }
     
@@ -121,12 +119,10 @@ impl Footprint {
                     } else {
                         *buy_qty += trade.qty;
                     }
+                } else if trade.is_sell {
+                    trades.insert(price_level, (0.0, trade.qty));
                 } else {
-                    if trade.is_sell {
-                        trades.insert(price_level, (0.0, trade.qty));
-                    } else {
-                        trades.insert(price_level, (trade.qty, 0.0));
-                    }
+                    trades.insert(price_level, (trade.qty, 0.0));
                 }
             }
         }
@@ -156,12 +152,10 @@ impl Footprint {
                 } else {
                     *buy_qty += trade.qty;
                 }
-            } else {
-                if trade.is_sell {
+            } else if trade.is_sell {
                     entry.0.insert(price_level, (0.0, trade.qty));
-                } else {
-                    entry.0.insert(price_level, (trade.qty, 0.0));
-                }
+            } else {
+                entry.0.insert(price_level, (trade.qty, 0.0));
             }
         }
     
@@ -183,7 +177,7 @@ impl Footprint {
     pub fn render_start(&mut self) {
         let timestamp_latest = self.data_points.keys().last().unwrap_or(&0);
 
-        let latest: i64 = *timestamp_latest as i64 - ((self.translation.x*1000.0)*(self.timeframe as f32)) as i64;
+        let latest: i64 = *timestamp_latest - ((self.translation.x*1000.0)*(self.timeframe as f32)) as i64;
         let earliest: i64 = latest - ((640000.0*self.timeframe as f32) / (self.scaling / (self.bounds.width/800.0))) as i64;
     
         let mut highest: f32 = 0.0;
@@ -531,7 +525,7 @@ impl canvas::Program<Message> for Footprint {
             }
             
             for (time, (trades, kline)) in self.data_points.range(earliest..=latest) {
-                let x_position: f32 = ((time - earliest) as f32 / (latest - earliest) as f32) * bounds.width as f32;
+                let x_position: f32 = ((time - earliest) as f32 / (latest - earliest) as f32) * bounds.width;
 
                 if x_position.is_nan() || x_position.is_infinite() {
                     continue;
@@ -566,14 +560,14 @@ impl canvas::Program<Message> for Footprint {
                     let sell_bar_width = 8.0 * self.scaling;
                     let sell_bar_x_position = x_position - (5.0*self.scaling) - sell_bar_width;
                     let sell_bar = Path::rectangle(
-                        Point::new(sell_bar_x_position, (bounds.height - sell_bar_height) as f32), 
-                        Size::new(sell_bar_width, sell_bar_height as f32)
+                        Point::new(sell_bar_x_position, bounds.height - sell_bar_height), 
+                        Size::new(sell_bar_width, sell_bar_height)
                     );
                     frame.fill(&sell_bar, Color::from_rgb8(192, 80, 77)); 
 
                     let buy_bar = Path::rectangle(
-                        Point::new(x_position + (5.0*self.scaling), (bounds.height - buy_bar_height) as f32), 
-                        Size::new(8.0 * self.scaling, buy_bar_height as f32)
+                        Point::new(x_position + (5.0*self.scaling), bounds.height - buy_bar_height), 
+                        Size::new(8.0 * self.scaling, buy_bar_height)
                     );
                     frame.fill(&buy_bar, Color::from_rgb8(81, 205, 160));
                 }
@@ -586,13 +580,13 @@ impl canvas::Program<Message> for Footprint {
                 let color = if kline.3 >= kline.0 { Color::from_rgba8(81, 205, 160, 0.6) } else { Color::from_rgba8(192, 80, 77, 0.6) };
 
                 let wick = Path::line(
-                    Point::new(x_position as f32, y_high), 
-                    Point::new(x_position as f32, y_low)
+                    Point::new(x_position, y_high), 
+                    Point::new(x_position, y_low)
                 );
                 frame.stroke(&wick, Stroke::default().with_color(color).with_width(1.0));
 
                 let body = Path::rectangle(
-                    Point::new(x_position as f32 - (2.0 * self.scaling), y_open.min(y_close)), 
+                    Point::new(x_position - (2.0 * self.scaling), y_open.min(y_close)), 
                     Size::new(4.0 * self.scaling, (y_open - y_close).abs())
                 );                    
                 frame.fill(&body, color);
@@ -618,7 +612,7 @@ impl canvas::Program<Message> for Footprint {
                 if let Some(cursor_position) = cursor.position_in(bounds) {
                     let line = Path::line(
                         Point::new(0.0, cursor_position.y), 
-                        Point::new(bounds.width as f32, cursor_position.y)
+                        Point::new(bounds.width, cursor_position.y)
                     );
                     frame.stroke(&line, Stroke::default().with_color(Color::from_rgba8(200, 200, 200, 0.6)).with_width(1.0));
 
@@ -631,7 +625,7 @@ impl canvas::Program<Message> for Footprint {
 
                     let line = Path::line(
                         Point::new(snap_x as f32, 0.0), 
-                        Point::new(snap_x as f32, bounds.height as f32)
+                        Point::new(snap_x as f32, bounds.height)
                     );
                     frame.stroke(&line, Stroke::default().with_color(Color::from_rgba8(200, 200, 200, 0.6)).with_width(1.0));
 
@@ -654,9 +648,9 @@ impl canvas::Program<Message> for Footprint {
                 }
             });
 
-            return vec![crosshair, heatmap];
+            vec![crosshair, heatmap]
         }   else {
-            return vec![heatmap];
+            vec![heatmap]
         }
     }
 
@@ -822,14 +816,14 @@ impl canvas::Program<Message> for AxisLabelXCanvas<'_> {
                 let latest_time: i64 = latest_in_millis;
 
                 while time <= latest_time {                    
-                    let x_position = ((time as i64 - earliest_in_millis as i64) as f64 / (latest_in_millis - earliest_in_millis) as f64) * bounds.width as f64;
+                    let x_position = ((time - earliest_in_millis) as f64 / (latest_in_millis - earliest_in_millis) as f64) * bounds.width as f64;
 
                     if x_position >= 0.0 && x_position <= bounds.width as f64 {
                         let text_size = 12.0;
-                        let time_as_datetime = NaiveDateTime::from_timestamp((time / 1000) as i64, 0);
+                        let time_as_datetime = NaiveDateTime::from_timestamp(time / 1000, 0);
                         let label = canvas::Text {
                             content: time_as_datetime.format("%H:%M").to_string(),
-                            position: Point::new(x_position as f32 - text_size, bounds.height as f32 - 20.0),
+                            position: Point::new(x_position as f32 - (text_size*4.0/3.0), bounds.height - 20.0),
                             size: iced::Pixels(text_size),
                             color: Color::from_rgba8(200, 200, 200, 1.0),
                             ..canvas::Text::default()
@@ -840,12 +834,12 @@ impl canvas::Program<Message> for AxisLabelXCanvas<'_> {
                         });
                     }
                     
-                    time = time + time_step;
+                    time += time_step;
                 }
 
                 let line = Path::line(
-                    Point::new(0.0, bounds.height as f32 - 30.0), 
-                    Point::new(bounds.width as f32, bounds.height as f32 - 30.0)
+                    Point::new(0.0, bounds.height - 30.0), 
+                    Point::new(bounds.width, bounds.height - 30.0)
                 );
                 frame.stroke(&line, Stroke::default().with_color(Color::from_rgba8(81, 81, 81, 0.2)).with_width(1.0));
             });
@@ -866,8 +860,8 @@ impl canvas::Program<Message> for AxisLabelXCanvas<'_> {
                 let text_size = 12.0;
                 let text_content = rounded_time.format("%H:%M").to_string();
                 let growth_amount = 6.0; 
-                let rectangle_position = Point::new(snap_x as f32 - 14.0 - growth_amount, bounds.height as f32 - 20.0);
-                let text_position = Point::new(snap_x as f32 - 14.0, bounds.height as f32 - 20.0);
+                let rectangle_position = Point::new(snap_x as f32 - 14.0 - growth_amount, bounds.height - 20.0);
+                let text_position = Point::new(snap_x as f32 - 14.0, bounds.height - 20.0);
 
                 let text_background = canvas::Path::rectangle(rectangle_position, Size::new(text_content.len() as f32 * text_size/2.0 + 2.0 * growth_amount + 1.0, text_size + text_size/2.0));
                 frame.fill(&text_background, Color::from_rgba8(200, 200, 200, 1.0));

+ 23 - 23
src/charts/heatmap.rs

@@ -503,14 +503,14 @@ impl canvas::Program<Message> for Heatmap {
                         let sell_bar_height = (volume.1 / max_volume) * volume_area_height;
 
                         let sell_bar = Path::rectangle(
-                            Point::new(x_position as f32, (bounds.height - sell_bar_height) as f32), 
-                            Size::new(1.0, sell_bar_height as f32)
+                            Point::new(x_position as f32, bounds.height - sell_bar_height), 
+                            Size::new(1.0, sell_bar_height)
                         );
                         frame.fill(&sell_bar, Color::from_rgb8(192, 80, 77)); 
 
                         let buy_bar = Path::rectangle(
-                            Point::new(x_position as f32 + 2.0, (bounds.height - buy_bar_height) as f32), 
-                            Size::new(1.0, buy_bar_height as f32)
+                            Point::new(x_position as f32 + 2.0, bounds.height - buy_bar_height), 
+                            Size::new(1.0, buy_bar_height)
                         );
                         frame.fill(&buy_bar, Color::from_rgb8(81, 205, 160));
                     }
@@ -526,9 +526,9 @@ impl canvas::Program<Message> for Heatmap {
 
                 let max_qty = latest_bids.iter().map(|(_, qty)| qty).chain(latest_asks.iter().map(|(_, qty)| qty)).fold(f32::MIN, |arg0: f32, other: &f32| f32::max(arg0, *other));
 
-                let x_position = ((latest_timestamp - earliest) as f32 / (latest - earliest) as f32) * bounds.width as f32;
+                let x_position = ((latest_timestamp - earliest) as f32 / (latest - earliest) as f32) * bounds.width;
 
-                for (_, (price, qty)) in latest_bids.iter().enumerate() {      
+                for (price, qty) in latest_bids.iter() {     
                     let y_position = heatmap_area_height - ((price - lowest) / y_range * heatmap_area_height);
 
                     let bar_width = (qty / max_qty) * depth_area_width;
@@ -538,7 +538,7 @@ impl canvas::Program<Message> for Heatmap {
                     );
                     frame.fill(&bar, Color::from_rgba8(0, 144, 144, 0.5));
                 }
-                for (_, (price, qty)) in latest_asks.iter().enumerate() {
+                for (price, qty) in latest_asks.iter() {
                     let y_position = heatmap_area_height - ((price - lowest) / y_range * heatmap_area_height);
 
                     let bar_width = (qty / max_qty) * depth_area_width; 
@@ -551,7 +551,7 @@ impl canvas::Program<Message> for Heatmap {
 
                 let line = Path::line(
                     Point::new(x_position, 0.0), 
-                    Point::new(x_position, bounds.height as f32)
+                    Point::new(x_position, bounds.height)
                 );
                 frame.stroke(&line, Stroke::default().with_color(Color::from_rgba8(100, 100, 100, 0.1)).with_width(1.0));
 
@@ -599,7 +599,7 @@ impl canvas::Program<Message> for Heatmap {
                 if let Some(cursor_position) = cursor.position_in(bounds) {
                     let line = Path::line(
                         Point::new(0.0, cursor_position.y), 
-                        Point::new(bounds.width as f32, cursor_position.y)
+                        Point::new(bounds.width, cursor_position.y)
                     );
                     frame.stroke(&line, Stroke::default().with_color(Color::from_rgba8(200, 200, 200, 0.6)).with_width(1.0));
 
@@ -607,22 +607,22 @@ impl canvas::Program<Message> for Heatmap {
                     let crosshair_millis = (earliest as f64 + crosshair_ratio * (latest as f64 - earliest as f64)).round() / 100.0 * 100.0;
                     let crosshair_time = NaiveDateTime::from_timestamp((crosshair_millis / 1000.0).floor() as i64, ((crosshair_millis % 1000.0) * 1_000_000.0).round() as u32);
 
-                    let crosshair_timestamp = crosshair_time.timestamp_millis() as i64;
+                    let crosshair_timestamp = crosshair_time.timestamp_millis();
 
                     let snap_ratio = (crosshair_timestamp as f64 - earliest as f64) / ((latest as f64) - (earliest as f64));
                     let snap_x = snap_ratio * bounds.width as f64;
 
                     let line = Path::line(
                         Point::new(snap_x as f32, 0.0), 
-                        Point::new(snap_x as f32, bounds.height as f32)
+                        Point::new(snap_x as f32, bounds.height)
                     );
                     frame.stroke(&line, Stroke::default().with_color(Color::from_rgba8(200, 200, 200, 0.6)).with_width(1.0));
                 }
             });
 
-            return vec![crosshair, heatmap];
+            vec![crosshair, heatmap]
         }   else {
-            return vec![heatmap];
+            vec![heatmap]
         }
     }
 
@@ -687,7 +687,7 @@ const TIME_STEPS: [i64; 8] = [
     10 * 1000, // 10 seconds
     5 * 1000,  // 5 seconds
     2 * 1000,  // 2 seconds
-    1 * 1000,  // 1 second
+    1000,  // 1 second
     500,       // 500 milliseconds
 ];
 fn calculate_time_step(earliest: i64, latest: i64, labels_can_fit: i32) -> (i64, i64) {
@@ -750,14 +750,14 @@ impl canvas::Program<Message> for AxisLabelXCanvas<'_> {
                 let latest_time: i64 = latest_in_millis;
 
                 while time <= latest_time {                    
-                    let x_position = ((time as i64 - earliest_in_millis as i64) as f64 / (latest_in_millis - earliest_in_millis) as f64) * bounds.width as f64;
+                    let x_position = ((time - earliest_in_millis) as f64 / (latest_in_millis - earliest_in_millis) as f64) * bounds.width as f64;
 
                     if x_position >= 0.0 && x_position <= bounds.width as f64 {
                         let text_size = 12.0;
-                        let time_as_datetime = NaiveDateTime::from_timestamp((time / 1000) as i64, 0);
+                        let time_as_datetime = NaiveDateTime::from_timestamp(time / 1000, 0);
                         let label = canvas::Text {
                             content: time_as_datetime.format("%M:%S").to_string(),
-                            position: Point::new(x_position as f32 - text_size, bounds.height as f32 - 20.0),
+                            position: Point::new(x_position as f32 - text_size, bounds.height - 20.0),
                             size: iced::Pixels(text_size),
                             color: Color::from_rgba8(200, 200, 200, 1.0),
                             ..canvas::Text::default()
@@ -768,12 +768,12 @@ impl canvas::Program<Message> for AxisLabelXCanvas<'_> {
                         });
                     }
                     
-                    time = time + time_step;
+                    time += time_step;
                 }
 
                 let line = Path::line(
-                    Point::new(0.0, bounds.height as f32 - 30.0), 
-                    Point::new(bounds.width as f32, bounds.height as f32 - 30.0)
+                    Point::new(0.0, bounds.height - 30.0), 
+                    Point::new(bounds.width, bounds.height - 30.0)
                 );
                 frame.stroke(&line, Stroke::default().with_color(Color::from_rgba8(81, 81, 81, 0.2)).with_width(1.0));
             });
@@ -784,7 +784,7 @@ impl canvas::Program<Message> for AxisLabelXCanvas<'_> {
                 let crosshair_millis = (earliest_in_millis as f64 + crosshair_ratio * (latest_in_millis as f64 - earliest_in_millis as f64)).round() / 100.0 * 100.0;
                 let crosshair_time = NaiveDateTime::from_timestamp((crosshair_millis / 1000.0).floor() as i64, ((crosshair_millis % 1000.0) * 1_000_000.0).round() as u32);
                 
-                let crosshair_timestamp = crosshair_time.timestamp_millis() as i64;
+                let crosshair_timestamp = crosshair_time.timestamp_millis();
 
                 let snap_ratio = (crosshair_timestamp as f64 - earliest_in_millis as f64) / (latest_in_millis as f64 - earliest_in_millis as f64);
                 let snap_x = snap_ratio * bounds.width as f64;
@@ -792,8 +792,8 @@ impl canvas::Program<Message> for AxisLabelXCanvas<'_> {
                 let text_size = 12.0;
                 let text_content = crosshair_time.format("%M:%S:%3f").to_string().replace(".", "");
                 let growth_amount = 6.0; 
-                let rectangle_position = Point::new(snap_x as f32 - 26.0 - growth_amount, bounds.height as f32 - 20.0);
-                let text_position = Point::new(snap_x as f32 - 26.0, bounds.height as f32 - 20.0);
+                let rectangle_position = Point::new(snap_x as f32 - 26.0 - growth_amount, bounds.height - 20.0);
+                let text_position = Point::new(snap_x as f32 - 26.0, bounds.height - 20.0);
 
                 let text_background = canvas::Path::rectangle(rectangle_position, Size::new(text_content.len() as f32 * text_size/2.0 + 2.0 * growth_amount, text_size + text_size/2.0));
                 frame.fill(&text_background, Color::from_rgba8(200, 200, 200, 1.0));

+ 37 - 41
src/main.rs

@@ -308,7 +308,7 @@ impl Application for State {
             Command::batch(vec![
                 font::load(ICON_BYTES).map(Message::FontLoaded),
 
-                if API_KEY != "" && SECRET_KEY != "" {
+                if !SECRET_KEY.is_empty() && !SECRET_KEY.is_empty() {
                     Command::perform(user_data::get_listen_key(API_KEY, SECRET_KEY), |res| {
                         match res {
                             Ok(listen_key) => {
@@ -368,11 +368,11 @@ impl Application for State {
             },
 
             Message::TickerSelected(ticker) => {
-                self.selected_ticker = Some(ticker.clone());
+                self.selected_ticker = Some(ticker);
 
                 for value in self.panes_open.values_mut() {
                     if let (true, Some(StreamType::Klines(_, timeframe))) = value {
-                        *value = (true, Some(StreamType::Klines(ticker.clone(), *timeframe)));
+                        *value = (true, Some(StreamType::Klines(ticker, *timeframe)));
                     }
                 }
 
@@ -395,25 +395,23 @@ impl Application for State {
                 let mut commands = vec![];
                 let mut dropped_streams = vec![];
 
-                self.panes.panes.get(&pane).map(|pane| {
-                    if let Some((_, stream_type)) = self.panes_open.get(&pane.id) {
-                        if let Some(StreamType::Klines(ticker, _)) = stream_type {
-                            self.panes_open.insert(pane.id, (true, Some(StreamType::Klines(*ticker, timeframe))));   
+                if let Some(pane) = self.panes.panes.get(&pane) {
+                    if let Some((_, Some(StreamType::Klines(ticker, _)))) = self.panes_open.get(&pane.id) {
+                        self.panes_open.insert(pane.id, (true, Some(StreamType::Klines(*ticker, timeframe))));   
 
-                            let pane_id = pane.id;
-                            let fetch_klines = Command::perform(
-                            market_data::fetch_klines(*selected_ticker, timeframe)
-                                .map_err(|err| format!("{}", err)), 
-                            move |klines| {
-                                Message::FetchEvent(klines, pane_id)
-                            });
-
-                            dropped_streams.push(pane_id);
-                            
-                            commands.push(fetch_klines);                                  
-                        };
-                    }
-                });
+                        let pane_id = pane.id;
+                        let fetch_klines = Command::perform(
+                        market_data::fetch_klines(*selected_ticker, timeframe)
+                            .map_err(|err| format!("{}", err)), 
+                        move |klines| {
+                            Message::FetchEvent(klines, pane_id)
+                        });
+
+                        dropped_streams.push(pane_id);
+                        
+                        commands.push(fetch_klines);                                  
+                    };
+                };
         
                 // sleep to drop existent stream and create new one
                 let remove_active_stream = Command::perform(
@@ -431,7 +429,7 @@ impl Application for State {
                 Command::none()
             },
             Message::WsToggle() => {
-                self.ws_running =! self.ws_running;
+                self.ws_running = !self.ws_running;
 
                 if self.ws_running {  
                     let mut commands = vec![];
@@ -623,7 +621,7 @@ impl Application for State {
                     value.0 = true;
                 }
 
-                if Some(focus_pane) != None {
+                if Some(focus_pane).is_some() {
                     self.focus = focus_pane;
 
                     let selected_ticker = match &self.selected_ticker {
@@ -673,7 +671,7 @@ impl Application for State {
                 Command::none()
             },
             Message::Close(pane) => {
-                self.panes.get(pane).map(|pane| {
+                if let Some(pane) = self.panes.get(pane) {
                     match pane.id {
                         PaneId::HeatmapChart => {
                             if let Some(value) = self.panes_open.get_mut(&PaneId::HeatmapChart) {
@@ -706,7 +704,7 @@ impl Application for State {
                             }
                         },  
                     }
-                });
+                };
                 
                 if let Some((_, sibling)) = self.panes.close(pane) {
                     self.focus = Some(sibling);
@@ -729,9 +727,9 @@ impl Application for State {
             },
 
             Message::OpenModal(pane) => {
-                self.panes.get_mut(pane).map(|pane| {
+                if let Some(pane) = self.panes.get_mut(pane) {
                     pane.show_modal = true;
-                });
+                };
                 Command::none()
             },
             Message::CloseModal => {
@@ -755,9 +753,9 @@ impl Application for State {
                 if let Some(heatmap_chart) = &mut self.heatmap_chart {
                     heatmap_chart.set_size_filter(self.size_filter_heatmap);
                 }
-                self.time_and_sales.as_mut().map(|time_and_sales| {
+                if let Some(time_and_sales) = &mut self.time_and_sales {
                     time_and_sales.set_size_filter(self.size_filter_timesales);
-                });
+                };
 
                 Command::none()
             },
@@ -1033,7 +1031,7 @@ impl Application for State {
 
                 let mut streams: Vec<(Ticker, Timeframe)> = vec![];
                 
-                for (_pane_id, (_is_open, stream_type)) in &self.panes_open {
+                for (_is_open, stream_type) in self.panes_open.values() {
                     if let Some(StreamType::Klines(ticker, timeframe)) = stream_type {
                         streams.push((*ticker, *timeframe));
                     }
@@ -1101,7 +1099,7 @@ fn view_content<'a, 'b: 'a>(
                 underlay =
                     heatmap_chart
                         .view()
-                        .map(move |message| Message::Heatmap(message));
+                        .map(Message::Heatmap);
             } else {
                 underlay = Text::new("No data")
                     .width(Length::Fill)
@@ -1156,7 +1154,7 @@ fn view_content<'a, 'b: 'a>(
                 underlay =
                     footprint_chart
                         .view()
-                        .map(move |message| Message::Footprint(message));
+                        .map(Message::Footprint);
             } else {
                 underlay = Text::new("No data")
                     .width(Length::Fill)
@@ -1172,7 +1170,7 @@ fn view_content<'a, 'b: 'a>(
                 underlay =
                     candlestick_chart
                         .view()
-                        .map(move |message| Message::Candlestick(message));
+                        .map(Message::Candlestick);
             } else {
                 underlay = Text::new("No data")
                     .width(Length::Fill)
@@ -1188,7 +1186,7 @@ fn view_content<'a, 'b: 'a>(
                 underlay =
                     custom_line
                         .view()
-                        .map(move |message| Message::CustomLine(message));
+                        .map(Message::CustomLine);
             } else {
                 underlay = Text::new("No data")
                     .width(Length::Fill)
@@ -1289,7 +1287,7 @@ fn view_controls<'a>(
         let ticksize_picker = pick_list(
             [0.1, 0.5, 1.0, 5.0, 10.0, 25.0, 50.0],
             selected_ticksize,
-            move |ticksize| Message::TicksizeSelected(ticksize),
+            Message::TicksizeSelected,
         ).placeholder("Choose a ticksize...").text_size(11).width(iced::Pixels(80.0));
         row = row.push(ticksize_picker);
     }
@@ -1338,7 +1336,7 @@ impl TimeAndSales {
 
     fn update(&mut self, trades_buffer: &Vec<Trade>) {
         for trade in trades_buffer {
-            let trade_time = NaiveDateTime::from_timestamp(trade.time as i64 / 1000, (trade.time % 1000) as u32 * 1_000_000);
+            let trade_time = NaiveDateTime::from_timestamp(trade.time / 1000, (trade.time % 1000) as u32 * 1_000_000);
             let converted_trade = ConvertedTrade {
                 time: trade_time,
                 price: trade.price,
@@ -1371,7 +1369,7 @@ impl TimeAndSales {
             );
         } else {
             for trade in filtered_trades.iter().rev().take(80) {
-                let trade: &ConvertedTrade = *trade;
+                let trade: &ConvertedTrade = trade;
 
                 let trade_row = Row::new()
                     .push(
@@ -1431,7 +1429,6 @@ mod style {
                 width: 1.0,
                 color: palette.primary.weak.color,
                 radius: 4.0.into(),
-                ..Border::default()
             },
             ..Default::default()
         }
@@ -1447,7 +1444,6 @@ mod style {
                 width: 1.0,
                 color: palette.primary.strong.color,
                 radius: 4.0.into(), 
-                ..Border::default()
             },
             ..Default::default()
         }
@@ -1492,7 +1488,7 @@ mod style {
             text_color: Color::from_rgba(192.0 / 255.0, 80.0 / 255.0, 77.0 / 255.0, 1.0).into(),
             border: Border {
                 width: 1.0,
-                color: Color::from_rgba(192.0 / 255.0, 80.0 / 255.0, 77.0 / 255.0, color_alpha).into(),
+                color: Color::from_rgba(192.0 / 255.0, 80.0 / 255.0, 77.0 / 255.0, color_alpha),
                 ..Border::default()
             },
             ..Default::default()
@@ -1504,7 +1500,7 @@ mod style {
             text_color: Color::from_rgba(81.0 / 255.0, 205.0 / 255.0, 160.0 / 255.0, 1.0).into(),
             border: Border {
                 width: 1.0,
-                color: Color::from_rgba(81.0 / 255.0, 205.0 / 255.0, 160.0 / 255.0, color_alpha).into(),
+                color: Color::from_rgba(81.0 / 255.0, 205.0 / 255.0, 160.0 / 255.0, color_alpha),
                 ..Border::default()
             },
             ..Default::default()