I am working on developing a framework for optimal time for loan buyback for profit maximization over customer lifetime in a p2p lending ecosystem. I have data about past loans and their paid and due dates. There is no late fee charge that the lender earns but they can buy back their original loan at no cost via the mediator after the due date. If they decide to buy back earlier than the due date there is a penalty fee. With this knowledge can you write a basic python pipeline that solves this as a bandit problem using river library that tells me as to on any given day since the loan has been disbursed whether I should buy back the loan or should I wait? Do note that there is an extra constraint of maximizing the profit over a set time period lets say a year. 