|
@@ -1442,57 +1442,18 @@ extension DealViewModel {
|
|
}
|
|
}
|
|
PriceCalibrator.shareCalibrator.updateLastPriceTime()
|
|
PriceCalibrator.shareCalibrator.updateLastPriceTime()
|
|
print("symbol的值:\(symbol)")
|
|
print("symbol的值:\(symbol)")
|
|
- var isReload = false
|
|
|
|
- if self.selectIndex == 0 {
|
|
|
|
- if let positionModel = self.positionListDict[symbol] {
|
|
|
|
- positionModel.isUpdate = true
|
|
|
|
- positionModel.SymbolModel.ask = String(format: "%@", currentSocket["ask"] as! CVarArg)
|
|
|
|
- positionModel.SymbolModel.bid = String(format: "%@", currentSocket["bid"] as! CVarArg)
|
|
|
|
-
|
|
|
|
-// let ask = Double(positionModel.SymbolModel.ask) ?? 0.0
|
|
|
|
-// let bid = Double(positionModel.SymbolModel.bid) ?? 0.0
|
|
|
|
-// positionModel.close_price = positionModel.SymbolModel.close
|
|
|
|
- let promd = BaseProductList.shareInstance.productList[symbol]
|
|
|
|
-
|
|
|
|
- let promdc = self.productList[symbol]
|
|
|
|
- promd?.ask = String(format: "%@", currentSocket["ask"] as! CVarArg)
|
|
|
|
- promd?.bid = String(format: "%@", currentSocket["bid"] as! CVarArg)
|
|
|
|
- promdc?.ask = String(format: "%@", currentSocket["ask"] as! CVarArg)
|
|
|
|
- promdc?.bid = String(format: "%@", currentSocket["bid"] as! CVarArg)
|
|
|
|
- isReload = true
|
|
|
|
- }
|
|
|
|
- } else if self.selectIndex == 1 {
|
|
|
|
- if let positionModel = self.entrustListDict[symbol] {
|
|
|
|
- positionModel.SymbolModel.ask = String(format: "%@", currentSocket["ask"] as! CVarArg)
|
|
|
|
- positionModel.SymbolModel.bid = String(format: "%@", currentSocket["bid"] as! CVarArg)
|
|
|
|
- let promd = BaseProductList.shareInstance.productList[symbol]
|
|
|
|
-
|
|
|
|
- let promdc = self.productList[symbol]
|
|
|
|
- promd?.ask = String(format: "%@", currentSocket["ask"] as! CVarArg)
|
|
|
|
- promd?.bid = String(format: "%@", currentSocket["bid"] as! CVarArg)
|
|
|
|
- promdc?.ask = String(format: "%@", currentSocket["ask"] as! CVarArg)
|
|
|
|
- promdc?.bid = String(format: "%@", currentSocket["bid"] as! CVarArg)
|
|
|
|
- isReload = true
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
|
|
let model = self.selectSymbolModel
|
|
let model = self.selectSymbolModel
|
|
if model.symbol == symbol {
|
|
if model.symbol == symbol {
|
|
- isReload = false
|
|
|
|
model.newPrice = "\(currentSocket["ask"] ?? "0")"
|
|
model.newPrice = "\(currentSocket["ask"] ?? "0")"
|
|
let np = conerData(model.newPrice, .MyDouble).2! - conerData(model.open, .MyDouble).2!
|
|
let np = conerData(model.newPrice, .MyDouble).2! - conerData(model.open, .MyDouble).2!
|
|
model.increase = "\(np / conerData(model.open, .MyDouble).2! * 100)"
|
|
model.increase = "\(np / conerData(model.open, .MyDouble).2! * 100)"
|
|
- model.ask = "\(currentSocket["bid"] ?? "0")"
|
|
|
|
- model.bid = "\(currentSocket["ask"] ?? "0")"
|
|
|
|
|
|
+ let bid = "\(currentSocket["bid"] ?? "0")"
|
|
|
|
+ let ask = "\(currentSocket["ask"] ?? "0")"
|
|
|
|
|
|
- let curPrice = ((Double(model.ask) ?? 0) + (Double(model.bid) ?? 0)) / 2
|
|
|
|
|
|
+ let curPrice = ((Double(ask) ?? 0) + (Double(bid) ?? 0)) / 2
|
|
self.price = "\(curPrice)"
|
|
self.price = "\(curPrice)"
|
|
|
|
|
|
- if self.productList[symbol] != nil {
|
|
|
|
- self.productList[symbol]!.ask = "\(currentSocket["ask"] ?? "0")"
|
|
|
|
- self.productList[symbol]!.bid = "\(currentSocket["bid"] ?? "0")"
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
self.observeSymbol.send(value: true)
|
|
self.observeSymbol.send(value: true)
|
|
|
|
|
|
guard let _ = currentSocket["time"] as? Int64 else {
|
|
guard let _ = currentSocket["time"] as? Int64 else {
|
|
@@ -1503,7 +1464,6 @@ extension DealViewModel {
|
|
|
|
|
|
var period = KLinePeriod.minuteFor(kPeriod: KLinePeriod.getDefaultKLinePeriod())
|
|
var period = KLinePeriod.minuteFor(kPeriod: KLinePeriod.getDefaultKLinePeriod())
|
|
period = period * 60
|
|
period = period * 60
|
|
- isReload = true
|
|
|
|
if let firstModel = self.priceList.first {
|
|
if let firstModel = self.priceList.first {
|
|
let firstTime = conerData(firstModel.datetime as Any, .MyCLong).3! + period
|
|
let firstTime = conerData(firstModel.datetime as Any, .MyCLong).3! + period
|
|
|
|
|
|
@@ -1535,18 +1495,9 @@ extension DealViewModel {
|
|
model.low = newPrice
|
|
model.low = newPrice
|
|
self.priceList.insert(model, at: 0)
|
|
self.priceList.insert(model, at: 0)
|
|
}
|
|
}
|
|
- if isReload {
|
|
|
|
- self.signalPriceBlock?()
|
|
|
|
- // self.observePrice.send(value: true)
|
|
|
|
- // if(self.refreshBlock != nil){
|
|
|
|
- // self.refreshBlock!()
|
|
|
|
- // }
|
|
|
|
- }
|
|
|
|
|
|
+ self.signalPriceBlock?()
|
|
} else {
|
|
} else {
|
|
- if isReload {
|
|
|
|
- self.signalPositionBlock?()
|
|
|
|
- // self.observePosition.send(value: true)
|
|
|
|
- }
|
|
|
|
|
|
+ self.signalPositionBlock?()
|
|
}
|
|
}
|
|
} else if currentType == "depth" {
|
|
} else if currentType == "depth" {
|
|
guard let symbol = currentSocket["symbol"] as? String else {
|
|
guard let symbol = currentSocket["symbol"] as? String else {
|
|
@@ -1561,6 +1512,39 @@ extension DealViewModel {
|
|
self.getPriceDepthActionBlock?()
|
|
self.getPriceDepthActionBlock?()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ if let marketDepthModel = MarketDepthModel.deserialize(from: currentSocket) {
|
|
|
|
+ if self.selectIndex == 0 {
|
|
|
|
+ if let positionModel = self.positionListDict[symbol] {
|
|
|
|
+ positionModel.isUpdate = true
|
|
|
|
+ positionModel.SymbolModel.ask = marketDepthModel.asks[0].price
|
|
|
|
+ positionModel.SymbolModel.bid = marketDepthModel.bids[0].price
|
|
|
|
+
|
|
|
|
+ let promd = BaseProductList.shareInstance.productList[symbol]
|
|
|
|
+ let promdc = self.productList[symbol]
|
|
|
|
+
|
|
|
|
+ promd?.ask = marketDepthModel.asks[0].price
|
|
|
|
+ promd?.bid = marketDepthModel.bids[0].price
|
|
|
|
+ promdc?.ask = marketDepthModel.asks[0].price
|
|
|
|
+ promdc?.bid = marketDepthModel.bids[0].price
|
|
|
|
+ }
|
|
|
|
+ } else if self.selectIndex == 1 {
|
|
|
|
+ if let positionModel = self.entrustListDict[symbol] {
|
|
|
|
+ positionModel.SymbolModel.ask = marketDepthModel.asks[0].price
|
|
|
|
+ positionModel.SymbolModel.bid = marketDepthModel.bids[0].price
|
|
|
|
+ let promd = BaseProductList.shareInstance.productList[symbol]
|
|
|
|
+
|
|
|
|
+ let promdc = self.productList[symbol]
|
|
|
|
+ promd?.ask = marketDepthModel.asks[0].price
|
|
|
|
+ promd?.bid = marketDepthModel.bids[0].price
|
|
|
|
+ promdc?.ask = marketDepthModel.asks[0].price
|
|
|
|
+ promdc?.bid = marketDepthModel.bids[0].price
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ self.signalPositionBlock?()
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
} else if type == 1 {
|
|
} else if type == 1 {
|
|
guard let currentSocket = dict.object(forKey: "currentSocket") as? NSDictionary else { return }
|
|
guard let currentSocket = dict.object(forKey: "currentSocket") as? NSDictionary else { return }
|