Code Monkey home page Code Monkey logo

Comments (14)

KonishchevDmitry avatar KonishchevDmitry commented on May 27, 2024 1

@ranisalt, I've supported your specific case in 2.10.2.

from investments.

KonishchevDmitry avatar KonishchevDmitry commented on May 27, 2024

Да - реверсы и сложные дроби я пока не поддерживаю. Пока что не было примеров, да и сложнее они:

  • Часть акций конвертируется в деньги, и это потом надо как-то мапить на FIFO
  • Если будет split -> reverse -> split -> reverse - то там получаются какие-то совсем унылые дроби, которые все усложняют еще больше.

Пришлите мне, пожалуйста, свои отчеты на [email protected] (можно обезличить перед отправкой) - по предоставленной вами ссылке я смогу понять только что произошло, а как оно в итоге отобразится в отчетах (в разных местах) - можно только гадать. Там местами бывают сюрпризы, которых совсем не ждешь.

from investments.

titov-vv avatar titov-vv commented on May 27, 2024

@antonrubtsov, если не лень, можете попробовать мой JAL, сплиты тестировали, но у меня не очень много обратной связи по ним было.

from investments.

KonishchevDmitry avatar KonishchevDmitry commented on May 27, 2024

Спасибо, получил ваш отчет.

Да уж... Сначала поделили имеющееся количество акций - получили бесконечную дробь. Округлили ее до 4 знака после запятой, а затем продали дробную часть. Нет бы сначала продать лишнее, а потом уже спокойно делить. :) Да еще и 3 трейда вместо одного: -N, +N, -N.

Ладно, чтож - буду думать, как это все лучше всего обрабатывать.

from investments.

antonrubtsov avatar antonrubtsov commented on May 27, 2024

@antonrubtsov, если не лень, можете попробовать мой JAL, сплиты тестировали, но у меня не очень много обратной связи по ним было.

Попробую обязательно.

from investments.

ranisalt avatar ranisalt commented on May 27, 2024

I'm having the same issue with this split:

SLG(US78440X1019) Split 100000 for 102918 (SLG, SL GREEN REALTY CORP, US78440X8048)

from investments.

KonishchevDmitry avatar KonishchevDmitry commented on May 27, 2024

Yep, I'm already on it. It's the next feature I'm planning to implement, but I'll need some time.

from investments.

ranisalt avatar ranisalt commented on May 27, 2024

Yep, I'm already on it. It's the next feature I'm planning to implement, but I'll need some time.

Great! Let me know if I can help 👍

from investments.

KonishchevDmitry avatar KonishchevDmitry commented on May 27, 2024

@antonrubtsov, добавил поддержку в 2.10.0. Не знаю уж, насколько оно готово будет переварить другие сплиты, но постарался сделать достаточно универсальным. Как минимум, ваш отчет теперь обрабатывается без проблем.

Правда, технические сделки от IB, о которых я писал выше, сейчас рассчитываются немного не в том порядке, в каком стоило бы по FIFO, но в вашем случае это ни на что не влияет - все равно копейки/убытки. Это связано с тем, что я пока храню времена сделок датами, а не с точностью до минут. Сделаю уже тогда это отдельным изменением, и проблема должна будет уйти.

from investments.

ranisalt avatar ranisalt commented on May 27, 2024

@KonishchevDmitry hey, neat work there. I am still having a problem with the SLG split, I get this error:

Failed to parse ("Corporate Actions", "Data", "Stocks", "USD", "2021-01-21", "2021-01-20, 20:25:00", "SLG(US78440X1019) Split 100000 for 102918 (SLG.OLD, SL GREEN REALTY CORP, US78440X1019)", "-7", "0", "0", "0", "") record: Unsupported corporate action: "SLG(US78440X1019) Split 100000 for 102918 (SLG.OLD, SL GREEN REALTY CORP, US78440X1019)".

That said, this error occurs when I run investments sync ib, but not when I run investments rebalance ib, which outputs outdated values.

from investments.

