10
10
use App \Investments \Domain \Operations \DealRepositoryInterface ;
11
11
use App \Investments \Infrastructure \Http \TInvestHttpClient ;
12
12
use Doctrine \ORM \EntityManagerInterface ;
13
+ use Metaseller \TinkoffInvestApi2 \exceptions \ValidateException ;
14
+ use Metaseller \TinkoffInvestApi2 \helpers \QuotationHelper ;
13
15
use Symfony \Component \Console \Attribute \AsCommand ;
14
16
use Symfony \Component \Console \Command \Command ;
15
17
use Symfony \Component \Console \Input \InputInterface ;
@@ -72,9 +74,9 @@ private function updateSharePrices(SymfonyStyle $io): void
72
74
continue ;
73
75
}
74
76
75
- $ price = sprintf ( ' %s.%s ' , $ item ->getPrice ()?->getUnits() ?? ' 0 ' , $ item -> getPrice ()?->getNano() ?? ' 0 ' );
77
+ $ price = QuotationHelper:: toDecimal ( $ item ->getPrice ());
76
78
if ($ price > 0 ) {
77
- $ share ->setPrice ($ price );
79
+ $ share ->setPrice (( string ) $ price );
78
80
$ this ->em ->persist ($ share );
79
81
}
80
82
$ io ->success (sprintf ('%s: %s - %s ' , $ share ->getStockMarket (), $ share ->getTicker (), $ share ->getPrice ()));
@@ -111,9 +113,9 @@ private function updateBondPrices(SymfonyStyle $io): void
111
113
continue ;
112
114
}
113
115
114
- $ price = sprintf ( ' %s.%s ' , $ item ->getPrice ()?->getUnits() ?? ' 0 ' , $ item -> getPrice ()?->getNano() ?? ' 0 ' );
116
+ $ price = QuotationHelper:: toDecimal ( $ item ->getPrice ());
115
117
if ($ price > 0 ) {
116
- $ bond ->setPrice ($ price );
118
+ $ bond ->setPrice (( string ) $ price );
117
119
$ this ->em ->persist ($ bond );
118
120
}
119
121
$ io ->success (sprintf ('%s: %s (%s) - %s ' , $ bond ->getStockMarket (), $ bond ->getName (), $ bond ->getTicker (), $ bond ->getPrice ()));
@@ -123,6 +125,9 @@ private function updateBondPrices(SymfonyStyle $io): void
123
125
$ io ->success ('Bond prices updated! ' );
124
126
}
125
127
128
+ /**
129
+ * @throws ValidateException
130
+ */
126
131
private function updateFuturePrices (SymfonyStyle $ io ): void
127
132
{
128
133
$ uids = [];
@@ -149,9 +154,9 @@ private function updateFuturePrices(SymfonyStyle $io): void
149
154
continue ;
150
155
}
151
156
152
- $ price = sprintf ( ' %s.%s ' , $ item ->getPrice ()?->getUnits() ?? ' 0 ' , $ item -> getPrice ()?->getNano() ?? ' 0 ' );
157
+ $ price = QuotationHelper:: toDecimal ( $ item ->getPrice ());
153
158
if ($ price > 0 ) {
154
- $ future ->setPrice ($ price );
159
+ $ future ->setPrice (( string ) $ price );
155
160
$ this ->em ->persist ($ future );
156
161
}
157
162
$ io ->success (sprintf ('%s: %s (%s) - %s ' , $ future ->getStockMarket (), $ future ->getName (), $ future ->getTicker (), $ future ->getPrice ()));
0 commit comments