Python Forum
Thread Rating:
  • 2 Vote(s) - 3.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Financial Modeling
#1
I'm just getting started learning Python, and attempting to apply it in a work problem: developing an asset reinvestment model parallel to a production model, for validation purposes. I ordinarily do this sort of work in Excel, but there are two reasons I'm trying this on Python: (1) it's difficult to dynamically add assets within Excel, and (2) it's an excuse to practice Python syntax which I'm hoping to eventually apply to more complex problems.

The general problem at hand is that I need to develop a financial projection with multiple columns of portfolio information by month; i.e. columns are items like Interest Earned, Book Value, Default Amount; and rows are months (e.g. 0-600). At each time step, the program needs to evaluate the free cash available in the portfolio and purchase new assets. The next month, it evaluates across all the assets to determine how much cash is available, purchases new assets, and on to the next month.

My first thought was to do the work with Pandas DataFrames, which a familiarly Excel-like and easily export to CSV or Excel for later evaluation. However, iterating rows by looping through DataFrames is apparently a big no-no and I don't see how to do this project without looping from time=0 to end; I need to evaluate across columns and assets, and create new assets, after each month. I'm also not sure how to create and track purchased assets; I thought maybe somehow by creating variables while listing the variable names in a dictionary or series, but I could use some kind of example to cheat from.

I apologize for such a general question, but I'm having trouble finding or Googling a relevant helpful example in this case. Mostly I'm finding examples that are too simple to scale up (like amortization schedules with cute closed-form solutions), or financial problems like machine learning optimizations that are unrelated. I have a bunch of Python reference materials, but I don't know the name of the concepts I need to learn. Thank you in advance for any help you can provide in pointing me toward the right direction(s).
Reply
#2
It seems to me that I dealt with the similar issue recently (and I started to learn Python 9 months ago).

My challenge was to develop a script for financial modeling of investment prospects in O&G industry. Unfortunately, the details are under copyright, although I could share the approach.

Below are the major parts of the solution:
1. To present the results for the stakeholders a jupyter notebook was chosen.
2. All the initial assumptions and parameters were gathered in the libraries (fiscal regime, production sharing agreement, etc.)
3. Separate class to initiate prospect environment and get up-to-date inflation, exchange rates and etc. from external sources and via API.
4. Class to input time and cost data from excel and ms project files.
5. Class to calculate a model (actually, it's chunked and aligned with previous excel model) and generate reports on calculated parameters.
6. Separate inherited class for sensitivity analysis.
7. Class for gathering several prospects in the portfolio.

After completion of refactoring, it would be possible to create a package of the resulting scripts for the further corporate usage.

Hope it helps somehow...
Reply
#3
Please find an example of implementation here: https://github.com/MikhailShi/psa-financial-model
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Filling NaNs in a financial dataset larzz 11 1,888 Jun-07-2023, 03:40 PM
Last Post: snippsat
  how to extract financial data from photocopy of document angela1 6 3,608 Feb-15-2020, 05:50 PM
Last Post: jim2007
  Google Financial Client ian 7 6,298 Sep-21-2017, 07:23 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020