KonishchevDmitry avatar KonishchevDmitry commented on May 27, 2024

Does beed376 (released as 2.10.1) help? Do you know why it's named as SLG.OLD in the corporate action? Does it appear somewhere else as SLG.OLD?

from investments.

ranisalt avatar ranisalt commented on May 27, 2024

Does beed376 (released as 2.10.1) help?

It changes the error message, but still errors: Unsupported stock split: SLG at 20.01.2021.

Do you know why it's named as SLG.OLD in the corporate action?

I have no idea, but I noticed that my stock for SLG was renamed to SLG.OLD, then it was added to the statement as if I have sold all my shares of SLG.OLD and bought SLG immediately:

Corporate Actions,Data,Stocks,USD,2021-01-21,"2021-01-20, 20:25:00","SLG(US78440X1019) Split 100000 for 102918 (SLG, SL GREEN REALTY CORP, US78440X8048)",6.8015,0,0,0,
Corporate Actions,Data,Stocks,USD,2021-01-21,"2021-01-20, 20:25:00","SLG(US78440X1019) Split 100000 for 102918 (SLG.OLD, SL GREEN REALTY CORP, US78440X1019)",-7,0,0,0,

I don't understand what happened very well, it was a split where I could choose whether to receive the value in stocks or in cash, and I chose to receive it in cash.

These are all the entries mentioning SLG in my statement:

