sirnfs / OptionSuite

Option and stock backtester / live trader
MIT License
243 stars 60 forks source link

error in put vertical buying power calculation #14

Closed bayareacoder closed 5 months ago

bayareacoder commented 5 months ago

I believe the buying power (margin) requirement for a short vertical in putVertical.py, shown as:


      currentPutToSellPrice - currentPutToBuyPrice)) * self.__numContracts * 100```

is not correct. It should be just the width of the spread * 100 * number of contracts as that is the max value it could achieve if the short spread is fully in the money. So:
      ```buyingPower = (self.__putToSell.strikePrice - self.__putToBuy.strikePrice) * self.__numContracts * 100```

UPDATE: OK I guess they allow the credit received to count against the margin requirement. That could be specific to Tastytrade. Then it's correct.
https://support.tastytrade.com/support/s/solutions/articles/43000435260
sirnfs commented 5 months ago

I believe this is correct. Can you please check the explanation and example here: https://tastytrade.com/learn/options/short-put-vertical-spread/

On Tue, Jun 25, 2024, 6:24 AM B @.***> wrote:

I believe in putVertical.py: buyingPower = ((self.putToSell.strikePrice - self.putToBuy.strikePrice) - ( currentPutToSellPrice - currentPutToBuyPrice)) self.__numContracts 100

should be: buyingPower = ((self.putToSell.strikePrice - self.putToBuy.strikePrice) ( currentPutToSellPrice - currentPutToBuyPrice)) self.__numContracts * 100

  • should be *

— Reply to this email directly, view it on GitHub https://github.com/sirnfs/OptionSuite/issues/14, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB6QJ4KRRN2MKFUZS2WBCKDZJDWINAVCNFSM6AAAAABJ3AL3U6VHI2DSMVQWIX3LMV43ASLTON2WKOZSGM3TCNRRGQ2TINY . You are receiving this because you are subscribed to this thread.Message ID: @.***>

bayareacoder commented 5 months ago

Yes it is correct as mentioned in my update. But when you do iron condors (vertical put & call spread) then it's not so simple as now the margin requirement of a put vertical depends on matching call verticals in the portfolio. Have you done code for an iron condor (i.e. matching put + call short verticals) strategy?

sirnfs commented 5 months ago

I don't have code for an iron condor, but here's how the buying power is calculated with Tastytrade: https://support.tastytrade.com/support/s/solutions/articles/43000435229

On Tue, Jun 25, 2024, 5:46 PM B @.***> wrote:

Yes it is correct as mentioned in my update. But when you do iron condors (vertical put & call spread) then it's not so simple as now the margin requirement of a put vertical depends on matching call verticals in the portfolio. Have you done code for an iron condor (i.e. matching put + call short verticals) strategy?

— Reply to this email directly, view it on GitHub https://github.com/sirnfs/OptionSuite/issues/14#issuecomment-2189306914, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB6QJ4PKTA3PXFGFDXJOOKDZJGGENAVCNFSM6AAAAABJ3AL3U6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOBZGMYDMOJRGQ . You are receiving this because you commented.Message ID: @.***>

sirnfs commented 5 months ago

Note that I actually checked and and confirmed this on the Tastytrade platform.

On Tue, Jun 25, 2024, 6:19 PM Michael Santoro @.***> wrote:

I don't have code for an iron condor, but here's how the buying power is calculated with Tastytrade: https://support.tastytrade.com/support/s/solutions/articles/43000435229

On Tue, Jun 25, 2024, 5:46 PM B @.***> wrote:

Yes it is correct as mentioned in my update. But when you do iron condors (vertical put & call spread) then it's not so simple as now the margin requirement of a put vertical depends on matching call verticals in the portfolio. Have you done code for an iron condor (i.e. matching put + call short verticals) strategy?

— Reply to this email directly, view it on GitHub https://github.com/sirnfs/OptionSuite/issues/14#issuecomment-2189306914, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB6QJ4PKTA3PXFGFDXJOOKDZJGGENAVCNFSM6AAAAABJ3AL3U6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOBZGMYDMOJRGQ . You are receiving this because you commented.Message ID: @.***>

sirnfs commented 5 months ago

Going to go ahead and close this issue. Thanks for reviewing the code.