Skip to content

Commit 406929c

Browse files
committed
Fix of expected coupons sum in bonds table + filter bonds that can be
bought + emitters updated
1 parent 05c722e commit 406929c

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

emitters.bin

208 Bytes
Binary file not shown.

src/main/java/ru/shemplo/tbs/TBSBondManager.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,11 @@ public void initialize (IProfile profile, TBSLogWrapper log) {
165165
try {
166166
log.info ("Loading data about bonds from Tinkoff and MOEX...");
167167
scanned = client.getInstrumentsService ().getAllBondsSync ().stream ()
168-
. filter (instrument -> profile.getCurrencies ().contains (Currency.from (instrument.getCurrency ()))).parallel ()
168+
. filter (instrument ->
169+
instrument.getApiTradeAvailableFlag ()
170+
&& instrument.getBuyAvailableFlag ()
171+
&& profile.getCurrencies ().contains (Currency.from (instrument.getCurrency ()))
172+
).parallel ()
169173
. map (instr -> new Bond (profile, instr, false)).peek (bond -> emitters.addEmitter (bond.getEmitterId (), bond.getCode ()))
170174
. filter (profile::testBond)//.limit (profile.getMaxResults ())
171175
. collect (Collectors.toList ());

src/main/java/ru/shemplo/tbs/entity/Bond.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,10 @@ public void updateScore (IProfile profile) {
212212
final var days = now.until (end, ChronoUnit.DAYS);
213213

214214
reliableCoupons = coupons.stream ().map (Coupon::isReliable).reduce (Boolean::logicalAnd).orElse (true);
215-
couponsCredit = coupons.stream ().mapToDouble (c -> c.getCredit (profile, now, end)).sum ();
215+
couponsCredit = coupons.stream ()
216+
. filter (c -> !now.isAfter (TBSUtils.aOrB (c.getRecord (), c.getDate ()))) // consider only coupons that can be payed after now
217+
. mapToDouble (c -> c.getCredit (profile, now, end))
218+
. sum ();
216219

217220
final var inflationFactor = Math.pow (1 + profile.getInflation (), days / 365.0);
218221
nominalValueWithInflation = nominalValue / inflationFactor;

0 commit comments

Comments
 (0)