Mark-to-Market Performance Summary,Data,Stocks,SLG,0,6,--,72.4400,56.52,0,0,2.54,59.06,
Mark-to-Market Performance Summary,Data,Stocks,SLG,7,0,59.5800,--,11.57053,0,0,13.14,24.71053,
Realized & Unrealized Performance Summary,Data,Stocks,SLG,0,13.1649394,0,0,0,13.1649394,147.495892,0,0,0,147.495892,160.6608314,
Open Positions,Data,Summary,Stocks,USD,SLG,6,1,47.8573515,287.144109,72.44,434.64,147.495892,
Trades,Data,Order,Stocks,USD,SLG,"2021-01-20, 20:25:00",-0.8015,63.8915,63.02,51.20903725,0,-51.20903725,0,0.6985,O
Trades,Data,Order,Stocks,USD,SLG,"2021-01-20, 20:25:00",0.8015,63.8915,62.85,-51.20903725,0,51.20903725,0,-0.8348,Ca
Trades,Data,Order,Stocks,USD,SLG,"2021-01-20, 20:25:00",-0.8015,63.02,62.85,50.51053,0,-37.345591,13.164939,0.1363,C
Trades,SubTotal,,Stocks,USD,SLG,,-0.8015,,,50.51053,0,-37.345591,13.164939,0,
Corporate Actions,Data,Stocks,USD,2021-01-21,"2021-01-20, 20:25:00","SLG(US78440X1019) Split 100000 for 102918 (SLG, SL GREEN REALTY CORP, US78440X8048)",6.8015,0,0,0,
Corporate Actions,Data,Stocks,USD,2021-01-21,"2021-01-20, 20:25:00","SLG(US78440X1019) Split 100000 for 102918 (SLG.OLD, SL GREEN REALTY CORP, US78440X1019)",-7,0,0,0,
Dividends,Data,USD,2021-01-15,"SLG (US78440X1019) Cash Dividend USD 0.373572, STOCK DIVIDEND US78440X1019 279695099 FOR 10000000000 (Ordinary Dividend)",14
Dividends,Data,USD,2021-02-16,SLG(US78440X8048) Cash Dividend USD 0.3033 per Share (Ordinary Dividend),1.82
Dividends,Data,USD,2021-03-15,SLG(US78440X8048) Cash Dividend USD 0.3033 per Share (Ordinary Dividend),1.82
Withholding Tax,Data,USD,2020-09-15,SLG(US78440X1019) Cash Dividend USD 0.295 per Share - US Tax,0.62,
Withholding Tax,Data,USD,2020-09-15,SLG(US78440X1019) Cash Dividend USD 0.295 per Share - US Tax,-0.23,
Withholding Tax,Data,USD,2020-10-15,SLG(US78440X1019) Cash Dividend USD 0.295 per Share - US Tax,0.62,
Withholding Tax,Data,USD,2020-10-15,SLG(US78440X1019) Cash Dividend USD 0.295 per Share - US Tax,-0.23,
Withholding Tax,Data,USD,2020-11-16,SLG(US78440X1019) Cash Dividend USD 0.295 per Share - US Tax,0.62,
Withholding Tax,Data,USD,2020-11-16,SLG(US78440X1019) Cash Dividend USD 0.295 per Share - US Tax,-0.23,
Withholding Tax,Data,USD,2020-12-15,SLG(US78440X1019) Cash Dividend USD 0.295 per Share - US Tax,0.62,
Withholding Tax,Data,USD,2020-12-15,SLG(US78440X1019) Cash Dividend USD 0.295 per Share - US Tax,-0.23,
Withholding Tax,Data,USD,2021-01-15,"SLG (US78440X1019) Cash Dividend USD 0.373572, STOCK DIVIDEND US78440X1019 279695099 FOR 10000000000 - US Tax",-4.2,
Withholding Tax,Data,USD,2021-01-15,"SLG (US78440X1019) Cash Dividend USD 0.373572, STOCK DIVIDEND US78440X1019 279695099 FOR 10000000000 - US Tax",4.2,
Withholding Tax,Data,USD,2021-01-15,"SLG (US78440X1019) Cash Dividend USD 0.373572, STOCK DIVIDEND US78440X1019 279695099 FOR 10000000000 - US Tax",-2.42,
Withholding Tax,Data,USD,2021-02-16,SLG(US78440X8048) Cash Dividend USD 0.3033 per Share - US Tax,-0.55,
Withholding Tax,Data,USD,2021-03-15,SLG(US78440X8048) Cash Dividend USD 0.3033 per Share - US Tax,-0.55,
Change in Dividend Accruals,Data,Stocks,USD,SLG,2021-01-15,2020-12-14,2021-01-15,7,-4.2,0,2,-14,-9.8,Re
Change in Dividend Accruals,Data,Stocks,USD,SLG,2021-01-27,2021-01-28,2021-02-16,6,0.54,0,0.3033,1.82,1.28,Po
Change in Dividend Accruals,Data,Stocks,USD,SLG,2021-01-27,2021-01-28,2021-02-16,6,0.55,0,0.3033,1.82,1.27,Po
Change in Dividend Accruals,Data,Stocks,USD,SLG,2021-01-27,2021-01-28,2021-02-16,6,-0.54,0,0.3033,-1.82,-1.28,Re
Change in Dividend Accruals,Data,Stocks,USD,SLG,2021-02-16,2021-01-28,2021-02-16,6,-0.55,0,0.3033,-1.82,-1.27,Re
Change in Dividend Accruals,Data,Stocks,USD,SLG,2021-02-24,2021-02-25,2021-03-15,6,0.55,0,0.3033,1.82,1.27,Po
Change in Dividend Accruals,Data,Stocks,USD,SLG,2021-03-15,2021-02-25,2021-03-15,6,-0.55,0,0.3033,-1.82,-1.27,Re
Change in Dividend Accruals,Data,Stocks,USD,SLG,2021-03-29,2021-03-30,2021-04-15,6,0.54,0,0.3033,1.82,1.28,Po
Change in Dividend Accruals,Data,Stocks,USD,SLG,2021-03-29,2021-03-30,2021-04-15,6,0.55,0,0.3033,1.82,1.27,Po
Change in Dividend Accruals,Data,Stocks,USD,SLG,2021-03-29,2021-03-30,2021-04-15,6,-0.54,0,0.3033,-1.82,-1.28,Re
Financial Instrument Information,Data,Stocks,SLG,SL GREEN REALTY CORP,464964527,US78440X8048,NYSE,1,REIT,
Financial Instrument Information,Data,Stocks,SLG.OLD,SL GREEN REALTY CORP,6608473,US78440X1019,NYSE,1,REIT,

