Skip to content

Instantly share code, notes, and snippets.

@nsa-yoda
Created December 10, 2018 22:03
Show Gist options
  • Save nsa-yoda/46e16ba44e120565e4a211c6781b5f88 to your computer and use it in GitHub Desktop.
Save nsa-yoda/46e16ba44e120565e4a211c6781b5f88 to your computer and use it in GitHub Desktop.
OSRS "Scamming" calculator - for those "selling 13 trout" noob alts. Calculates your profit per batch of items.
from prettytable import PrettyTable
data = [{
'purchase_price': 26,
'amount_purchased': 20,
'amount_sold': 13,
'sold_for': 3000
},{
'purchase_price': 26,
'amount_purchased': 116,
'amount_sold': 26,
'sold_for': 30000
},{
'purchase_price': 26,
'amount_purchased': 116,
'amount_sold': 52,
'sold_for': 100000
}]
profit = 0
carryover_amount = 0
current_amount = 0
bank = 0
t = PrettyTable(['Inventory', 'Profit', 'Carryover', 'Bank'])
t.align["Inventory"] = "r"
t.align["Profit"] = "r"
t.align["Carryover"] = "r"
t.align["Bank"] = "r"
for d in data:
profit = (d['sold_for']) - (d['purchase_price'] * d['amount_purchased'])
bank = bank + profit
carryover_amount = (d['amount_purchased'] - d['amount_sold'])
current_amount = current_amount + carryover_amount
t.add_row(['{:,}'.format(current_amount),
'${:,.2f}'.format(profit),
'{:,}'.format(carryover_amount),
'${:,.2f}'.format(bank)])
print t
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment