In this study, we consider a company that uses two channels for trading: long‐term contracts and spot markets. With a quantity flexibility long‐term contract, the buyer commits to purchasing at least as much as the minimum order quantity and is able to reserve capacity with the forward contract supplier up to the maximum order quantity in each period at a predetermined price. Through the spot market, the buyer can order or sell inventory at an uncertain future spot price without quantity limitations. A fixed setup cost is incurred in each instance of buying or selling in the spot market. This study considers very general inventory‐related (not necessarily convex) costs, and demand is random following a one‐sided Pólya distribution. We introduce a concept called “non‐(K1, K2)‐decreasing with changeovers” and characterize the optimal trading policy in the spot market. We show that the optimal policy can be characterized by five critical points. We also characterize optimal procurement from the contracted supplier under certain conditions. Two simple, yet efficient, heuristics that yield near‐optimal results in many cases are presented as well in order to calculate procurement quantities. Moreover, we show that our results also apply to uniform demand, which is not Pólya, and numerical tests assuming uniform demand are performed to discern which factors are most important and to gain managerial insights.