Skip to content

Commit

Permalink
update gate
Browse files Browse the repository at this point in the history
  • Loading branch information
zhouaini528 committed Dec 21, 2023
1 parent 1cbcb03 commit 6943b08
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 20 deletions.
47 changes: 38 additions & 9 deletions src/Exchanges/Gate.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ class Gate
protected $platform_margin;
protected $platform_wallet;

protected $platform;

protected $version;

function __construct($key,$secret,$host){
$this->key=$key;
$this->secret=$secret;
Expand Down Expand Up @@ -164,27 +168,25 @@ function getPlatform(string $type=''){
$this->type=strtolower($type);

switch ($this->type){
case 'spot':{
return $this->platform_spot=new GateSpot($this->key,$this->secret,$this->host);;
}
case 'spot_v2':{
$this->host='https://api.gateio.la';
return $this->platform_spot_v2=new GateSpotV2($this->key,$this->secret,$this->host);;
return $this->platform_spot_v2=new GateSpotV2($this->key,$this->secret,$this->host);
}
case 'future':{
return $this->platform_future=new GateFuture($this->key,$this->secret,$this->host);;
return $this->platform_future=new GateFuture($this->key,$this->secret,$this->host);
}
case 'margin':{
return $this->platform_margin=new GateMargin($this->key,$this->secret,$this->host);;
return $this->platform_margin=new GateMargin($this->key,$this->secret,$this->host);
}
case 'delivery':{
return $this->platform_delivery=new GateDelivery($this->key,$this->secret,$this->host);;
return $this->platform_delivery=new GateDelivery($this->key,$this->secret,$this->host);
}
case 'wallet':{
return $this->platform_wallet=new GateWallet($this->key,$this->secret,$this->host);;
return $this->platform_wallet=new GateWallet($this->key,$this->secret,$this->host);
}
case 'spot':
default:{
return null;
return $this->platform_spot=new GateSpot($this->key,$this->secret,$this->host);
}
}
}
Expand Down Expand Up @@ -222,5 +224,32 @@ function setOptions(array $options=[]){

}
}

return $this;
}

/**
Set exchange transaction category, default "spot" transaction. Other options "spot" "margin" "future" "swap"
*/
public function setPlatform(string $platform=''){
$this->platform=$platform ?? 'spot';
return $this;
}

/**
Set exchange API interface version. for example "v1" "v3" "v5"
*/
public function setVersion(string $version=''){
$this->version=$version;
return $this;
}


/**
* Support for more request Settings
* */
/*function setOptions(array $options=[]){
$this->options=$options;
return $this;
}*/
}
23 changes: 12 additions & 11 deletions tests/gate.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,7 @@
$exchanges->setOptions([
//Set the request timeout to 60 seconds by default
'timeout'=>10,

//If you are developing locally and need an agent, you can set this
//'proxy'=>true,
//More flexible Settings
/* 'proxy'=>[
'http' => 'http://127.0.0.1:12333',
'https' => 'http://127.0.0.1:12333',
'no' => ['.cn']
], */
//Close the certificate
//'verify'=>false,

]);

$action=intval($_GET['action'] ?? 0);//http pattern
Expand Down Expand Up @@ -276,6 +266,17 @@
}
break;
}

case 1001:{
try {
$result=$exchanges->getPlatform('spot')->account()->get();
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}

break;
}


default:{
Expand Down

0 comments on commit 6943b08

Please sign in to comment.