Skip to main content
留学咨询

辅导案例-FM5092

By May 15, 2020No Comments

5092.12 Final project design & what comes next FM5092 Chris Prouty University of Minnesota A g e n d a • Your exotics projects should now be handed in • Two weeks from now is a review session for the final exam (next week no class) • The final exam is the following week • Today we will design elements of your final project, which is due the night before the final • We will also discuss what comes next? • If you liked the content of this class and want to write more code, there are many different directions you may proceed • I’ll try to highlight several of the most interesting (to me) P o r t f o l i o m a n a g e m e n t p r o j e c t • We need to delineate the tasks ahead of us, because they are many – Design the data model in Entity – Generate an SQL database from our Entity model – Create an GUI app that permits the user to curate elements of the Entity model • This has many, many sub-elements – Connect the GUI app to our Monte Carlo simulator – Make the GUI app able to take all the individual elements of a “trade on the books” and hand it off to the simulator – Once a product has been priced, sum all the values to create a portfolio value P o r t f o l i o m a n a g e m e n t p r o j e c t • I suspect that this will be your most ambitious project, so, as always, don’t dawdle • Step 1: Design the data model • Recall this slide from a previous lecture P o r t f o l i o m a n a g e m e n t p r o j e c t • We need to take that model and design it in Entity as part of our project The fields shown in the entities are taken from the model we derived in a previous lecture The relationships among the entities is crucially important to get correct – note carefully the different types present here Please review the numerous pieces of commentary on TPT vs TPH and various ways to structure the problem of modeling an Instrument. P o r t f o l i o m a n a g e m e n t p r o j e c t • There is a 1 -> many relationship between: – Instrument and Trade – Instrument and Historical Price – Instrument and InstType (if using a TPH approach) • InterestRate lives on its own • Generating the Entity model presents many opportunities for mistakes • Especially after the SQL database is generated, making changes will be laborious • If you find a mistake after your database is generated, you will probably need to delete the SQL database and start over…  P o r t f o l i o m a n a g e m e n t p r o j e c t • This data model is incomplete for our purposes • The fields currently defined cover European, Asian, Range, and Lookback options • Digital options require a rebate scalar field • Barrier options require a barrier field and some type of barrier type entity • The barrier type entity could contain all the types of barriers that exist • It is up to you to define an updated data model that encompasses all the fields, entities, and associations you will need P o r t f o l i o m a n a g e m e n t p r o j e c t • Step 2: Generate an SQL database from Entity model • Recall this slide from 5092.9 • Follow these instructions… P o r t f o l i o m a n a g e m e n t p r o j e c t • Step 3: Create GUI app to curate elements of Entity model • The GUI design encompasses most of the functionality you’re adding to your current simulator • Think of the Portfolio Manager GUI as a “dashboard” that would allow you to manage financial positions • As such a manager, you care about the trades in your portfolio, their characteristics, and their P&L • Design it like you would use it! P o r t f o l i o m a n a g e m e n t p r o j e c t • GUI specifications: – GUI must provide a view that lists all trades currently in the database – The view must display the following about each trade • Direction • Quantity • Instrument • Instrument type • Trade price • “Mark price” – simulated price • P&L between trade price and mark price • All Greeks P o r t f o l i o m a n a g e m e n t p r o j e c t • GUI specifications: – The Trade view has fields for which special calculation must be considered • The P&L field must be calculated to include the direction of the trade and the quantity • The direction and quantity of the Greek fields must also be considered • Do not forget that a Stock has a delta of “1” – the delta field must be correct for Stocks too! – The fields need not be populated when trades are loaded – The population of price and Greeks will take place only after a simulation is run P o r t f o l i o m a n a g e m e n t p r o j e c t • GUI specifications: – Example of “main” screen with trade view Here, all trades are listed and the specified fields are populated P o r t f o l i o m a n a g e m e n t p r o j e c t • GUI specifications: – The GUI must provide a way to curate the following Entities • Instrument type • Instrument • Trade • Interest rate • Historical price – Curate means: • The user must be able to create new instances of each of the items above • The user must be able to delete instances of each of the items above • There is an order to the creation of some Entities You may choose to hard-code this… P o r t f o l i o m a n a g e m e n t p r o j e c t • Curate is practically equal to CRUD – Create – Read – Update – Delete • These SQL commands should be familiar, but a user needs a GUI-based friendly way to go about editing data • Delete may present an extra bit of work – What happens if you try to delete something that has foreign key associations elsewhere in the database? P o r t f o l i o m a n a g e m e n t p r o j e c t • An order exists to the creation of Entities • Consider creating a Trade… Instrument Type Instrument Trade The first step is to create an Instrument Type, since all Instruments must be typed (again, this may be hard-coded in the model) After a type is present, an instrument, like a Stock, can be created To have a trade, we must have an instrument to trade. To have an instrument, we must have a type that defines the instrument. P o r t f o l i o m a n a g e m e n t p r o j e c t • GUI specifications: – Example of curating an Instrument Selecting File -> New -> Instrument displays a dialog that can be populated by the user. Once the Instrument is created, Trades may be created using that Instrument. P o r t f o l i o m a n a g e m e n t p r o j e c t • GUI specifications: – Example of curating historical prices I created a Price Analysis window to curate a price collection for a particular Instrument. Here, a user can select rows in the data grid and delete them to remove the price from the collection. This action also saves changes to the historical prices to the database. P o r t f o l i o m a n a g e m e n t p r o j e c t • GUI specifications: – The user must have a means by which trades are loaded from the database – This may occur automatically when the program loads, or by instruction from the user – In my example, I chose a manual process initiated by the user to populate trades – The trades should populate the Trade view described in an earlier slide P o r t f o l i o m a n a g e m e n t p r o j e c t • GUI specifications: – There must be a view that, when multiple trades are selected by the user, provides the sum of the following characteristics A “Totals” view must be present to sum all selected trades in the “Trades” view P o r t f o l i o m a n a g e m e n t p r o j e c t • Broadly speaking, users should be able to easily create, view, and manipulate all the Entities that exist • Keep in your mind that the purpose of this assignment is to build a tool that manages a book of Trades • All the tools necessary to create the Trades and the ancillary data necessary to properly price and manage the trades must be present in your project • Again, imagine that you are building this tool to use it yourself! P o r t f o l i o m a n a g e m e n t p r o j
e c t • Step 4: Wire up your Monte Carlo simulator to the Portfolio Manager app • Once a GUI is in place to curate all the Entity objects, the Monte Carlo simulator must be added • The easiest way to perform this task is to take the core elements of your simulator and save them as a project • Then, in the Portfolio Manager GUI solution, add the Monte Carlo simulator project • Add the simulator as a reference in the GUI app and code should then have access P o r t f o l i o m a n a g e m e n t p r o j e c t • Here I show the idea of a solution PortMgr with the projects PortMgr and MontyLib • Right-click on the PortMgr project and select Add Reference An existing project can be added to a solution P o r t f o l i o m a n a g e m e n t p r o j e c t • Here, a reference may be made to another existing project in the solution • Once the reference is added, add the namespace reference to any code you wish to use the simulator P o r t f o l i o m a n a g e m e n t p r o j e c t • Pricing specifications: – Your portfolio manager must permit the addition of the following types of instruments • Stock • European option • Digital option • Barrier option • Asian option • Range option • Lookback option – The user must be able to create Trades on each of these products – The user must be able to value all the Trades of these product types using simulation Again, you may alternatively choose to make these static in your data model and Portfolio Manager GUI. P o r t f o l i o m a n a g e m e n t p r o j e c t • Pricing specifications: – When an Instrument Type is created, a pricing model must be selected; the system needs to know how to value a specific type of instrument being created – There must be a user-initiated way to begin pricing the book via simulation – Trade “mark price”, P&L, and Greeks should be updated after simulation runs P o r t f o l i o m a n a g e m e n t p r o j e c t • Pricing specifications: – Consider the inputs to the simulator for all options now • Underlying price • Strike price • Rebate • Barrier price • Barrier type • Volatility • Interest rate • Tenor – Some of the inputs come from the Instrument – Others come from the user or from ancillary Entity objects in the project Option object Last price in historical prices collection Simple input from user Interpolation from collection of interest rate points P o r t f o l i o m a n a g e m e n t p r o j e c t • Pricing specifications: – The characteristics in blue should be easy enough; they come from the option object – The underlying price should refer to the last recorded price of the underlying product • If there are not any recorded prices, raise an exception – The volatility should be a simple input on the main portfolio manager window, as shown here – The interest rate should be a linear interpolation between the two nearest points present as Interest Rate entity objects P o r t f o l i o m a n a g e m e n t p r o j e c t • Step 5: Ensure that the Portfolio Manager app and the simulator work seamlessly • Try adding a few different Stock instruments • Add a few options on the Stock instruments with different characteristics • Build a portfolio of trades using various instruments • As an exercise, try to build a delta-neutral portfolio • Price the book and select all the trades to see the P&L • Change the underlying prices and re-price! P o r t f o l i o m a n a g e m e n t p r o j e c t • There are a couple “acid tests” that will be helpful as you build the simulator • Acid Test #1 – Buy an option instrument. Sell the same instrument and quantity for a higher price. The sum of those two trades should create a positive P&L. They should also create flat Greeks. • Acid Test #2 – Build a delta-hedged portfolio with a long European option. Add a new price for the underlying dramatically different from the previous price. Re-price the book. The net delta should now be different and P&L should be positive. P o r t f o l i o m a n a g e m e n t p r o j e c t • 5 Minute Challenge Write the formula to calculate the P&L of a trade which is long fifty European options at a price of 10.89. The current mark is 13.55. P o r t f o l i o m a n a g e m e n t p r o j e c t • Solution The P&L would be calculated as follows: (13.55 – 10.89) x 50 = 133 If the trade were short fifty options: (10.89 – 13.55) x 50 = -133 W h a t ’ s n e x t ? • I hope you’ve enjoyed this class and the tinkering with programming and technology that comes along with it • We are out of time, but if you’re motivated to learn more in this vein, I have some suggestions • My suggestions fall into several categories – Programming – Web/cloud – Electrical engineering – Finance/trading – Art W h a t ’ s n e x t ? ( P r o g r a m m i n g ) • If you liked the functional design aspects of Python and C#… • F# is a functional language designed by Microsoft and part of .NET • I have not personally used it much, but I’m told it’s very good for finance applications W h a t ’ s n e x t ? ( P r o g r a m m i n g ) • If you liked C#, but don’t like Windows… • .NET Core is the platform-independent implementation of .NET • .NET Core apps run easily on Mac, Linux, or Windows, permitting you to use your C# skills across platforms! W h a t ’ s n e x t ? ( P r o g r a m m i n g ) • If you liked C#, but don’t like Microsoft… • C# takes a lot of inspiration from Java • With a good grasp of C#, picking up Java isn’t too tough • Recent versions of Java even have LINQ-like features…pretty neat • Works across many different platforms W h a t ’ s n e x t ? ( P r o g r a m m i n g ) • If you want to write C# for Android and iOS devices… • Xamarin Studio gives you the ability to write C# and compile it for Android and iOS • I can’t personally attest to its quality, but it seems widely-used • Many C# features are available in code W h a t ’ s n e x t ? ( P r o g r a m m i n g ) • If you want to extend Visual Studio… • ReSharper is a “helper” that extends the functionality of Visual Studio • Several students in past years have used it as professional programmers and tend to love it • There are competing similar products W h a t ’ s n e x t ? ( P r o g r a m m i n g ) • If you want to take multi-threading to the next level… • As mentioned in an earlier lecture, multi- threading can be extended to GPUs • There exists a project called C++ AMP to perform just this task • It can be accessed from C#… W h a t ’ s n e x t ? ( P r o g r a m m i n g ) • If you want a lightweight IDE that’s free to do all your cool C# and web coding… • Visual Studio Code is a free IDE made by Microsoft • It’s a simple yet powerful and flexible code editor that’s easily customizable • Great for .NET Core stuff W h a t ’ s n e x t ? ( P r o g r a m m i n g ) • If you want to expand your OS horizons… • Linux is encroaching ever more quickly into Windows’ market share • Having basic Linux skills is becoming very important for developers • In the future, I wouldn’t be surprised if this class switches to Linux W h a t ’ s n e x t ? ( W e b / c l o u d ) • If you want to use your .NET skills on the web… • ASP stands for Active Server Pages • You can use a lot of your C# knowledge to write responsive websites • There exist ASP.NET project templates in Visual Studio • Desktop coding skills transfer surprisingly well W h a t ’ s n e x t ? ( W e b / c l o u d ) • If you want to use your C# skills for web apps… • TypeScript is a superset of Javascript and is made by Microsoft • If you like writing thicker desktop app-style programs, writing TypeScript is a fairly easy transition to web apps • TypeScript is used by bigger frameworks like Angular and React W h a t ’ s n e x t ? ( W e b / c l o u d ) • If you want to write desktop
apps but want them to run in a web browser… • Angular is a Google technology that makes writing web apps oddly easy if you’re coming from a desktop developer background • I love Angular W h a t ’ s n e x t ? ( W e b / c l o u d ) • If you want to deploy your code on the Internet for everybody… • Microsoft’s cloud service is Windows Azure • Competitors include Amazon EC2 and Heroku • Azure is incredibly well-integrated into Visual Studio • You may host sites, dbs, virtual machines, etc. W h a t ’ s n e x t ? ( W e b / c l o u d ) • If you want to understand containerization… • Docker is a tool to create containers that run specific applications • Making a docker container means bundling up all the things an app needs to run (including the OS) into a tidy portable package • Very useful for cloud stuff W h a t ’ s n e x t ? ( E l e c . E n g i n e e r i n g ) • If you want to build a physical device… • An Arduino board makes it extremely easy to prototype physical devices with automation • You may program this simple board to control electrical current output • There are many easily-connectable sensors W h a t ’ s n e x t ? ( F i n a n c e / t r a d i n g ) • If you want to learn more about exotics trading… • The book Dynamic Hedging by Nassim Taleb is a good place to start • It has many real-world considerations in the trading of exotics W h a t ’ s n e x t ? ( F i n a n c e / t r a d i n g ) • If you want to write code to trade autonomously… • Automated trades almost universally take place over the FIX protocol • Using it, you can write code to execute orders • The brokerage Interactive Brokers permits retail clients to connect via FIX…pretty cool W h a t ’ s n e x t ? ( A r t ) • If you want to read about the nature of intelligence and consciousness This is my favorite book. W h a t ’ s n e x t ? ( A r t ) • If you want to stop thinking about finance, trading, programming, and this class… • This book is a superb introduction to modern art – I loved it In my view, the notion of “objective value” is a trope. Learn about art in order to learn about relative value – the only kind of value there is.

admin

Author admin

More posts by admin