Jelajahi Sumber

Merge branch '推广版' of https://git.jdnx.me/tomy/JD_iOS into 推广版

culturetown 6 hari lalu
induk
melakukan
0db3669a39

+ 0 - 3
Koala/Koala/FX/Base/BaseViewController.swift

@@ -60,9 +60,6 @@ class BaseViewController: UIViewController {
     
     override func viewWillAppear(_ animated: Bool) {
         super.viewWillAppear(animated)
-        
-        // 随时检查socket是否处于链接状态
-        //OperationalSymbolSocketManager.shared().checkSymbolLinkStatus()
     }
     
     func createNavigationBar() {

+ 2 - 0
Koala/Koala/FX/NetClass/Network.swift

@@ -1078,6 +1078,8 @@ extension NetWork {
             return switchLanguage("已达最大持仓量")
         case 7000:
             return switchLanguage("持仓未满30分钟,无法平仓")
+        case 2020: // 涨跌停开平仓
+            return switchLanguage("该产品暂停交易")
         default:
             return switchLanguage("网络拥堵,请稍后再试")
         }

+ 2 - 0
Koala/Koala/FX/OtherClass/KLineChart/Model/KMyLineModel.swift

@@ -13,6 +13,8 @@ public class KMyLineModel {
     public var high: CGFloat = 0
     public var low: CGFloat = 0
     public var close: CGFloat = 0
+    public var priceChange: CGFloat = 0
+    public var priceChangePer: CGFloat = 0
     public var vol: CGFloat = 0
     public var datetime: Int64 = 0
 

+ 17 - 2
Koala/Koala/FX/OtherClass/KLineChart/Util/DataUtil.swift

@@ -218,7 +218,11 @@ class DataUtil {
         var rsi: CGFloat = 0
         var rsiABSEma: CGFloat = 0
         var rsiMaxEma: CGFloat = 0
+        var priceChange: CGFloat = 0
+        var priceChangePer: CGFloat = 0
+        
         var startIndex = 0
+        
         if isLast, dataList.count > 13 {
             startIndex = dataList.count - 1
             let data = dataList[dataList.count - 2]
@@ -226,6 +230,7 @@ class DataUtil {
             rsiABSEma = data.rsiABSEma
             rsiMaxEma = data.rsiMaxEma
         }
+        
         for i in startIndex ..< dataList.count {
             let entity = dataList[i]
             let closePrice = entity.close
@@ -233,18 +238,28 @@ class DataUtil {
                 rsi = 0
                 rsiABSEma = 0
                 rsiMaxEma = 0
+                priceChange = 0
+                priceChangePer = 0
             } else {
-                let Rmax = max(0, closePrice - dataList[i - 1].close)
-                let RAbs = abs(closePrice - dataList[i - 1].close)
+                let preClosePrice = dataList[i - 1].close
+                let closeDiff = closePrice - preClosePrice
+                
+                let Rmax = max(0, closeDiff)
+                let RAbs = abs(closeDiff)
                 rsiMaxEma = (Rmax + (14 - 1) * rsiMaxEma) / 14
                 rsiABSEma = (RAbs + (14 - 1) * rsiABSEma) / 14
                 rsi = (rsiMaxEma / rsiABSEma) * 100
+                
+                priceChange = closeDiff
+                priceChangePer = priceChange / preClosePrice * 100.0
             }
             if i < 13 { rsi = 0 }
             if rsi.isNaN { rsi = 0 }
             entity.rsi = rsi
             entity.rsiABSEma = rsiABSEma
             entity.rsiMaxEma = rsiMaxEma
+            entity.priceChange = priceChange
+            entity.priceChangePer = priceChangePer
         }
     }
 

+ 4 - 3
Koala/Koala/FX/OtherClass/KLineChart/View/KLineInfosView.swift

@@ -71,7 +71,7 @@ class KLineInfosView: UIView {
             lowLabel.text = pricePrecisionFormat(KLineStateManger.precision, model.low)
             closeLabel.text = pricePrecisionFormat(KLineStateManger.precision, model.close)
             
-            let upDown = model.close - model.open
+            let upDown = model.priceChange
             var symbol = "-"
             
             if upDown > 0 {
@@ -84,9 +84,10 @@ class KLineInfosView: UIView {
                 self.amplitudeLabel.textColor = self.increaseLabel.textColor
             }
             
-            let upDownPercent = upDown / model.open * 100
             increaseLabel.text = symbol + pricePrecisionFormat(KLineStateManger.precision, abs(upDown))
-            amplitudeLabel.text = symbol + pricePrecisionFormat(KLineStateManger.precision, abs(upDownPercent)) + "%"
+            
+            let upDownPercent = model.priceChangePer
+            amplitudeLabel.text = symbol + pricePrecisionFormat("2", abs(upDownPercent)) + "%"
         }
     }
 }

+ 4 - 0
Koala/Koala/FX/OtherClass/KLineChart/View/KLineOptionView.swift

@@ -9,6 +9,8 @@
 import UIKit
 
 class KLineOptionView: BaseAlertView, UIGestureRecognizerDelegate {
+    var kLineStateManger: KLineStateManger = .init()
+    
     private let containerViewHeight: CGFloat = 175 + 34
     private var originCenter = CGPointZero
     
@@ -215,6 +217,8 @@ extension KLineOptionView: UICollectionViewDelegate {
         if let block = completeBlock {
             block(titleList[indexPath.item] as NSString)
             
+            kLineStateManger.klineChart?.isLongPress = false
+            
             dismissAlert()
         }
     }

+ 3 - 0
Koala/Koala/FX/OtherClass/KLineChart/View/KLinePeriod2View.swift

@@ -84,6 +84,7 @@ class KLinePeriod2View: UIView {
     
     private func handleMoreAction(_ sender: UIButton) {
         let pop = KLineOptionView()
+        pop.kLineStateManger = kLineStateManger
         pop.showPopupView(titles: [switchLanguage("1分"), switchLanguage("5分"), switchLanguage("周K"), switchLanguage("月K"), switchLanguage("年K")], index: currentMoreTitle as NSString) { [weak self] title in
             guard let self = self else { return }
             
@@ -167,6 +168,8 @@ class KLinePeriod2View: UIView {
                 
         kLineStateManger.setisLine(isLine)
         kLineStateManger.kType = kType
+        kLineStateManger.klineChart?.isLongPress = false
+        
         JDLoadView.startAnimating()
     }
     

+ 2 - 0
Koala/Koala/FX/OtherClass/KLineChart/View/KLinePeriodView.swift

@@ -84,6 +84,7 @@ class KLinePeriodView: UIView {
     
     private func handleMoreAction(_ sender: UIButton) {
         let pop = KLineOptionView()
+        pop.kLineStateManger = kLineStateManger
         pop.showPopupView(titles: [switchLanguage("1分"), switchLanguage("5分"), switchLanguage("15分"), switchLanguage("30分"), switchLanguage("60分")], index: currentMoreTitle as NSString) { [weak self] title in
             guard let self = self else { return }
             
@@ -167,6 +168,7 @@ class KLinePeriodView: UIView {
                 
         kLineStateManger.setisLine(isLine)
         kLineStateManger.kType = kType
+        kLineStateManger.klineChart?.isLongPress = false
         
         JDLoadView.startAnimating()
     }

+ 7 - 5
Koala/Koala/Modular/Deal/V/Deal/DealProDataCell.swift

@@ -173,11 +173,10 @@ extension DealProDataCell {
     func updatePrice(vm: DealViewModel) {
         self.VM = vm
         let model = vm.selectSymbolModel
-        let color = exchangeColorAndImage(increase: conerData(model.increase, .MyFloat).1!).0
         
         let price = precisionString(with: model.newPrice, precision: model.digits)
         
-        let difference: Double = conerData(model.newPrice, .MyDouble).2! - conerData(model.open, .MyDouble).2!
+        let difference: Double = conerData(model.newPrice, .MyDouble).2! - conerData(model.close, .MyDouble).2!
         var digits = model.digits
         if Double(digits) ?? 0 == 0 {
             if showThreeDigitPrecision(model.market) {
@@ -189,14 +188,17 @@ extension DealProDataCell {
         
         let differenceStr = precisionString(with: "\(difference)", precision: digits)
         
-        let increase = conerData(model.increase as Any, .MyFloat).1!
+        let increase = (difference/conerData(model.close, .MyDouble).2!) * 100
         var increaseStr = "0%"
         if increase > 0 {
-            increaseStr = "+" + precisionString(with: model.increase, precision: digits) + "%"
+            increaseStr = "+" + precisionString(with: "\(increase)", precision: digits) + "%"
         } else {
-            increaseStr = precisionString(with: model.increase, precision: digits) + "%"
+            increaseStr = precisionString(with: "\(increase)", precision: digits) + "%"
         }
         
+        let color = exchangeColorAndImage(increase: Float(increase)).0
+        model.increase = "\(increase)"
+        
         self.value2Lab.text = String(format: "%@  %@  %@", price, differenceStr, increaseStr)
         self.value2Lab.textColor = color
     }

+ 5 - 0
Koala/Koala/Modular/Deal/V/Deal/DealSimDataCell.swift

@@ -149,6 +149,11 @@ class DealSimDataCell: BaseTableViewCell {
     }
     
     func updateCellPrice(vm: DealViewModel) {
+        
+        let difference: Double = conerData(vm.selectSymbolModel.newPrice, .MyDouble).2! - conerData(vm.selectSymbolModel.close, .MyDouble).2!
+        let increase = (difference/conerData(vm.selectSymbolModel.close, .MyDouble).2!) * 100
+        vm.selectSymbolModel.increase = "\(increase)"
+        
         if vm.selectSymbolModel.digits.count > 0 {
             self.priceLab.text = precisionString(with: vm.selectSymbolModel.newPrice, precision: vm.selectSymbolModel.digits)
             if conerData(vm.selectSymbolModel.increase, .MyFloat).1! > 0 {

+ 21 - 0
Koala/Koala/Modular/MarketDetail/C/MarketAuoteViewController.swift

@@ -58,6 +58,14 @@ class MarketAuoteViewController: BaseViewController {
                 return
             }
             
+            // 异常账户限制交易
+            if OperationalUserInfoData.getUserInfoDataModel().group == "9999" {
+                let pop = JDFuncLimitPopView()
+                pop.showPopupView(title: "", detail: "") { _ in }
+                
+                return
+            }
+            
             let symbolModel = self.symbolModel
             let dealVC = DealViewController()
             dealVC.viewModel.updateSymbols(symbol: symbolModel)
@@ -113,6 +121,14 @@ class MarketAuoteViewController: BaseViewController {
                 return
             }
             
+            // 异常账户限制交易
+            if OperationalUserInfoData.getUserInfoDataModel().group == "9999" {
+                let pop = JDFuncLimitPopView()
+                pop.showPopupView(title: "", detail: "") { _ in }
+                
+                return
+            }
+            
             let symbolModel = self.symbolModel
             let dealVC = DealViewController()
             dealVC.viewModel.updateSymbols(symbol: symbolModel)
@@ -153,6 +169,11 @@ class MarketAuoteViewController: BaseViewController {
         OperationalUserInfoData.refreshUserInfoComplete {
         }
     }
+    
+    override func viewWillAppear(_ animated: Bool) {
+        super.viewWillAppear(animated)
+        OperationalSymbolSocketManager.shared().skipSymbolDisconnect = true
+    }
 }
 
 extension MarketAuoteViewController: JXSegmentedListContainerViewListDelegate {

+ 4 - 3
Koala/Koala/Other/TimerManager.swift

@@ -28,9 +28,10 @@ class SocketTimerManager {
     }
     
     @objc func detectionSocket() {
-        // 开启子线程
-        DispatchQueue.global().async {
-            //OperationalSymbolSocketManager.shared().checkSymbolLinkStatus()
+        if(PriceCalibrator.shareCalibrator.subscribles.count > 0){
+            if(OperationalSymbolSocketManager.shared().symbolConnectCommand.value == true){
+                OperationalSymbolSocketManager.shared().checkSymbolLinkStatus()
+            }
         }
     }
 }