domokane / FinancePy

A Python Finance Library that focuses on the pricing and risk-management of Financial Derivatives, including fixed-income, equity, FX and credit derivatives.
GNU General Public License v3.0
2.16k stars 322 forks source link

Equity swap #166

Closed nashquant closed 1 year ago

nashquant commented 1 year ago

Hi @domokane,

Here's a first version of the implementation for Equity Swaps as mentioned in issue #159. Looking forward for a feedback of yours!

Some details: 1) Implemented Equity Swap for Total return only - Thought that Price Return would be complicated for this first round, as it requires the generation of the div payments separately.

2) Enabled only Float Rate for Rate Leg for now - also to avoid extra complexity in this first round.

3) Given that Equity Leg has variable notional - i.e. at every reset we need to update the new notional to reflect the new price of equity - I had to make some small changes to the SwapFloatLeg model to address this issue - Let me know if you disagree or think of a better way to address this.

4) Implemented three tests that should cover basic logic for this model - let me know if you think of something else that must be there in this first round.

5) I wasn't being able to generate good-looking tables for the payments schedule and valuation prints, so I used an external lib PrettyTable. Let me know if you're against it, I can give it another try, but I'm letting attached a print of how it's looking now - and I sort of liked it.

6) Overall, I tried to stick to the conventions and code style of EquitySwapFloat, but of course I might have overlooked some aspects, so feel free to point me to them.

Best, Matheus

Payment Schedule

domokane commented 1 year ago

Hi - This is good but can you rename class SwapEquityLeg class to EquitySwapLeg. I will study it more later.

nashquant commented 1 year ago

Hi @domokane

Thank you! Will update this soon.

PaleNeutron commented 1 year ago

prettytable is not included in package dependency 😕

domokane commented 1 year ago

It is already in requirements.txt. Where else should it be ?

PaleNeutron commented 1 year ago

@domokane , it should be here https://github.com/domokane/FinancePy/blob/762dfb31eaa335b144cc7345a89bb4fd0b1c0d24/setup.py#L48 not requirements.txt, a little tricky.

domokane commented 1 year ago
OK. Will add.  From: John LyuSent: 22 May 2023 13:48To: domokane/FinancePyCc: domokane; MentionSubject: Re: [domokane/FinancePy] Equity swap (PR ***@***.*** , it should be here https://github.com/domokane/FinancePy/blob/762dfb31eaa335b144cc7345a89bb4fd0b1c0d24/setup.py#L48 not requirements.txt, a little tricky.—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: ***@***.***> 
nashquant commented 1 year ago

Apologies for missing that, and thank you both for reviewing this. I'm currently in a trip with limit access to pc.

kiann00 commented 1 year ago

@domokane wow Ser! This is an AMAZING project. You basically gave the 'world'/everyone FREE, what costs (tens of, to hundreds of) millions of dollars in Quant salaries and Quant code, what Investment Banks took decades to build!

I salute you, Ser.

side note on this issue, @nashquant , yes, the issue is still there. I just have to manually install in (Ana)conda : $pip install prettytable to correct the error

domokane commented 1 year ago

Thanks. I updated setup.py but I need to roll a new version. I will do that asap.