-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f57d23f
commit f3fcb51
Showing
6 changed files
with
358 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,183 @@ | ||
<?php | ||
/** | ||
* @author lin <[email protected]> | ||
* */ | ||
|
||
namespace Lin\Ftx\Api; | ||
|
||
use Lin\Ftx\Request; | ||
|
||
class Orders extends Request | ||
{ | ||
//authenticat requests signature | ||
protected $authorization=true; | ||
|
||
/** | ||
*GET /orders?market={market} | ||
* */ | ||
public function gets(array $data=[]){ | ||
$this->type='GET'; | ||
$this->path='/orders'; | ||
$this->data=$data; | ||
return $this->exec(); | ||
} | ||
|
||
/** | ||
*GET /orders/history?market={market} | ||
* */ | ||
public function getHistory(array $data=[]){ | ||
$this->type='GET'; | ||
$this->path='/orders/history'; | ||
$this->data=$data; | ||
return $this->exec(); | ||
} | ||
|
||
/** | ||
*GET /conditional_orders?market={market} | ||
* */ | ||
public function getConditionalOrders(array $data=[]){ | ||
$this->type='GET'; | ||
$this->path='/conditional_orders'; | ||
$this->data=$data; | ||
return $this->exec(); | ||
} | ||
|
||
/** | ||
*GET /conditional_orders/{conditional_order_id}/triggers | ||
* */ | ||
public function getConditionalOrderId(array $data=[]){ | ||
$this->type='GET'; | ||
$this->path='/conditional_orders/'.$data['conditional_order_id'].'/triggers'; | ||
unset($data['conditional_order_id']); | ||
$this->data=$data; | ||
return $this->exec(); | ||
} | ||
|
||
/** | ||
*GET /conditional_orders/history?market={market} | ||
* */ | ||
public function getConditionalOrdersHistory(array $data=[]){ | ||
$this->type='GET'; | ||
$this->path='/conditional_orders/history'; | ||
$this->data=$data; | ||
return $this->exec(); | ||
} | ||
|
||
/** | ||
*POST /orders | ||
* */ | ||
public function post(array $data=[]){ | ||
$this->type='POST'; | ||
$this->path='/orders'; | ||
$this->data=$data; | ||
return $this->exec(); | ||
} | ||
|
||
/** | ||
*POST /conditional_orders | ||
* */ | ||
public function postConditionalOrders(array $data=[]){ | ||
$this->type='POST'; | ||
$this->path='/conditional_orders'; | ||
$this->data=$data; | ||
return $this->exec(); | ||
} | ||
|
||
/** | ||
*POST /orders/{order_id}/modify | ||
* */ | ||
public function postModify(array $data=[]){ | ||
$this->type='POST'; | ||
$this->path='/orders/'.$data['order_id'].'/modify'; | ||
unset($data['order_id']); | ||
$this->data=$data; | ||
return $this->exec(); | ||
} | ||
|
||
/** | ||
*POST /orders/by_client_id/{client_order_id}/modify | ||
* */ | ||
public function postByClientIdModify(array $data=[]){ | ||
$this->type='POST'; | ||
$this->path='/orders/by_client_id/'.$data['client_order_id'].'/modify'; | ||
unset($data['client_order_id']); | ||
$this->data=$data; | ||
return $this->exec(); | ||
} | ||
|
||
/** | ||
*POST /conditional_orders/{order_id}/modify | ||
* */ | ||
public function postConditionalOrdersModify(array $data=[]){ | ||
$this->type='POST'; | ||
$this->path='/conditional_orders/'.$data['order_id'].'/modify'; | ||
unset($data['order_id']); | ||
$this->data=$data; | ||
return $this->exec(); | ||
} | ||
|
||
/** | ||
*GET /orders/{order_id} | ||
* */ | ||
public function get(array $data=[]){ | ||
$this->type='GET'; | ||
$this->path='/orders/'.$data['order_id']; | ||
unset($data['order_id']); | ||
$this->data=$data; | ||
return $this->exec(); | ||
} | ||
|
||
/** | ||
*GET /orders/by_client_id/{client_order_id} | ||
* */ | ||
public function getByClientId(array $data=[]){ | ||
$this->type='GET'; | ||
$this->path='/orders/by_client_id/'.$data['client_order_id']; | ||
unset($data['client_order_id']); | ||
$this->data=$data; | ||
return $this->exec(); | ||
} | ||
|
||
/** | ||
*DELETE /orders/{order_id} | ||
* */ | ||
public function delete(array $data=[]){ | ||
$this->type='DELETE'; | ||
$this->path='/orders/'.$data['order_id']; | ||
unset($data['order_id']); | ||
$this->data=$data; | ||
return $this->exec(); | ||
} | ||
|
||
/** | ||
*DELETE /orders/by_client_id/{client_order_id} | ||
* */ | ||
public function deleteByClientId(array $data=[]){ | ||
$this->type='DELETE'; | ||
$this->path='/orders/by_client_id/'.$data['client_order_id']; | ||
unset($data['client_order_id']); | ||
$this->data=$data; | ||
return $this->exec(); | ||
} | ||
|
||
/** | ||
*DELETE /conditional_orders/{id} | ||
* */ | ||
public function deleteConditionalOrders(array $data=[]){ | ||
$this->type='DELETE'; | ||
$this->path='/conditional_orders/'.$data['id']; | ||
unset($data['id']); | ||
$this->data=$data; | ||
return $this->exec(); | ||
} | ||
|
||
/** | ||
*DELETE /orders | ||
* */ | ||
public function deletes(array $data=[]){ | ||
$this->type='DELETE'; | ||
$this->path='/orders'; | ||
$this->data=$data; | ||
return $this->exec(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?php | ||
use Lin\Ftx\Ftx; | ||
|
||
|
||
require __DIR__ .'../../vendor/autoload.php'; | ||
|
||
include 'key_secret.php'; | ||
|
||
$ftx=new Ftx($key,$secret); | ||
|
||
//You can set special needs | ||
$ftx->setOptions([ | ||
//Set the request timeout to 60 seconds by default | ||
'timeout'=>10, | ||
|
||
//https://github.com/guzzle/guzzle | ||
//'proxy'=>[], | ||
|
||
//https://www.php.net/manual/en/book.curl.php | ||
//'curl'=>[], | ||
|
||
//FTX-SUBACCOUNT (optional): URI-encoded name of the subaccount to use. Omit if not using subaccounts. | ||
//'headers'=>['FTX-SUBACCOUNT'=>'xxxx'] | ||
]); | ||
|
||
/*try { | ||
$result=$ftx->markets()->gets(); | ||
print_r($result); | ||
}catch (\Exception $e){ | ||
print_r($e->getMessage()); | ||
}*/ | ||
|
||
try { | ||
$result=$ftx->markets()->get([ | ||
'market_name'=>'BTC/USD',// BTC/USD BTC-PERP BTC-0626 | ||
//'depth'=>'10' | ||
]); | ||
print_r($result); | ||
}catch (\Exception $e){ | ||
print_r($e->getMessage()); | ||
} | ||
|
||
try { | ||
$result=$ftx->markets()->getOrderBook([ | ||
'market_name'=>'BTC-PERP',// BTC/USD BTC-PERP BTC-0626 | ||
//'depth'=>'10' | ||
]); | ||
print_r($result); | ||
}catch (\Exception $e){ | ||
print_r($e->getMessage()); | ||
} | ||
|
||
try { | ||
$result=$ftx->markets()->getTrades([ | ||
'market_name'=>'BTC-0626',// BTC/USD BTC-PERP BTC-0626 | ||
//'depth'=>'10' | ||
]); | ||
print_r($result); | ||
}catch (\Exception $e){ | ||
print_r($e->getMessage()); | ||
} | ||
|
||
try { | ||
$result=$ftx->markets()->getCandles([ | ||
'market_name'=>'BTC-0628',// BTC/USD BTC-PERP BTC-0626 | ||
'resolution'=>'60' | ||
]); | ||
print_r($result); | ||
}catch (\Exception $e){ | ||
print_r($e->getMessage()); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?php | ||
use Lin\Ftx\Ftx; | ||
|
||
|
||
require __DIR__ .'../../vendor/autoload.php'; | ||
|
||
include 'key_secret.php'; | ||
|
||
$ftx=new Ftx($key,$secret); | ||
|
||
//You can set special needs | ||
$ftx->setOptions([ | ||
//Set the request timeout to 60 seconds by default | ||
'timeout'=>10, | ||
|
||
//https://github.com/guzzle/guzzle | ||
//'proxy'=>[], | ||
|
||
//https://www.php.net/manual/en/book.curl.php | ||
//'curl'=>[], | ||
|
||
//FTX-SUBACCOUNT (optional): URI-encoded name of the subaccount to use. Omit if not using subaccounts. | ||
//'headers'=>['FTX-SUBACCOUNT'=>'xxxx'] | ||
]); | ||
|
||
|
||
try { | ||
$result=$ftx->orders()->post([ | ||
'market'=>'BTC/USD', | ||
'side'=>'buy', | ||
'price'=>'10000', | ||
'type'=>'limit', | ||
'size'=>'1', | ||
//'clientId'=>'1234567890', | ||
]); | ||
print_r($result); | ||
}catch (\Exception $e){ | ||
print_r($e->getMessage()); | ||
} | ||
|
||
try { | ||
$result=$ftx->orders()->get([ | ||
'order_id'=>'1234567890', | ||
]); | ||
print_r($result); | ||
|
||
$result=$ftx->orders()->getByClientId([ | ||
'client_order_id'=>'1234567890', | ||
]); | ||
print_r($result); | ||
}catch (\Exception $e){ | ||
print_r($e->getMessage()); | ||
} | ||
|
||
|
||
try { | ||
$result=$ftx->orders()->delete([ | ||
'order_id'=>'1234567890', | ||
]); | ||
print_r($result); | ||
|
||
$result=$ftx->orders()->deleteByClientId([ | ||
'client_order_id'=>'1234567890', | ||
]); | ||
print_r($result); | ||
}catch (\Exception $e){ | ||
print_r($e->getMessage()); | ||
} | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters