Skip to content

Commit

Permalink
New methods (#34)
Browse files Browse the repository at this point in the history
* Add swapDayTotal method

* Add swapMonthTotal method

* Add swapInfoSell method

* Add swapInfoSellVol method

* Add bLiquidity method

* Add biCurBase method

* Add biCurBacket method

* Add repoDebtUSD method
  • Loading branch information
liquetsoft committed Oct 5, 2023
1 parent 32eb34e commit f668b56
Show file tree
Hide file tree
Showing 11 changed files with 994 additions and 1 deletion.
164 changes: 163 additions & 1 deletion src/CbrfDaily.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

namespace Liquetsoft\CbrfService;

use Liquetsoft\CbrfService\Entity\BiCurBacketItem;
use Liquetsoft\CbrfService\Entity\BiCurBaseRate;
use Liquetsoft\CbrfService\Entity\BliquidityRate;
use Liquetsoft\CbrfService\Entity\CurrencyEnum;
use Liquetsoft\CbrfService\Entity\CurrencyRate;
use Liquetsoft\CbrfService\Entity\DepoRate;
Expand All @@ -17,11 +20,16 @@
use Liquetsoft\CbrfService\Entity\OvernightRate;
use Liquetsoft\CbrfService\Entity\PreciousMetalRate;
use Liquetsoft\CbrfService\Entity\RepoDebt;
use Liquetsoft\CbrfService\Entity\RepoDebtUSDRate;
use Liquetsoft\CbrfService\Entity\ReutersCurrency;
use Liquetsoft\CbrfService\Entity\ReutersCurrencyRate;
use Liquetsoft\CbrfService\Entity\RuoniaBid;
use Liquetsoft\CbrfService\Entity\RuoniaIndex;
use Liquetsoft\CbrfService\Entity\Saldo;
use Liquetsoft\CbrfService\Entity\SwapDayTotalRate;
use Liquetsoft\CbrfService\Entity\SwapInfoSellItem;
use Liquetsoft\CbrfService\Entity\SwapInfoSellVolItem;
use Liquetsoft\CbrfService\Entity\SwapMonthTotalRate;
use Liquetsoft\CbrfService\Entity\SwapRate;
use Liquetsoft\CbrfService\Exception\CbrfException;

Expand Down Expand Up @@ -567,7 +575,7 @@ public function getReutersCursOnDate(\DateTimeInterface $date): array
}

/**
* Returns prices for coins.
* Returns rates of overnight loans.
*
* @return OvernightRate[]
*
Expand All @@ -585,4 +593,158 @@ public function overnight(\DateTimeInterface $from, \DateTimeInterface $to): arr

return DataHelper::arrayOfItems('Overnight.OB', $res, OvernightRate::class);
}

/**
* Returns rates for currency swap.
*
* @return SwapDayTotalRate[]
*
* @throws CbrfException
*/
public function swapDayTotal(\DateTimeInterface $from, \DateTimeInterface $to): array
{
$res = $this->transport->query(
'SwapDayTotal',
[
'fromDate' => $from,
'ToDate' => $to,
]
);

return DataHelper::arrayOfItems('SwapDayTotal.SDT', $res, SwapDayTotalRate::class);
}

/**
* Returns rates for currency swap by eur and usd.
*
* @return SwapMonthTotalRate[]
*
* @throws CbrfException
*/
public function swapMonthTotal(\DateTimeInterface $from, \DateTimeInterface $to): array
{
$res = $this->transport->query(
'SwapMonthTotal',
[
'fromDate' => $from,
'ToDate' => $to,
]
);

return DataHelper::arrayOfItems('SwapMonthTotal.SMT', $res, SwapMonthTotalRate::class);
}

/**
* Returns conditions for currency swap.
*
* @return SwapInfoSellItem[]
*
* @throws CbrfException
*/
public function swapInfoSell(\DateTimeInterface $from, \DateTimeInterface $to): array
{
$res = $this->transport->query(
'SwapInfoSell',
[
'fromDate' => $from,
'ToDate' => $to,
]
);

return DataHelper::arrayOfItems('SwapInfoSell.SSU', $res, SwapInfoSellItem::class);
}

/**
* Returns sell volume for currency swap.
*
* @return SwapInfoSellVolItem[]
*
* @throws CbrfException
*/
public function swapInfoSellVol(\DateTimeInterface $from, \DateTimeInterface $to): array
{
$res = $this->transport->query(
'SwapInfoSellVol',
[
'fromDate' => $from,
'ToDate' => $to,
]
);

return DataHelper::arrayOfItems('SwapInfoSellVol.SSUV', $res, SwapInfoSellVolItem::class);
}

/**
* Returns banks liquidity.
*
* @return BliquidityRate[]
*
* @throws CbrfException
*/
public function bLiquidity(\DateTimeInterface $from, \DateTimeInterface $to): array
{
$res = $this->transport->query(
'Bliquidity',
[
'fromDate' => $from,
'ToDate' => $to,
]
);

return DataHelper::arrayOfItems('Bliquidity.BL', $res, BliquidityRate::class);
}

/**
* Returns bi currency backet price.
*
* @return BiCurBaseRate[]
*
* @throws CbrfException
*/
public function biCurBase(\DateTimeInterface $from, \DateTimeInterface $to): array
{
$res = $this->transport->query(
'BiCurBase',
[
'fromDate' => $from,
'ToDate' => $to,
]
);

return DataHelper::arrayOfItems('BiCurBase.BCB', $res, BiCurBaseRate::class);
}

/**
* Returns bi currency backet structure.
*
* @return BiCurBacketItem[]
*
* @throws CbrfException
*/
public function biCurBacket(): array
{
$res = $this->transport->query('BiCurBacket');

return DataHelper::arrayOfItems('BiCurBacket.BC', $res, BiCurBacketItem::class);
}

/**
* Returns repo debts.
*
* @return RepoDebtUSDRate[]
*
* @throws CbrfException
*/
public function repoDebtUSD(\DateTimeInterface $from, \DateTimeInterface $to): array
{
$res = $this->transport->query(
'RepoDebtUSD',
[
'fromDate' => $from,
'ToDate' => $to,
]
);

return DataHelper::arrayOfItems('RepoDebtUSD.rd', $res, RepoDebtUSDRate::class);
}
}
43 changes: 43 additions & 0 deletions src/Entity/BiCurBacketItem.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

declare(strict_types=1);

namespace Liquetsoft\CbrfService\Entity;

use Liquetsoft\CbrfService\DataHelper;

/**
* DTO that represents response item from BiCurBacket method.
*
* @psalm-immutable
*/
final class BiCurBacketItem
{
private readonly \DateTimeInterface $date;

private readonly float $usd;

private readonly float $eur;

public function __construct(array $item)
{
$this->date = DataHelper::dateTime('D0', $item);
$this->usd = DataHelper::float('USD', $item, .0);
$this->eur = DataHelper::float('EUR', $item, .0);
}

public function getDate(): \DateTimeInterface
{
return $this->date;
}

public function getUSD(): float
{
return $this->usd;
}

public function getEUR(): float
{
return $this->eur;
}
}
36 changes: 36 additions & 0 deletions src/Entity/BiCurBaseRate.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

declare(strict_types=1);

namespace Liquetsoft\CbrfService\Entity;

use Liquetsoft\CbrfService\CbrfEntityRate;
use Liquetsoft\CbrfService\DataHelper;

/**
* DTO that represents response item from BiCurBase method.
*
* @psalm-immutable
*/
final class BiCurBaseRate implements CbrfEntityRate
{
private readonly \DateTimeInterface $date;

private readonly float $rate;

public function __construct(array $item)
{
$this->date = DataHelper::dateTime('D0', $item);
$this->rate = DataHelper::float('VAL', $item, .0);
}

public function getDate(): \DateTimeInterface
{
return $this->date;
}

public function getRate(): float
{
return $this->rate;
}
}
116 changes: 116 additions & 0 deletions src/Entity/BliquidityRate.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
<?php

declare(strict_types=1);

namespace Liquetsoft\CbrfService\Entity;

use Liquetsoft\CbrfService\CbrfEntityRate;
use Liquetsoft\CbrfService\DataHelper;

/**
* DTO that represents response item from Bliquidity method.
*
* @psalm-immutable
*/
final class BliquidityRate implements CbrfEntityRate
{
private readonly \DateTimeInterface $date;

private readonly float $rate;

private readonly float $claims;

private readonly float $actionBasedRepoFX;

private readonly float $actionBasedSecureLoans;

private readonly float $standingFacilitiesRepoFX;

private readonly float $standingFacilitiesSecureLoans;

private readonly float $liabilities;

private readonly float $depositAuctionBased;

private readonly float $depositStandingFacilities;

private readonly float $CBRbonds;

private readonly float $netCBRclaims;

public function __construct(array $item)
{
$this->date = DataHelper::dateTime('DT', $item);
$this->rate = DataHelper::float('StrLiDef', $item, .0);
$this->claims = DataHelper::float('claims', $item, .0);
$this->actionBasedRepoFX = DataHelper::float('actionBasedRepoFX', $item, .0);
$this->actionBasedSecureLoans = DataHelper::float('actionBasedSecureLoans', $item, .0);
$this->standingFacilitiesRepoFX = DataHelper::float('standingFacilitiesRepoFX', $item, .0);
$this->standingFacilitiesSecureLoans = DataHelper::float('standingFacilitiesSecureLoans', $item, .0);
$this->liabilities = DataHelper::float('liabilities', $item, .0);
$this->depositAuctionBased = DataHelper::float('depositAuctionBased', $item, .0);
$this->depositStandingFacilities = DataHelper::float('depositStandingFacilities', $item, .0);
$this->CBRbonds = DataHelper::float('CBRbonds', $item, .0);
$this->netCBRclaims = DataHelper::float('netCBRclaims', $item, .0);
}

public function getDate(): \DateTimeInterface
{
return $this->date;
}

public function getRate(): float
{
return $this->rate;
}

public function getClaims(): float
{
return $this->claims;
}

public function getActionBasedRepoFX(): float
{
return $this->actionBasedRepoFX;
}

public function getActionBasedSecureLoans(): float
{
return $this->actionBasedSecureLoans;
}

public function getStandingFacilitiesRepoFX(): float
{
return $this->standingFacilitiesRepoFX;
}

public function getStandingFacilitiesSecureLoans(): float
{
return $this->standingFacilitiesSecureLoans;
}

public function getLiabilities(): float
{
return $this->liabilities;
}

public function getDepositAuctionBased(): float
{
return $this->depositAuctionBased;
}

public function getDepositStandingFacilities(): float
{
return $this->depositStandingFacilities;
}

public function getCBRbonds(): float
{
return $this->CBRbonds;
}

public function getNetCBRclaims(): float
{
return $this->netCBRclaims;
}
}
Loading

0 comments on commit f668b56

Please sign in to comment.