Skip to content

Instantly share code, notes, and snippets.

@NewProggie
Created December 4, 2020 08:20
Show Gist options
  • Save NewProggie/fe93f94a24bae6135c892754d0a25382 to your computer and use it in GitHub Desktop.
Save NewProggie/fe93f94a24bae6135c892754d0a25382 to your computer and use it in GitHub Desktop.
# Copyright (c) 2020, Kai Wolf. All rights reserved.
from argparse import ArgumentParser
capital_gains_tax = 0.26375
def calculate_profit(quantity, buy_price, sell_price):
gain = quantity * sell_price - quantity * buy_price
fees = min(69.9, 4.9 + sell_price * 0.25) # ING-DiBBa order provision
taxes = (gain - fees) * capital_gains_tax
return gain - fees - taxes # profit
if __name__ == "__main__":
parser = ArgumentParser(description='stock profit calculator')
parser.add_argument('-b', '--buy_price', type=float, help="Buy price", required=True)
parser.add_argument('-s', '--sell_price', type=float, help="Sell price", required=True)
parser.add_argument('-q', '--quantity', type=int, help="Number of stocks", required=True)
args = parser.parse_args()
print(calculate_profit(args.quantity, args.buy_price, args.sell_price))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment