|
@@ -1,4 +1,4 @@
|
|
|
-use std::cmp::{max, min};
|
|
|
|
|
|
|
+use std::cmp::{max};
|
|
|
use std::collections::{BTreeMap, VecDeque};
|
|
use std::collections::{BTreeMap, VecDeque};
|
|
|
use std::sync::Arc;
|
|
use std::sync::Arc;
|
|
|
use chrono::{Utc};
|
|
use chrono::{Utc};
|
|
@@ -437,27 +437,6 @@ impl Predictor {
|
|
|
self.optimal_bid_price.rescale(self.mid_price.scale());
|
|
self.optimal_bid_price.rescale(self.mid_price.scale());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- pub fn update_optimal_ask_and_bid(&mut self) {
|
|
|
|
|
- self.optimal_ask_price = if self.ask_delta == dec!(-1) {
|
|
|
|
|
- self.bid_price
|
|
|
|
|
- } else if self.ask_delta == dec!(-2) {
|
|
|
|
|
- Self::DONT_VIEW
|
|
|
|
|
- } else {
|
|
|
|
|
- max(self.ask_price + self.ask_delta, self.bid_price)
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
- self.optimal_bid_price = if self.bid_delta == dec!(-1) {
|
|
|
|
|
- self.ask_price
|
|
|
|
|
- } else if self.bid_delta == dec!(-2) {
|
|
|
|
|
- Self::DONT_VIEW
|
|
|
|
|
- } else {
|
|
|
|
|
- min(self.bid_price - self.bid_delta, self.ask_price)
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
- self.optimal_ask_price.rescale(self.mid_price.scale());
|
|
|
|
|
- self.optimal_bid_price.rescale(self.mid_price.scale());
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
pub fn update_t_diff(&mut self) {
|
|
pub fn update_t_diff(&mut self) {
|
|
|
if self.prev_trade_time > 0 {
|
|
if self.prev_trade_time > 0 {
|
|
|
let time_diff_decimal = Decimal::from_i64(Utc::now().timestamp_micros() - self.prev_trade_time).unwrap();
|
|
let time_diff_decimal = Decimal::from_i64(Utc::now().timestamp_micros() - self.prev_trade_time).unwrap();
|
|
@@ -507,7 +486,6 @@ impl Predictor {
|
|
|
|
|
|
|
|
self.update_t_diff();
|
|
self.update_t_diff();
|
|
|
self.update_delta();
|
|
self.update_delta();
|
|
|
- self.update_optimal_ask_and_bid();
|
|
|
|
|
|
|
|
|
|
// let mut smm = Decimal::ZERO;
|
|
// let mut smm = Decimal::ZERO;
|
|
|
// if !self.depth_vec[1].time.is_zero() {
|
|
// if !self.depth_vec[1].time.is_zero() {
|