If you need, I can send my full statement file for your analysis 😄

from investments.

KonishchevDmitry avatar KonishchevDmitry commented on May 27, 2024

Mmm... It looks like you provided only entries for 2021 year - I don't see initial buy operation. It was 7 shares?

Yet another thing which confuses me:

Dividends,Data,USD,2021-01-15,"SLG (US78440X1019) Cash Dividend USD 0.373572, STOCK DIVIDEND US78440X1019 279695099 FOR 10000000000 (Ordinary Dividend)",14

- it's actually not supported yet (stock dividends) (#27), but may be due to a small number of shares you own, you have received nothing, and that's the reason why it may work now.

So, when I added the following fake trade:

Trades,Data,Order,Stocks,USD,SLG,"2021-01-02, 20:25:00",7,63.8915,63.02,-447.2405,0,51.20903725,0,0.6985,O

and changed the order of lines from

Corporate Actions,Data,Stocks,USD,2021-01-21,"2021-01-20, 20:25:00","SLG(US78440X1019) Split 100000 for 102918 (SLG, SL GREEN REALTY CORP, US78440X8048)",6.8015,0,0,0,
Corporate Actions,Data,Stocks,USD,2021-01-21,"2021-01-20, 20:25:00","SLG(US78440X1019) Split 100000 for 102918 (SLG.OLD, SL GREEN REALTY CORP, US78440X1019)",-7,0,0,0,

to

Corporate Actions,Data,Stocks,USD,2021-01-21,"2021-01-20, 20:25:00","SLG(US78440X1019) Split 100000 for 102918 (SLG.OLD, SL GREEN REALTY CORP, US78440X1019)",-7,0,0,0,
Corporate Actions,Data,Stocks,USD,2021-01-21,"2021-01-20, 20:25:00","SLG(US78440X1019) Split 100000 for 102918 (SLG, SL GREEN REALTY CORP, US78440X8048)",6.8015,0,0,0,

it started to work for my fake statement I've created. May be it'll help you too if my assumptions are correct. :)

If you can send me the full statements ([email protected], you can strip all personal information like your name and account number from them) it will be great. It always significantly increases chances that I will find a free time to support the issue (I always prioritize issues with real statements), that I won't break it in the future (I write regression tests for) and gives me the chance to check all your statement - that the result of all of my calculations matches with real data with zero cent precision.

from investments.

ranisalt avatar ranisalt commented on May 27, 2024

Mmm... It looks like you provided only entries for 2021 year - I don't see initial buy operation. It was 7 shares?

I bought those shares in 2020, and I have one activity statement for 2020 (until 31/12) and one for 2021 (from 01/01). If I should export an activity statement from the very beginning instead, then that might be it 😛

The activity for 2020 regarding SLG is:

