Skip to content

Commit

Permalink
set platform option
Browse files Browse the repository at this point in the history
zhouaini528 committed Jan 2, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 0adda89 commit 4928e4f
Showing 1 changed file with 23 additions and 27 deletions.
50 changes: 23 additions & 27 deletions src/Exchanges/Bitget.php
Original file line number Diff line number Diff line change
@@ -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,34 +73,14 @@ public function setVersion(string $version=''){
return $this;
}


/**
* Support for more request Settings
* */
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

0 comments on commit 4928e4f

Please sign in to comment.