From 406929c78cd710bbe2fabcb9c5c080c0eb8844bb Mon Sep 17 00:00:00 2001 From: Plotnikov Andrey Date: Fri, 16 Sep 2022 19:13:18 +0300 Subject: [PATCH] Fix of expected coupons sum in bonds table + filter bonds that can be bought + emitters updated --- emitters.bin | Bin 35612 -> 35820 bytes .../java/ru/shemplo/tbs/TBSBondManager.java | 6 +++++- src/main/java/ru/shemplo/tbs/entity/Bond.java | 5 ++++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/emitters.bin b/emitters.bin index 154031e49382f173377b8d0edeb117fdd5adc2e4..1a92d508ef9636757fd16ef72fc73d1d84985f64 100644 GIT binary patch delta 1756 zcmZvcdr(w$6vy}Oz3f6FNC+q*Eofk%a$oznY1%$u*JWLH?>=BJj0*GsA8C43CPzcb zA{z(gR5WB*Lr(7*^p_(dzQ**Qrs-~DS$|aan8~tfWHQVCsdKN@z)ZU{`}p18?|aVq zp3nImdeQvzfO(|a%S#@*ThZ3vd;mS*($EtYJuI+rnLC`#>0JIttDNS@D&)0RN3sG2&A0J93# zVMxy5u&bsROiZta69tzU&gFGMUtz++Dyal(ho1^Pv@gIyO;Md5JksQX9YtX)D|sZ< zBxCRg$n;saDND%5sip<6tEiBa7q^--*kDtz7J5sP44+W!@NLN|Y8|xtA`qNgjrm#s z{1~2?yC;iP6fVH4rgwEE@RSbGLfA>ZD=nlf&LAdM4inZwD6s8eL?JA|%eIr2NDw2f zF!m3WEurmP96l{`(@H8%W|v>U$V#d<3g66s8|{lr(06Y#YqoY+_r_KZ8!O5x(48Na zcWrsxw9AxfGG3YaswrDeuq^Aw8U@9rnkwOXu!MY4v6ylxiqwd%&G}bE8%}p?Bibo# z%=jGDPL}IhGY!SU?Wjp%h+BV<^$QxQvT0hs_MUcdvG%I=y1p%U$~LQ71l3i=v>*o| zP<10yNx2;k)l`oivV&Y*p<8vjpX{uzrX(&DWL4ALJC$gMv?JP}tz3ISJBI0;!GELL zxRJ=5sS&=|L|ltDAenB~32)Ve7}n!q;d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X0(0CIAshQr!r~dq;WR$rZHli%naBKY@9ZR$>JzORB-b%;Ano)lx!)V8Xp^{GkxS4uunI38Yhe$ zHO3)h2nN%|_My(chjG6ggDW~U=$vyspA0S_q%5?19WJVe0gyi7k?JV(G^BR_hLGmzOd3G(KaThq@CUA~Lw&Rs*Z0`d{v)`Z9u zWe)zT(Fo}Rc;{bZH6iT82rZ{fiRh{fySO8)*btH6DSkcU5oH+W-R5*1jf5e^R2H5i z%%+Kal0Lx&aVcRsK&dAV(81lZ7;+sWBp0W75nOV3m`2ToA9prWEFVA|UMsIBf^hiZ zsw-$E`-BA4wnSjtg1X#bEG%>PA?_^DY1`y`N*k=5X-(%%J$e;istr;MibnCIx>VL% z;Siy1C8??uK6Gz1E8)#a#*5v;8x5NB zbO)SU(anldjKlKEAIU8B#W1cl%JP!rz#XjiNVB}h$HOmc%{>kT&dvr#_HekrQzE}Yl#@U;2V~6#Q?j%)1xf-TfaCeJ5oA diff --git a/src/main/java/ru/shemplo/tbs/TBSBondManager.java b/src/main/java/ru/shemplo/tbs/TBSBondManager.java index ffdcc93..013d946 100644 --- a/src/main/java/ru/shemplo/tbs/TBSBondManager.java +++ b/src/main/java/ru/shemplo/tbs/TBSBondManager.java @@ -165,7 +165,11 @@ public void initialize (IProfile profile, TBSLogWrapper log) { try { log.info ("Loading data about bonds from Tinkoff and MOEX..."); scanned = client.getInstrumentsService ().getAllBondsSync ().stream () - . filter (instrument -> profile.getCurrencies ().contains (Currency.from (instrument.getCurrency ()))).parallel () + . filter (instrument -> + instrument.getApiTradeAvailableFlag () + && instrument.getBuyAvailableFlag () + && profile.getCurrencies ().contains (Currency.from (instrument.getCurrency ())) + ).parallel () . map (instr -> new Bond (profile, instr, false)).peek (bond -> emitters.addEmitter (bond.getEmitterId (), bond.getCode ())) . filter (profile::testBond)//.limit (profile.getMaxResults ()) . collect (Collectors.toList ()); diff --git a/src/main/java/ru/shemplo/tbs/entity/Bond.java b/src/main/java/ru/shemplo/tbs/entity/Bond.java index d2f3213..0aaa841 100644 --- a/src/main/java/ru/shemplo/tbs/entity/Bond.java +++ b/src/main/java/ru/shemplo/tbs/entity/Bond.java @@ -212,7 +212,10 @@ public void updateScore (IProfile profile) { final var days = now.until (end, ChronoUnit.DAYS); reliableCoupons = coupons.stream ().map (Coupon::isReliable).reduce (Boolean::logicalAnd).orElse (true); - couponsCredit = coupons.stream ().mapToDouble (c -> c.getCredit (profile, now, end)).sum (); + couponsCredit = coupons.stream () + . filter (c -> !now.isAfter (TBSUtils.aOrB (c.getRecord (), c.getDate ()))) // consider only coupons that can be payed after now + . mapToDouble (c -> c.getCredit (profile, now, end)) + . sum (); final var inflationFactor = Math.pow (1 + profile.getInflation (), days / 365.0); nominalValueWithInflation = nominalValue / inflationFactor;