1dirctn
1dirctn
31.03.2020 • 
Mathematics

You expect the price of a commodity to behave as follows over the next 12 months:

Month 1 2 3 4 5 6 7 8 9 10 11 12

Price ($/unit) 142 100 58 55 95 140 147 110 64 52 85 133

Your inventory capacity is 25 units and you have 3 units in inventory at the start of month 1. In any given month, you can buy up to 10 units or sell up to 15 units. The prices per unit sold or bought are the same within each month, but every transaction, whether you buy or sell, is subject to a $120 transaction charge (the only way to avoid this charge in a given month is by neither Page 2 of 2 buying for selling that month). Your holding cost is $15 per unit per month, assessed on the inventory at the end of each month. Any units of the commodity left over after month 12 are assessed a $70 per unit salvage value. Create a Python program to maximize your profits trading the commodity over the next 12 months.

import numpy hugeNumber = float("inf") unused = -1e10 stages = 12 inventoryCapacity = 25 maxBuy = 10 maxSell = 15 startingInventory = 3 holdingCost = 15.00 salvageValue = 70.00 transactionCost = 120.00 price = numpy.array([unused, 142, 100, 58, 55, 95, 140, 147, 110, 64, 52, 85, 133])

Solved
Show answers

Ask an AI advisor a question