A few comments on your spreadsheet.

One approach to solving the problem with

Budget in column Y is to do the calculations in a separate column or even a separate sheet. For simplicity, I added formulas to column

AFCell AF2 use

=Y2Cell AF9 use

=W9+AF2Cell AF16 use

=W16+AF9Cell AF23 use

=W23+AF16Cell AF30 use

=W30+AF23etc.

Since W23 is 0, the results in AF16 and AF23 display the same value, allowing the ensuing calculations to display the correct values.

Then in column Y

Cell Y9 use =IF(INT(F9)-INT(Q9)=0;AF9;0)

Cell Y16 use =IF(INT(F16)-INT(Q16)=0;AF16;0)

Cell Y23 use =IF(INT(F23)-INT(Q23)=0;AF23;0)

Cell Y30 use =IF(INT(F30)-INT(Q30)=0;AF30;0)

etc

Mixing potential data types in a single cell can lead to problems, so in the Else clause I used the number 0 instead of an empty text string "" when there are unsold shares.

As far as .

Must be possible to easy and quick add a line, keeping all formulas

You could try a recorded macro.

But in reality what you have is a database. While simple databases can be implemented using a spreadsheet, yours may be a little too complex for a spreadsheet.

For instance

must be possible to easy and quick add a line, keeping all formulas

with a database the buy/sell transactions could be displayed in a table control on a form. Table controls can have a navigation bar and scroll bars so if there are more transactions than will fit in the display box the scroll bar will allow them all to be accessed.

This line has a conditional format and turns Yellow, to establish an 'End of Day

would be unnecessary using a database, you could step through the transactions on a form one day at a time.

If your problem has been solved, please edit this topic's initial post and add "[Solved]" to the beginning of the subject line

Apache OpenOffice 4.1.6 & LibreOffice 6.1.5.2 - Windows 10 Professional