I actively trade stocks and I am trying to manipulate a file in Python that will act as a way to check my current holdings.
Upon opening, it will read the contents of the file to see if I have any holdings. If I enter something, I will enter the ticker and append the file. How would I make it so that if I wanted to exit something, I can type the ticker and it would delete that string from the file?
Truncate won't work because if I have more than one position on, the entire file will be wiped. I have tried many people's suggestions on this topic but none have worked. Can anyone put forth an easy way to exit the holding in the file based upon my inputs? Thanks in advance!