agusalex / tax_calculator

Apache License 2.0
0 stars 1 forks source link

options handling (buy and sell // long and short) #5

Closed wusatiuk closed 6 months ago

wusatiuk commented 6 months ago

from input file: AssetClass in input-file is "OPT" options = df[(df['LevelOfDetail'] == 'EXECUTION') & (df['AssetClass'] == 'OPT')].copy()

options should be calculated in the same way as stocks, when it comes to calculating "Accumulated_Securities" and "Avg_Moving_Price". The only thing with options is, that there is a multiplier on the price.

my example: I sold (shorted) 2x VIPS Put Options and received "370.00 USD". explanation: I received USD 370 from somebody to give him/her the option to sell to me 200 stocks of VIP until the 20th of Jan 2023 for the price of 8.00 USD (you can think of it like an insurance premium which the option seller is receiving)

trade date: 2021-12-17 settle date: 2021-12-20 symbol: VIPS 230120P00008000 multiplier: 100 strike: 8 expiry: 2023-01-20 price: 1.85 x 100 (multiplier) = 185 quantity: -2

I then bough back the 2 put options and had to pay 480.00 USD trade date: 2021-12-30 settle date: 2021-12-31 symbol, multiplier, strike, expiry = identical (= always identical, if symbol is identical) price: 2.40 x 100 (multiplier) = -480 quantity: 2

so in this case i have a deficits of "-110.00" with this symbol at the end of year and no position left open.

agusalex commented 6 months ago

Checkout this example, its converting it to EUR https://github.com/agusalex/tax_calculator/blob/main/output/VIPS-230120P00008000_table.csv I think it works properly now 😄

agusalex commented 6 months ago

Verified by setting FxCurrency conversion manually to usd and the total taxable amount ends up being -110