anthonyk1225 / robinhood-to-xlsx

Python package that grabs your robinhood data and exports it to excel
MIT License
15 stars 3 forks source link

Incorrect amount of shares held #12

Closed kfchou closed 4 years ago

kfchou commented 4 years ago

In the P/L calculation, number of shares held does not correctly reflect the number of shares I hold in my RH account.

anthonyk1225 commented 4 years ago

Hey, try pulling your latest history and then generating the xlsx file for orders again. Is it still inaccurate?

If it is, can you tell me if these were shares you straight up bought/sold or if they came from an event like getting assigned from a call, etc.

kfchou commented 4 years ago

Hey @anthonyk1225, the shares held are still inaccurate. All shares are bought/sold (I haven't traded any call/puts/options/etc).

If I performe the calculation =IF([@side]="buy",[@quantity],-[@quantity]) on the orders table, and calculated the sum of that result for a particular stock, that summation should give me the shares owned. This is the case for some stocks and not the case for some others. That same summation should be consistent with the number of shares owned on the P/L table, but it isn't. Hopefully this information helps with debugging...

anthonyk1225 commented 4 years ago

Hmm, the only thing I can think of is there are buy/sell orders missing from your history. This happened for me in my options history where I had a SPY leg missing which caused it to show that I had 1 leg open when I actually had 0.

If you could, check your history on the first tab for a ticker that is incorrect. See if you tally up the buys and sells, it reflects correctly in your RH account. If it does then I'll keep looking, otherwise the wrong tally has to do with RH omitting a trade from your history.

kfchou commented 4 years ago

Well, I think there are two issues.

First, tallying the history in the first tab for each stock produces a total number of shares held that is inconsistent with what is shown in the P/L table.

Second, the tallying the history in the first tab still produces incorrect number of shares held of some stocks (but fewer incorrect numbers than the P/L table). In this case, something might be missing from the RH history.

anthonyk1225 commented 4 years ago

Alright, thanks for that information. It's really annoying that this is happening. I actually messaged RH about the missing leg in my options history and they are content with it being omitted, so now I have to create an avenue to add rows that are missing from a user's history to make up for this.

If you want to email me your rows of just one company where they add up on the first tab, but don't tally up correctly for the P/L tab, I can write some tests and try to see what the bug or error is. Unfortunately, my order history all adds up. I would just need the price and quantity for them, nothing else. All good if that's too much to ask for.

kfchou commented 4 years ago

Nice, a new update to ring in 2020! Hope you enjoyed the holidays @anthonyk1225.

In the latest update, I got this error after selecting the xlsx option when running app.py:

Had trouble writing an item to the cell object of type 'NoneType' has no len() Traceback (most recent call last): File "app.py", line 48, in <module> run() File "app.py", line 41, in run json_to_xlsx.run(answer) File "robinhood-to-xlsx\controllers\json_to_xlsx.py", line 81, in run formula_pipelines[entity](formula_worksheet, workbook, sorted_data) File "robinhood-to-xlsx\formulas\orders.py", line 112, in handle_formulas write_aggregates(worksheet, workbook, data) File "robinhood-to-xlsx\formulas\orders.py", line 104, in write_aggregates totals = get_company_totals(v) File "robinhood-to-xlsx\formulas\orders.py", line 39, in get_company_totals average_sell_price = sell_equity / sell_quantity ZeroDivisionError: division by zero

Thanks!

anthonyk1225 commented 4 years ago

What a legend. Fixed this. If there are any other issues, lets start a fresh one.