From 4928e4ffcec7145829af447290644bb5d4c8b238 Mon Sep 17 00:00:00 2001 From: zhouaini528 <465382251@qq.com> Date: Tue, 2 Jan 2024 15:02:35 +0800 Subject: [PATCH] set platform option --- src/Exchanges/Bitget.php | 50 ++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 27 deletions(-) diff --git a/src/Exchanges/Bitget.php b/src/Exchanges/Bitget.php index d7d59dd..fd48436 100644 --- a/src/Exchanges/Bitget.php +++ b/src/Exchanges/Bitget.php @@ -15,11 +15,6 @@ class BaseBitget { protected $platform_future=null; protected $platform_spot=null; - protected $platform_swap=null; - - protected $platform_account=null; - protected $platform_margin=null; - protected $platform_option=null; protected $platform=''; protected $version=''; @@ -41,11 +36,32 @@ protected function checkType($symbol){ return ''; } + /*** + *Initialize exchange + */ + function getPlatform(string $type=''){ + switch (strtolower($type)){ + case 'contract': + case 'future':{ + if($this->platform_future == null) $this->platform_future=new BitgetContractV2($this->key,$this->secret,$this->passphrase,$this->host); + $this->platform_future->setOptions($this->options); + return $this->platform_future; + } + case 'spot': + default:{ + if($this->platform_spot == null) $this->platform_spot=new BitgetSpotV2($this->key,$this->secret,$this->passphrase,$this->host); + $this->platform_spot->setOptions($this->options); + return $this->platform_spot; + } + } + return null; + } + /** Set exchange transaction category, default "spot" transaction. Other options "spot" "margin" "future" "swap" */ public function setPlatform(string $platform=''){ - $this->platform=$platform; + $this->platform=$platform ?? 'spot'; return $this; } @@ -57,6 +73,7 @@ public function setVersion(string $version=''){ return $this; } + /** * Support for more request Settings * */ @@ -64,27 +81,6 @@ function setOptions(array $options=[]){ $this->options=$options; return $this; } - - /*** - *Initialize exchange - */ - function getPlatform(string $type=''){ - switch (strtolower($type)){ - case 'contract': - case 'future':{ - if($this->platform_future == null) $this->platform_future=new BitgetContractV2($this->key,$this->secret,$this->passphrase,$this->host); - $this->platform_future->setOptions($this->options); - return $this->platform_future; - } - case 'spot': - default:{ - if($this->platform_spot == null) $this->platform_spot=new BitgetSpotV2($this->key,$this->secret,$this->passphrase,$this->host); - $this->platform_spot->setOptions($this->options); - return $this->platform_spot; - } - } - return null; - } } class AccountBitget extends BaseBitget implements AccountInterface