``` Mark-to-Market Performance Summary,Data,Stocks,SLG,0,7,--,59.5800,91.88,3.15,-2.4597,5.8,98.3703, Realized & Unrealized Performance Summary,Data,Stocks,SLG,0,0,0,0,0,0,92.5703,0,0,0,92.5703,92.5703, Month & Year to Date Performance Summary,Data,Stocks,SLG,SL GREEN REALTY CORP,13.21,98.3703,0,0,0,0 Open Positions,Data,Summary,Stocks,USD,SLG,7,1,46.355671429,324.4897,59.58,417.06,92.5703, Trades,Data,Order,Stocks,USD,SLG,"2020-08-03, 10:28:41",3,44.94,45.91,-134.82,-1,135.82,0,2.91,O Trades,Data,Order,Stocks,USD,SLG,"2020-08-03, 11:23:08",1,45.88,45.91,-45.88,-0.4597,46.3397,0,0.03,O Trades,Data,Order,Stocks,USD,SLG,"2020-08-05, 13:39:23",3,47.11,47.18,-141.33,-1,142.33,0,0.21,O Trades,SubTotal,,Stocks,USD,SLG,,7,,,-322.03,-2.4597,324.4897,0,3.15, Dividends,Data,USD,2020-09-15,SLG(US78440X1019) Cash Dividend USD 0.295 per Share (Ordinary Dividend),2.07 Dividends,Data,USD,2020-10-15,SLG(US78440X1019) Cash Dividend USD 0.295 per Share (Ordinary Dividend),2.07 Dividends,Data,USD,2020-11-16,SLG(US78440X1019) Cash Dividend USD 0.295 per Share (Ordinary Dividend),2.07 Dividends,Data,USD,2020-12-15,SLG(US78440X1019) Cash Dividend USD 0.295 per Share (Ordinary Dividend),2.07 Withholding Tax,Data,USD,2020-09-15,SLG(US78440X1019) Cash Dividend USD 0.295 per Share - US Tax,-0.62, Withholding Tax,Data,USD,2020-10-15,SLG(US78440X1019) Cash Dividend USD 0.295 per Share - US Tax,-0.62, Withholding Tax,Data,USD,2020-11-16,SLG(US78440X1019) Cash Dividend USD 0.295 per Share - US Tax,-0.62, Withholding Tax,Data,USD,2020-12-15,SLG(US78440X1019) Cash Dividend USD 0.295 per Share - US Tax,-0.62, Change in Dividend Accruals,Data,Stocks,USD,SLG,2020-08-27,2020-08-28,2020-09-15,7,0.62,0,0.295,2.07,1.45,Po Change in Dividend Accruals,Data,Stocks,USD,SLG,2020-09-15,2020-08-28,2020-09-15,7,-0.62,0,0.295,-2.07,-1.45,Re Change in Dividend Accruals,Data,Stocks,USD,SLG,2020-09-28,2020-09-29,2020-10-15,7,0.62,0,0.295,2.07,1.45,Po Change in Dividend Accruals,Data,Stocks,USD,SLG,2020-10-15,2020-09-29,2020-10-15,7,-0.62,0,0.295,-2.07,-1.45,Re Change in Dividend Accruals,Data,Stocks,USD,SLG,2020-10-28,2020-10-29,2020-11-16,7,0.62,0,0.295,2.07,1.45,Po Change in Dividend Accruals,Data,Stocks,USD,SLG,2020-11-16,2020-10-29,2020-11-16,7,-0.62,0,0.295,-2.07,-1.45,Re Change in Dividend Accruals,Data,Stocks,USD,SLG,2020-11-26,2020-11-27,2020-12-15,7,0.62,0,0.295,2.07,1.45,Po Change in Dividend Accruals,Data,Stocks,USD,SLG,2020-12-11,2020-12-14,2021-01-15,7,0.64,0,0.3033,2.12,1.48,Po Change in Dividend Accruals,Data,Stocks,USD,SLG,2020-12-11,2020-12-14,2021-01-15,7,3.56,0,1.6967,11.88,8.32,Po Change in Dividend Accruals,Data,Stocks,USD,SLG,2020-12-11,2020-12-14,2021-01-15,7,4.2,0,2,14,9.8,Po Change in Dividend Accruals,Data,Stocks,USD,SLG,2020-12-11,2020-12-14,2021-01-15,7,-3.56,0,2,-11.88,-8.32,Re Change in Dividend Accruals,Data,Stocks,USD,SLG,2020-12-11,2020-12-14,2021-01-15,7,-0.64,0,0.3033,-2.12,-1.48,Re Change in Dividend Accruals,Data,Stocks,USD,SLG,2020-12-15,2020-11-27,2020-12-15,7,-0.62,0,0.295,-2.07,-1.45,Re Financial Instrument Information,Data,Stocks,SLG,SL GREEN REALTY CORP,6608473,US78440X1019,1,REIT, ```
So I can see in the trades I bought 3 + 1 + 3

Edit: swapping the splits as you suggested has worked.

from investments.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.