Jul-08-2018, 08:25 PM
(This post was last modified: Jul-08-2018, 08:25 PM by MarkHaversham.)
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).
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).