Skip to content

Commit

Permalink
Modify the parameters passed in
Browse files Browse the repository at this point in the history
  • Loading branch information
zhouaini528 committed Jul 3, 2019
1 parent 7d0d206 commit 898d671
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ If something goes wrong add composer.json "minimum-stability":"dev"
#### Exchanges initialization
```php
$exchanges=new Exchanges('binance',$key,$secret);
$exchanges=new Exchanges('bitmex',$key,$secret);
$exchanges=new Exchanges('bitmex',$key,$secret,$host);
$exchanges=new Exchanges('okex',$key,$secret,$passphrase,$host);
$exchanges=new Exchanges('huobi',$key,$secret,$account_id,$host);
```
Expand Down
2 changes: 1 addition & 1 deletion README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ composer require linwj/exchanges:dev-master
#### 交易所初始化
```php
$exchanges=new Exchanges('binance',$key,$secret);
$exchanges=new Exchanges('bitmex',$key,$secret);
$exchanges=new Exchanges('bitmex',$key,$secret,$host);
$exchanges=new Exchanges('okex',$key,$secret,$passphrase,$host);
$exchanges=new Exchanges('huobi',$key,$secret,$account_id,$host);
```
Expand Down
8 changes: 6 additions & 2 deletions src/Exchanges.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ function __construct(string $exchange,string $key,string $secret,string $extra='
$this->secret=$secret;
$this->extra=$extra;
$this->host=$host;

if(stripos($extra,'http')===0) {
$this->host=$extra;
$this->extra='';
}
}

function account(){
Expand All @@ -53,14 +58,13 @@ function trader(){
}

/**
* 支持原生访问
* Support native access
* */
public function getPlatform(string $type=''){
if($this->trader!==null) return $this->trader->getPlatform($type);
if($this->market!==null) return $this->market->getPlatform($type);
if($this->acount!==null) return $this->acount->getPlatform($type);

//如果没有就初始化
return $this->trader()->getPlatform($type);
}

Expand Down
3 changes: 1 addition & 2 deletions tests/bitmex.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@
$key=$keysecret['bitmex']['key'];
$secret=$keysecret['bitmex']['secret'];
$host=$keysecret['bitmex']['host'];
$extra='';

$exchanges=new Exchanges('bitmex',$key,$secret,$extra,$host);
$exchanges=new Exchanges('bitmex',$key,$secret,$host);

$action=intval($_GET['action'] ?? 0);//http pattern
if(empty($action)) $action=intval($argv[1]);//cli pattern
Expand Down

0 comments on commit 898d671

Please sign in to comment.