future-public: add kline request
This commit is contained in:
1 parent
429c956e37
commit
0503da7349
5 files changed
+83
-1
No files matched your search
@@ -2,4 +2,34 @@
|
||||
|
||||
namespace Msr\LaravelBitunixApi;
|
||||
|
||||
class LaravelBitunixApi {}
|
||||
use GuzzleHttp\Client;
|
||||
use Msr\LaravelBitunixApi\Requests\FutureKLineRequestContract;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
class LaravelBitunixApi implements FutureKLineRequestContract
|
||||
{
|
||||
private Client $publicFutureClient;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->publicFutureClient = new Client([
|
||||
'base_uri' => config('bitunix-api.future_base_uri') . '/api/v1/futures/market/',
|
||||
]);
|
||||
}
|
||||
|
||||
public function getFutureKline(string $symbol, string $interval, int $limit = 100, ?int $startTime = null, ?int $endTime = null, string $type = 'LAST_PRICE'): ResponseInterface
|
||||
{
|
||||
$response = $this->publicFutureClient->get('kline', [
|
||||
'query' => [
|
||||
'symbol' => $symbol,
|
||||
'interval' => $interval,
|
||||
'limit' => $limit,
|
||||
'startTime' => $startTime,
|
||||
'endTime' => $endTime,
|
||||
'type' => $type,
|
||||
]
|
||||
]);
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Msr\LaravelBitunixApi;
|
||||
|
||||
use Msr\LaravelBitunixApi\Requests\FutureKLineRequestContract;
|
||||
use Spatie\LaravelPackageTools\Package;
|
||||
use Spatie\LaravelPackageTools\PackageServiceProvider;
|
||||
use Msr\LaravelBitunixApi\Commands\LaravelBitunixApiCommand;
|
||||
@@ -22,4 +23,11 @@ class LaravelBitunixApiServiceProvider extends PackageServiceProvider
|
||||
->hasMigration('create_laravel_bitunix_api_table')
|
||||
->hasCommand(LaravelBitunixApiCommand::class);
|
||||
}
|
||||
|
||||
public function packageRegistered(): void
|
||||
{
|
||||
parent::packageRegistered();
|
||||
|
||||
$this->app->bind(FutureKLineRequestContract::class, LaravelBitunixApi::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Msr\LaravelBitunixApi\Requests;
|
||||
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
interface FutureKLineRequestContract
|
||||
{
|
||||
/**
|
||||
* @param string $symbol
|
||||
* @param string $interval
|
||||
* @param int $limit
|
||||
* @param int|null $startTime
|
||||
* @param int|null $endTime
|
||||
* @param string $type
|
||||
* @return ResponseInterface
|
||||
*
|
||||
* interval could be: 1m 5m 15m 30m 1h 2h 4h 6h 8h 12h 1d 3d 1w 1M
|
||||
* limit: max is 200
|
||||
* startTime : milliseconds format
|
||||
* endTime : milliseconds format
|
||||
* type could be: LAST_PRICE, MARK_PRICE
|
||||
*/
|
||||
public function getFutureKline(string $symbol,
|
||||
string $interval,
|
||||
int $limit = 100,
|
||||
?int $startTime = null,
|
||||
?int $endTime = null,
|
||||
string $type = 'LAST_PRICE'): ResponseInterface;
|
||||
}
|
||||
Reference in new issue
Block a user