Rigorous derivation of dΠ for stock with continuous dividend

Posted on StackExchange, but they have a nasty habit of deleting unanswered questions after a while, in an irrecoverable way, so I’m going to re-post all my random questions here as I go along in life.  (You can see dead questions if you know the URL, they keep it around, but if you lose the URL, forget about it.)  So….

Suppose we are holding a replicating portfolio \Pi_t of long an option f(S,t) and short some stock, so \Pi_t=f(S_t,t)-\Delta_t S_t Suppose the stock follows geometric Brownian motion and pays continuous dividends at rate q, so d S_t = S_t((\mu-q)dt + \sigma dW_t Naively, d\Pi_t = d f(S_t,t)-\Delta_t dS_t However, because the stock pays a dividend, common sense and the literature tell us that d\Pi_t=df(S_t,t)-\Delta_t dS_t-\Delta_t S_t dt

Question: How do we rigorously arrive at the total derivative for d\Pi_t which includes extra term -\Delta_t S_t dt, given that we know \Pi_t=f(S_t,t)-\Delta_t S_t, without appeal to common sense i.e., from the equations, without recalling the mechanics of how the stock works? Because, naively, I would not include the extra term, if I just knew the equation defining \Pi_t and nothing about the mechanics of the stock.

Date range search fields in Django: Take your rant to your blog, mister!

This is something I figured out but it was horribly difficult and took me a week and 10 cups of coffee to figure out.  I posted a soluion on StackExchange. Because I noted the #cups of coffee I got two immediate downvotes and angry messages from some gurus who spend all their time on StackExchange:

This is not the right place to post your rants. Please consider posting this in your blog or somewhere.


This really isn’t the place for a rant disguised as a question. If you want to request this specific feature, you can open a ticket. If you just want to put this out there for future reference, you can ask a question on how to do it, and add your own answer. Either way, please use a more constructive tone.

I edited out the snark and now their comments look overheated, because the post is now entirely dry and technical.  I hope they leave their castigations up so I can have some exciting controversy at the bottom of the post, which is as stimulating without the color as a description of how to install a replacement toilet handle.

Privatizing the 4th of July


My family and I went to see 4th of July fireworks in a Southern town north of Charlotte. The only available fireworks were at a country club.  Members of the club had their own roped-off area and the hoi polloi were invited to park on a nearby main road and hike onto the rest of the golf course.  About 5,000 cars were parked on the main road, a mile up and down, and the walk with small children was a challenge.  We chose to park near the main entrance to the club.  There was a community of over $1MM brick houses associated with the club.  Not all residents are members.  Membership in the club starts with a down payment of around $50,000 and then monthly payments around $700.  I saw a non-member resident ask to sit in the club members area, something she had done in previous years, and she was turned away.  This community thus comprises both haves and have-nots, first class and business class.  The rest of us were in coach.  Parking my car I was close to but not blocking one resident’s driveway.  He came out and asked us to move, pretexting visitors soon to come.  After the fireworks were over, we returned and found his house unlit and unoccupied.

Growing up in New England I have a memory, perhaps false, that there were always town-sponsored fireworks in some area big enough to accommodate all of the town. North of Charlotte, where there is a large lake, there is almost no public space other than shopping malls.  The opening of a small beach was a big deal, with nearby residents loudly hand-wringing over the accompanying parking problems.  The beach had about 70 parking spaces. Consistently 700 come to bathe.  Even the highway, route 77, has been privatized, with a fast lane under construction for those that can afford to pay per use.

North Carolina is a state which is notable for the thorough inadequacy of its public transportation, its low teacher pay and disdain for public education, and the refusal Federal Medicaid funds.  The state, which just elected a Democratic governor by a narrow margin, has seen its Republican-dominated legislature systematically strip the governor of his powers and cut funds to his employees.  It’s quite something.

As a state on the losing side of what has been called, down here (not so sure if by the current generation, but surely the prior one), the War Between The States, I wonder if the lack of municipal attention paid to the 4th of July has strong historical roots in that conflict.  There is some evidence in favor of this interpretation.  So despite the otherwise rah-rah nature of Southern conservatives regarding the US of A and all of that, I wonder if institutionally the state is still driven by those older grievances, in a completely unconscious but still persistent way.

Python software spaghetti stack for web apps


When you want to solve a problem, the easiest thing is to follow in the tracks of someone else.  This can lead to a fairly complicated software stack to combine solutions to different issues.  My stack is going in this direction:

SQL/Sqlite: Database.  Simple and light but apparently more than good enough for most web apps.

Python: main application glue.  For those of us who need to get stuff done in the scientific visualization space, and have no patience for Java or random obscure newish languages like Scala and Lua.

CSS: Stylesheet language of all websites.  Hard to avoid knowing about.  A bit unlovely.

Javascript: Popular browser-side programming language implemented in all major browsers, equivalent to Python, loosely Java-like but without all the mind-numbing type checking and package hierarchies (at first glance).

Ajax: Method of communicating between client-side Javascript and server-side application (in Python in my case), to update an element of a webpage without having to redraw and reload the entire webpage

Bootstrap: A library of widgets and good stuff, originally programmed for Twitter, which is public domain and has things like stars for Like buttons.

Node.js: Server-side implementation of Javascript, moving some of the rendering load for complicated pages back to server.  (But initial intention was for browser-side Javascript to make things faster

Django: Python-based web application development package.  Features use of SQLAlchemy to make it easy to bind classes to database tables and incorporate changes in class structure during dvelopment.

React.js: A way of getting much fancier widgets than vanilla Django, in particular the Editable Table.  Requires some tedious and tricky integration to make it play with Django.

Amazon Elastic Compute: Web server in the cloud without compromising my home computer, for modest cost.

Series the wife and I finished watching

The jig is almost up now for Veep

and Silicon Valley.

We closed down Girls.

We’re waiting for Game of Thrones to start up again.

Big Little Lies wasn’t to my taste, so we didn’t get far on that one.

Orange is the New Black was for a while but then I got tired of it and there’s a series and a half of so I haven’t seen.

We finished Homeland and are between seasons.

We just finished Better Call Saul and are sadly beginning the long wait for renewal and the next season.

We finished Crashing

and Master of None,

neither of which is guaranteed a new season.  I finished Archer Season 8.

That’s a show that seems to have run out of variations on a theme, I could be wrong.  I’ll be surprised to see it back, but will watch it if it does.  It’s a one-trick pony but it works for me.   I finished WestWorld.

We are going back to House of Cards, we’ve got a season and a half left.

I quit that a while ago because, prior to the most recent election, I just thought it was too far-fetched.   Now with a Queens landlord as President and his stripper wife as First Lady, not so much.  Even if Hillary won, that would still have played into the House of Cards theme. Only a Bernie win would have broken the mold.  We live in strange times.