Code to calculate Margin using TIMS model?

Discussion in 'App Development' started by gowthamn, Mar 22, 2019.

  1. gowthamn

    gowthamn

    Is there some library I can use to calculate margin requirements for an options order using the TIMS model?
    I have a portfolio margin account and I would like to back test some strategies. But don't know what my margin would have been. I trade with IB, so IB uses +6% and -8% range for indexes like SPX.
     
    stochastix likes this.
  2. Is there some reason you can't use a simple calculation ?
     
  3. gowthamn

    gowthamn

    Is there a simple way to calculate margin using TIMS? We have to vary the underlying price and change IV to simulate what would happen.
     
  4. Robert Morse

    Robert Morse Sponsor

    1st, IB does not always use those OCC shocks. 2nd, the OCC does not offer that formula to non-members. IB requirement will be higher if you have OTM options.

    In general, The OCC takes end of day bid/ask spreads and calculate the midpoint. Then they look for strikes that are further away but have a higher value than options that are closier so there is no "arb" in prices. Then they uses a smoothing algorithm for out of the money options. They smooth price then Ivol. Then they have their curve that they calculate the 5 breaks down and 5 break up to determine max loss and compare that to the minimum requirement.

    Not easy to do on your own.
     
    stochastix likes this.
  5. gowthamn

    gowthamn

    If calculating margin is so difficult, then is there a way to programmatically back test strategies without calculating margin for portfolio margin accounts?
     
  6. sle

    sle

    Margin models and leverage ratios change over time. Instead, you want to backtest in terms of return on risk whichever way you like to define it (notional, vega, var etc). If you are trading equities, you can use GMV, for example.
     
  7. Robert Morse

    Robert Morse Sponsor

    Not as far as I know
     
  8. TommyR

    TommyR

    margin models change at brokers convenience its how they are able to steal yourmoney on options even when you pay them 10 times market width. for that reason i no longer trade options with brokers. if you do its v risky and im not sure really sure how you would deal with it its certainly not feasible risk revard v everage (they seem to charge many times the underling plus their vol markets and whatever else and often change if some idiot wises up to in the money options as if you are screwing them: imagine how much can u pay them to do nothing) its like any other shit. they can and will be dealt with its amusing tho when they say CJNJ are not nice or something. brokers would be buried under the jail they wouldnt last a day
     
  9. TommyR

    TommyR

    tell them you must have a way to know the margin, like are they joking is that funy. it must not change during the trade. the pnl will account for it. leave and take your money until its done.
     
  10. Robert Morse

    Robert Morse Sponsor

    I'm not sure how option trading works in the UK, but here the broker is not the counterparty to your option trade and we do not provide depth and liquidity. We do not determine the option spreads. That is done by option market makers and public orders. If markets are too wide in the symbols you trade, I do agree it is a good idea to avoid them however placing the blame on your broker is not accurate. Put the blame on the SEC for allowing the fragmentation of 15, soon to be 16 options exchanges that mostly owned by the ICE, CBOE and NASDAQ.
     
    #10     Mar 24, 2019
    stochastix likes this.