作者 karlet

feat:修复api为空判断

@@ -99,7 +99,10 @@ class CmBroker @@ -99,7 +99,10 @@ class CmBroker
99 //复制一个新的实例 99 //复制一个新的实例
100 public function copy() 100 public function copy()
101 { 101 {
102 - $apiInfo = new ApiInfo($this->apiInfo->key, $this->apiInfo->secret, $this->apiInfo->passphrase); 102 + $apiInfo = null;
  103 + if ($this->apiInfo) {
  104 + $apiInfo = new ApiInfo($this->apiInfo->key, $this->apiInfo->secret, $this->apiInfo->passphrase);
  105 + }
103 $cmBroker = new CmBroker($this->plat, $apiInfo); 106 $cmBroker = new CmBroker($this->plat, $apiInfo);
104 $cmBroker->symbolInfos = $this->symbolInfos; 107 $cmBroker->symbolInfos = $this->symbolInfos;
105 $cmBroker->positions = $this->positions; 108 $cmBroker->positions = $this->positions;
@@ -767,7 +770,7 @@ class CmBroker @@ -767,7 +770,7 @@ class CmBroker
767 } 770 }
768 private function initPosMode() 771 private function initPosMode()
769 { 772 {
770 - if ($this->plat == self::PLAT_OKX && $this->apiInfo->key != '') { 773 + if ($this->plat == self::PLAT_OKX && $this->apiInfo && $this->apiInfo->key != '') {
771 $res = $this->exBroker->getAccountConfig(); 774 $res = $this->exBroker->getAccountConfig();
772 $config = $res['data'][0]; 775 $config = $res['data'][0];
773 $this->posMode = $config['posMode'] == 'long_short_mode' ? self::MODE_TWO_SIDE : self::MODE_ONE_SIDE; 776 $this->posMode = $config['posMode'] == 'long_short_mode' ? self::MODE_TWO_SIDE : self::MODE_ONE_SIDE;