|
@@ -10,6 +10,7 @@ import UIKit
|
|
|
import ReactiveCocoa
|
|
|
import ReactiveSwift
|
|
|
|
|
|
+
|
|
|
class DealViewModel: BaseViewModel {
|
|
|
|
|
|
|
|
@@ -72,8 +73,13 @@ class DealViewModel: BaseViewModel {
|
|
|
|
|
|
var selectSymbolModel:KSymbolModel = KSymbolModel(){
|
|
|
didSet{
|
|
|
+ self.netGetPriceDepth()
|
|
|
+ self.netGetSimPriceList()
|
|
|
self.netGetTradesList()
|
|
|
self.netGetPriceList()
|
|
|
+ self.updatePositionList()
|
|
|
+ self.updateEntrustList()
|
|
|
+ self.updateCloseOrderList()
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -86,14 +92,30 @@ class DealViewModel: BaseViewModel {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ var symbols:[String] = []{
|
|
|
+ didSet{
|
|
|
+ netGetProductList()
|
|
|
+ requestUpdateSubscribeAction()
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ var server:String = ""{
|
|
|
+ didSet{
|
|
|
+ netGetAccountList()
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ var depthModel:MarketDepthModel = MarketDepthModel()
|
|
|
+
|
|
|
var isUpdateKline:Bool = true //是否
|
|
|
var isSimpleness:Bool = true //是否
|
|
|
- var isSell:Bool = true //是否
|
|
|
+ var isSell:Bool = false //是否
|
|
|
var isMarket:Bool = true //是否
|
|
|
var isShowKline:Bool = true //是否
|
|
|
- var num:String = ""
|
|
|
- var profit:String = ""
|
|
|
- var loss:String = ""
|
|
|
+ var isDayLimit:Bool = true //是否
|
|
|
+ var num:String = "1"
|
|
|
+ var profit:String = "0"
|
|
|
+ var loss:String = "0"
|
|
|
var limitType:String = ""
|
|
|
var price:String = ""
|
|
|
var selectOrderType = 0//0,sell,1,buy 2-buyLimit ; 3-sellLimit;4-buyStop;5-sellStop
|
|
@@ -104,9 +126,11 @@ class DealViewModel: BaseViewModel {
|
|
|
let (signalTrade, observeTrade) = Signal<Bool, Never>.pipe()
|
|
|
let (signalPosition, observePosition) = Signal<Bool, Never>.pipe()
|
|
|
|
|
|
- //getPositionList
|
|
|
- var groupListAction: Action <(),(Bool),Never>!
|
|
|
- var userListAction: Action <(),(Bool),Never>!
|
|
|
+ //netForHomeSymbolList
|
|
|
+ var getProductListAction: Action <(),(Bool),Never>!
|
|
|
+ var getPriceDepthAction: Action <(),(Bool),Never>!
|
|
|
+ var getSimPriceListAction: Action <(),(Bool),Never>!
|
|
|
+
|
|
|
var symbolListAction: Action <(),(Bool),Never>!
|
|
|
var insertProductUserAction: Action <(String),(Bool),Never>!
|
|
|
var deleteProductUserAction: Action <(String),(Bool),Never>!
|
|
@@ -121,34 +145,35 @@ class DealViewModel: BaseViewModel {
|
|
|
|
|
|
|
|
|
override func initialize() {
|
|
|
- groupListAction = Action<(),(Bool),Never> {[weak self] _ in
|
|
|
+ getProductListAction = Action<(),(Bool),Never> {[weak self] _ in
|
|
|
return SignalProducer<(Bool),Never>{ observer, _ in
|
|
|
- self?.requestGroupList(observer: observer)
|
|
|
- }
|
|
|
- }
|
|
|
- userListAction = Action<(),(Bool),Never> {[weak self] _ in
|
|
|
- return SignalProducer<(Bool),Never>{ observer, _ in
|
|
|
- self?.requestUserList(observer: observer)
|
|
|
+ self?.requestGetProductList(observer: observer)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- symbolListAction = Action<(),(Bool),Never> {[weak self] _ in
|
|
|
+ getPriceDepthAction = Action<(),(Bool),Never> {[weak self] _ in
|
|
|
return SignalProducer<(Bool),Never>{ observer, _ in
|
|
|
- self?.requestSymbolList(observer: observer)
|
|
|
+ self?.requestGetPriceDepth(observer: observer)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- insertProductUserAction = Action<(String),(Bool),Never> {[weak self] symbol in
|
|
|
+ getSimPriceListAction = Action<(),(Bool),Never> {[weak self] _ in
|
|
|
return SignalProducer<(Bool),Never>{ observer, _ in
|
|
|
- self?.requestInsertProductUser(observer: observer,symbol:symbol)
|
|
|
+ self?.requestGetSimPriceList(observer: observer)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- deleteProductUserAction = Action<(String),(Bool),Never> {[weak self] symbol in
|
|
|
- return SignalProducer<(Bool),Never>{ observer, _ in
|
|
|
- self?.requestDeleteProductUser(observer: observer,symbol:symbol)
|
|
|
- }
|
|
|
- }
|
|
|
+// insertProductUserAction = Action<(String),(Bool),Never> {[weak self] symbol in
|
|
|
+// return SignalProducer<(Bool),Never>{ observer, _ in
|
|
|
+// self?.requestInsertProductUser(observer: observer,symbol:symbol)
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// deleteProductUserAction = Action<(String),(Bool),Never> {[weak self] symbol in
|
|
|
+// return SignalProducer<(Bool),Never>{ observer, _ in
|
|
|
+// self?.requestDeleteProductUser(observer: observer,symbol:symbol)
|
|
|
+// }
|
|
|
+// }
|
|
|
|
|
|
getPriceListAction = Action<(),(Bool),Never> {[weak self] _ in
|
|
|
return SignalProducer<(Bool),Never>{ observer, _ in
|
|
@@ -207,59 +232,33 @@ class DealViewModel: BaseViewModel {
|
|
|
}
|
|
|
|
|
|
extension DealViewModel{
|
|
|
- //获取产品分组列表
|
|
|
- func netGroupList() {
|
|
|
- groupListAction.apply().start()
|
|
|
- }
|
|
|
- //获取产品分组列表
|
|
|
- func requestGroupList(observer: Signal< Bool, Never>.Observer) -> Void {
|
|
|
-
|
|
|
- NetWork.NetWorkInstance.requestData(requestType: .Post, URLString: netForProductGroupList, success: { (code, result) in
|
|
|
- if let list:[NSDictionary] = result?["list"] as? [NSDictionary] {
|
|
|
- self.productGroupList.removeAll()
|
|
|
- for dic in list {
|
|
|
- let model = MarketProductGroupModel.deserialize(from: dic)
|
|
|
- self.productGroupList.append(model!)
|
|
|
- }
|
|
|
- observer.send(value: true)
|
|
|
- }else{
|
|
|
- observer.send(value: false)
|
|
|
- ProgressHUD.showError(status:DataTypeErrorPrompt)
|
|
|
- }
|
|
|
- observer.sendCompleted()
|
|
|
- }) { (code, result) in
|
|
|
- ProgressHUD.showError(status: result as! String)
|
|
|
- observer.send(value: false)
|
|
|
- observer.sendCompleted()
|
|
|
+ //
|
|
|
+ func netGetAccountList() {
|
|
|
+ if (OperationalUserInfoData.getLogin()){
|
|
|
+ getAccountListAction.apply().start()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //获取自选产品列表
|
|
|
- func netUserList() {
|
|
|
- if OperationalUserInfoData.getLogin(){
|
|
|
- userListAction.apply().start()
|
|
|
- }else{
|
|
|
- self.collectionList.removeAll()
|
|
|
- for model in self.symbolList {
|
|
|
- model.isCollection = false
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- func requestUserList(observer: Signal< Bool, Never>.Observer) -> Void {
|
|
|
-
|
|
|
- NetWork.NetWorkInstance.requestData(requestType: .Post, URLString: netForProductUserList, success: { (code, result) in
|
|
|
-
|
|
|
- if let list:[NSDictionary] = result?["list"] as? [NSDictionary] {
|
|
|
- self.collectionList.removeAll()
|
|
|
- for dic in list {
|
|
|
- self.collectionList.append((dic["symbol"] as? String) ?? "")
|
|
|
+ func requestGetAccountList(observer: Signal< Bool, Never>.Observer) -> Void {
|
|
|
+ NetWork.NetWorkInstance.requestData(requestType: .Post, URLString: netForGetAccountList, success: { (code, result) in
|
|
|
+ ProgressHUD.hideHud()
|
|
|
+ if let dict:NSDictionary = result as? NSDictionary {
|
|
|
+ if let list:[NSDictionary] = dict["list"] as? [NSDictionary]{
|
|
|
+ self.accountList.removeAll()
|
|
|
+ for dic in list {
|
|
|
+ let model = AccountInfoModel.deserialize(from: dic)!
|
|
|
+ model.defaultAccount = conerData(String(format: "%@",dic["default"] as! CVarArg), .MyInt).0!
|
|
|
+ if model.server == self.server {
|
|
|
+ self.accountInfoModel = model
|
|
|
+ }
|
|
|
+ self.accountList.append(model)
|
|
|
+ }
|
|
|
+ observer.send(value: true)
|
|
|
+ }else{
|
|
|
+ observer.send(value: false)
|
|
|
}
|
|
|
- self.updateSymbolListCollection()
|
|
|
- observer.send(value: true)
|
|
|
}else{
|
|
|
observer.send(value: false)
|
|
|
- ProgressHUD.showError(status:DataTypeErrorPrompt)
|
|
|
}
|
|
|
observer.sendCompleted()
|
|
|
}) { (code, result) in
|
|
@@ -269,63 +268,52 @@ extension DealViewModel{
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //获取交易对
|
|
|
- func netSymbolList() {
|
|
|
- symbolListAction.apply().start()
|
|
|
- }
|
|
|
- //
|
|
|
- func requestSymbolList(observer: Signal< Bool, Never>.Observer) -> Void {
|
|
|
- if getSymbolList().count > 0 {
|
|
|
- self.symbolList = getSymbolList()
|
|
|
- self.updatePositionList()
|
|
|
- self.updateCloseOrderList()
|
|
|
- if DealSymbool.length > 0 {
|
|
|
- for model in self.symbolList{
|
|
|
- if model.symbol == DealSymbool{
|
|
|
- self.selectSymbolModel = model
|
|
|
- DealSymbool = ""
|
|
|
- break
|
|
|
- }
|
|
|
- }
|
|
|
- }else{
|
|
|
- if let firstModel = self.symbolList.first {
|
|
|
- self.selectSymbolModel = firstModel
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- self.updateSymbolListCollection()
|
|
|
- observer.send(value: true)
|
|
|
- observer.sendCompleted()
|
|
|
- return
|
|
|
+ func netGetProductList() {
|
|
|
+ if (OperationalUserInfoData.getLogin()){
|
|
|
+ getProductListAction.apply().start()
|
|
|
}
|
|
|
- ProgressHUD.showMessage(status:"")
|
|
|
- NetWork.NetWorkInstance.requestData(requestType: .Post, URLString: netForHomeSymbolList, success: { (code, result) in
|
|
|
+ }
|
|
|
+
|
|
|
+ func requestGetProductList(observer: Signal< Bool, Never>.Observer) -> Void {
|
|
|
+
|
|
|
+ let parame:[String:Any] = [
|
|
|
+ "symbol":getJSONStringFromArray(array: self.symbols as NSArray)
|
|
|
+ ]
|
|
|
+
|
|
|
+ NetWork.NetWorkInstance.requestData(requestType: .Post, URLString: netForHomeSymbolList,parameters: parame, success: { (code, result) in
|
|
|
ProgressHUD.hideHud()
|
|
|
- if let list:[NSDictionary] = result?["list"] as? [NSDictionary] {
|
|
|
- self.symbolList.removeAll()
|
|
|
- SaveData.shared().updateSymbolList(list: list as NSArray)
|
|
|
- self.symbolList = getSymbolList()
|
|
|
- self.updatePositionList()
|
|
|
- self.updateCloseOrderList()
|
|
|
- if DealSymbool.length > 0 {
|
|
|
- for model in self.symbolList{
|
|
|
- if model.symbol == DealSymbool{
|
|
|
- self.selectSymbolModel = model
|
|
|
- DealSymbool = ""
|
|
|
- break
|
|
|
+ if let dict:NSDictionary = result as? NSDictionary {
|
|
|
+ if let list:[NSDictionary] = dict["list"] as? [NSDictionary]{
|
|
|
+ self.symbolList.removeAll()
|
|
|
+ for dict in list{
|
|
|
+ let model = KSymbolModel.deserialize(from: dict)
|
|
|
+ if model!.visible == 1{
|
|
|
+ var ask = model!.ask
|
|
|
+ if conerData(ask, .MyDouble).2! == 0{
|
|
|
+ ask = model!.open
|
|
|
+ }
|
|
|
+ model?.newPrice = precisionString(with: ask, precision: model!.digits)
|
|
|
+ let np = decimalNumber(A: model!.newPrice, B: model!.open, type: .Subtract, scale:model!.digits)
|
|
|
+ let increase = (conerData(np, .MyDouble).2!/conerData(model!.open, .MyDouble).2!)*100
|
|
|
+ model?.increase = String(format: "%.2f",increase)
|
|
|
+
|
|
|
+ }
|
|
|
+ let symbol = self.symbols.last
|
|
|
+ if model!.symbol == symbol{
|
|
|
+ self.selectSymbolModel = model!
|
|
|
+ self.price = model!.newPrice
|
|
|
}
|
|
|
+ self.symbolList.append(model!)
|
|
|
}
|
|
|
+ self.updateEntrustList()
|
|
|
+ self.updatePositionList()
|
|
|
+ self.updateCloseOrderList()
|
|
|
+ observer.send(value: true)
|
|
|
}else{
|
|
|
- if let firstModel = self.symbolList.first {
|
|
|
- self.selectSymbolModel = firstModel
|
|
|
- }
|
|
|
+ observer.send(value: false)
|
|
|
}
|
|
|
-
|
|
|
- self.updateSymbolListCollection()
|
|
|
- observer.send(value: true)
|
|
|
}else{
|
|
|
observer.send(value: false)
|
|
|
- ProgressHUD.showError(status:DataTypeErrorPrompt)
|
|
|
}
|
|
|
observer.sendCompleted()
|
|
|
}) { (code, result) in
|
|
@@ -335,27 +323,29 @@ extension DealViewModel{
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //添加收藏
|
|
|
- func netInsertProductUser(symbol:String) {
|
|
|
- if OperationalUserInfoData.getLogin(){
|
|
|
- insertProductUserAction.apply(symbol).start()
|
|
|
- }else{
|
|
|
- currentVc()!.navigationController?.pushViewController(LoginViewController(), animated: true)
|
|
|
- }
|
|
|
+ func netGetPriceDepth() -> Void {
|
|
|
+ getPriceDepthAction.apply().start()
|
|
|
}
|
|
|
|
|
|
- func requestInsertProductUser(observer: Signal< Bool, Never>.Observer,symbol:String) -> Void {
|
|
|
-
|
|
|
- let parame:[String:Any] = ["symbol":symbol]
|
|
|
- NetWork.NetWorkInstance.requestData(requestType: .Post, URLString: netForInsertProductUser ,parameters: parame, success: { (code, result) in
|
|
|
- ProgressHUD.showSuccess(status: switchLanguage("收藏成功"))
|
|
|
- self.collectionList.append(symbol)
|
|
|
- for model in self.symbolList{
|
|
|
- if model.symbol == symbol{
|
|
|
- model.isCollection = true
|
|
|
- }
|
|
|
+ func requestGetPriceDepth(observer: Signal< Bool, Never>.Observer) -> Void {
|
|
|
+
|
|
|
+ let param = [
|
|
|
+ "symbol":self.selectSymbolModel.symbol,
|
|
|
+ ]
|
|
|
+
|
|
|
+ ProgressHUD.showLoading()
|
|
|
+ NetWork.NetWorkInstance.requestData(requestType: .Post, URLString: netForGetPriceDepth,parameters:param , success: { (code, result) in
|
|
|
+
|
|
|
+ ProgressHUD.hideHud()
|
|
|
+
|
|
|
+ if let dic:NSDictionary = result as? NSDictionary {
|
|
|
+ self.depthModel = MarketDepthModel.deserialize(from: dic)!
|
|
|
+ observer.send(value: true)
|
|
|
+ }else{
|
|
|
+
|
|
|
+ observer.send(value: false)
|
|
|
+ ProgressHUD.showError(status:DataTypeErrorPrompt)
|
|
|
}
|
|
|
- observer.send(value: true)
|
|
|
observer.sendCompleted()
|
|
|
}) { (code, result) in
|
|
|
ProgressHUD.showError(status: result as! String)
|
|
@@ -364,27 +354,37 @@ extension DealViewModel{
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //取消收藏
|
|
|
- func netDeleteProductUser(symbol:String) {
|
|
|
- if OperationalUserInfoData.getLogin(){
|
|
|
- deleteProductUserAction.apply(symbol).start()
|
|
|
- }else{
|
|
|
- currentVc()!.navigationController?.pushViewController(LoginViewController(), animated: true)
|
|
|
- }
|
|
|
+ //获取行情数据
|
|
|
+ func netGetSimPriceList() {
|
|
|
+ getSimPriceListAction.apply().start()
|
|
|
}
|
|
|
-
|
|
|
- func requestDeleteProductUser(observer: Signal< Bool, Never>.Observer,symbol:String) -> Void {
|
|
|
- let parame:[String:Any] = ["symbol":symbol]
|
|
|
- NetWork.NetWorkInstance.requestData(requestType: .Post, URLString: netForDeleteProductUser,parameters: parame, success: { (code, result) in
|
|
|
- ProgressHUD.showSuccess(status: switchLanguage("取消成功"))
|
|
|
- let index = self.collectionList.firstIndex(of: symbol)
|
|
|
- self.collectionList.remove(at:index!)
|
|
|
- for model in self.symbolList{
|
|
|
- if model.symbol == symbol{
|
|
|
- model.isCollection = false
|
|
|
+ //获取行情数据
|
|
|
+ func requestGetSimPriceList(observer: Signal< Bool, Never>.Observer) -> Void {
|
|
|
+
|
|
|
+ let endDate:String = currentTimeStamp()
|
|
|
+
|
|
|
+ let param = [
|
|
|
+ "symbol":self.selectSymbolModel.symbol,
|
|
|
+ "type":1,
|
|
|
+ "endTime":endDate+"000",
|
|
|
+ "count": 40
|
|
|
+ ] as [String : Any]
|
|
|
+
|
|
|
+ ProgressHUD.showLoading()
|
|
|
+ NetWork.NetWorkInstance.requestData(requestType: .Post, URLString: netForGetPriceList,parameters:param , success: { (code, result) in
|
|
|
+ ProgressHUD.hideHud()
|
|
|
+ if let list:[NSDictionary] = result as? [NSDictionary] {
|
|
|
+ self.priceList.removeAll()
|
|
|
+ for dic in list {
|
|
|
+ let model = CTMarketChartsModel.deserialize(from: dic)!
|
|
|
+ model.datetime = decimalNumber(A: model.datetime, B: "1000", type: .Divid)
|
|
|
+ self.priceList.append(model)
|
|
|
}
|
|
|
+ observer.send(value: true)
|
|
|
+ }else{
|
|
|
+ observer.send(value: false)
|
|
|
+ ProgressHUD.showError(status:DataTypeErrorPrompt)
|
|
|
}
|
|
|
- observer.send(value: true)
|
|
|
observer.sendCompleted()
|
|
|
}) { (code, result) in
|
|
|
ProgressHUD.showError(status: result as! String)
|
|
@@ -468,42 +468,7 @@ extension DealViewModel{
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //
|
|
|
- func netGetAccountList() {
|
|
|
- if (OperationalUserInfoData.getLogin()){
|
|
|
- getAccountListAction.apply().start()
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- func requestGetAccountList(observer: Signal< Bool, Never>.Observer) -> Void {
|
|
|
- NetWork.NetWorkInstance.requestData(requestType: .Post, URLString: netForGetAccountList, success: { (code, result) in
|
|
|
- ProgressHUD.hideHud()
|
|
|
- if let dict:NSDictionary = result as? NSDictionary {
|
|
|
- if let list:[NSDictionary] = dict["list"] as? [NSDictionary]{
|
|
|
- self.accountList.removeAll()
|
|
|
- for dic in list {
|
|
|
- let model = AccountInfoModel.deserialize(from: dic)!
|
|
|
- model.defaultAccount = conerData(String(format: "%@",dic["default"] as! CVarArg), .MyInt).0!
|
|
|
- if model.defaultAccount == 1 {
|
|
|
- self.accountInfoModel = model
|
|
|
- }
|
|
|
- self.accountList.append(model)
|
|
|
- }
|
|
|
- observer.send(value: true)
|
|
|
- }else{
|
|
|
- observer.send(value: false)
|
|
|
- }
|
|
|
- }else{
|
|
|
- observer.send(value: false)
|
|
|
- }
|
|
|
- observer.sendCompleted()
|
|
|
- }) { (code, result) in
|
|
|
- ProgressHUD.showError(status: result as! String)
|
|
|
- observer.send(value: false)
|
|
|
- observer.sendCompleted()
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
+
|
|
|
func netOpenPosition() {
|
|
|
if self.accountInfoModel.account.length > 0 {
|
|
|
openPositionAction.apply().start()
|
|
@@ -517,7 +482,8 @@ extension DealViewModel{
|
|
|
"cmd":self.selectOrderType,
|
|
|
"volume":self.num,
|
|
|
"sl":self.loss,
|
|
|
- "tp":self.profit
|
|
|
+ "tp":self.profit,
|
|
|
+ "server":self.accountInfoModel.server as Any
|
|
|
] as [String : Any]
|
|
|
|
|
|
ProgressHUD.showLoading()
|
|
@@ -586,19 +552,26 @@ extension DealViewModel{
|
|
|
func requestGetPositionList(observer: Signal< Bool, Never>.Observer) -> Void {
|
|
|
ProgressHUD.showLoading()
|
|
|
let param = [
|
|
|
- "account": self.accountInfoModel.account as Any
|
|
|
+ "account": self.accountInfoModel.account as Any,
|
|
|
+ "server":self.accountInfoModel.server
|
|
|
] as [String : Any]
|
|
|
NetWork.NetWorkInstance.requestData(requestType: .Post, URLString: netForGetPositionList,parameters: param,success: { (code, result) in
|
|
|
ProgressHUD.hideHud()
|
|
|
if let dict:NSDictionary = result as? NSDictionary {
|
|
|
if let list:[NSDictionary] = dict["list"] as? [NSDictionary]{
|
|
|
+ var sys:[String] = [String]()
|
|
|
self.positionList.removeAll()
|
|
|
for dic in list {
|
|
|
let model = PositionListModel.deserialize(from: dic)!
|
|
|
model.volume = decimalNumber(A: model.volume, B: model.SymbolModel.lot_min, type: .Multiply)
|
|
|
self.positionList.append(model)
|
|
|
+ sys.append(model.symbol)
|
|
|
+ }
|
|
|
+ if self.isChangeServer(){
|
|
|
+ self.symbols = sys
|
|
|
}
|
|
|
self.updatePositionList()
|
|
|
+
|
|
|
observer.send(value: true)
|
|
|
}else{
|
|
|
observer.send(value: false)
|
|
@@ -635,6 +608,7 @@ extension DealViewModel{
|
|
|
let model = EntrustListModel.deserialize(from: dic)!
|
|
|
self.entrustList.append(model)
|
|
|
}
|
|
|
+ self.updateEntrustList()
|
|
|
observer.send(value: true)
|
|
|
}else{
|
|
|
observer.send(value: false)
|
|
@@ -687,6 +661,22 @@ extension DealViewModel{
|
|
|
observer.sendCompleted()
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ func requestUpdateSubscribeAction() -> Void {
|
|
|
+ let parame:[String:Any] = [
|
|
|
+ "symbols":getJSONStringFromArray(array: self.symbols as NSArray)
|
|
|
+ ]
|
|
|
+ NetWork.NetWorkInstance.requestData(requestType: .Post, URLString: netUpdateSubscribe, parameters: parame) { (code, result) in
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ } failured: { (code, result) in
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
@@ -707,12 +697,37 @@ extension DealViewModel{
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ func updateSymbols(symbol:String) -> Void {
|
|
|
+
|
|
|
+ for (i,str) in self.symbols.enumerated(){
|
|
|
+ if symbol == str{
|
|
|
+ self.symbols.remove(at: i)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ self.symbols.append(symbol)
|
|
|
+ }
|
|
|
+
|
|
|
func updatePositionList() -> Void {
|
|
|
- guard self.positionList.count > 0 && self.symbolList.count > 0 else {
|
|
|
+ guard self.positionList.count > 0 && self.symbolList.count > 0 else {
|
|
|
return
|
|
|
}
|
|
|
- for model in self.symbolList {
|
|
|
- for m in self.positionList {
|
|
|
+ for m in self.positionList {
|
|
|
+ for model in self.symbolList{
|
|
|
+ if m.symbol == model.symbol{
|
|
|
+ m.SymbolModel = model
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ func updateEntrustList() -> Void {
|
|
|
+ guard self.entrustList.count > 0 && self.symbolList.count > 0 else {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for m in self.entrustList {
|
|
|
+ for model in self.symbolList{
|
|
|
if m.symbol == model.symbol{
|
|
|
m.SymbolModel = model
|
|
|
continue
|
|
@@ -722,11 +737,11 @@ extension DealViewModel{
|
|
|
}
|
|
|
|
|
|
func updateCloseOrderList() -> Void {
|
|
|
- guard self.closeOrderList.count > 0 && self.symbolList.count > 0 else {
|
|
|
+ guard self.closeOrderList.count > 0 && self.symbolList.count > 0 else {
|
|
|
return
|
|
|
}
|
|
|
- for model in self.symbolList {
|
|
|
- for m in self.closeOrderList {
|
|
|
+ for m in self.closeOrderList {
|
|
|
+ for model in self.symbolList{
|
|
|
if m.symbol == model.symbol{
|
|
|
m.SymbolModel = model
|
|
|
continue
|
|
@@ -735,6 +750,15 @@ extension DealViewModel{
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ func isChangeServer() -> Bool {
|
|
|
+ if self.server == self.accountInfoModel.server {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ return true
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
extension DealViewModel{
|