it('testCoveredCallShort', function() { var bs1=new OptionsStrategy([ { q: 1, o: new BlackScholes('C',80,0,0.25,0)}, { q: -1, o: new BlackScholes('S',80,0,0.25,0)} ]); var x=bs1.margin([60,80,100,120],0); (x==80).should.eql(true); });
it('testSpreadShort', function() { var bs1=new OptionsStrategy([ { q: -1, o: new BlackScholes('C',80,0,0.25,0.2)}, { q: 1, o: new BlackScholes('C',90,0,0.25,0.2)} ]); var x=bs1.margin([60,80,100,120],[0,0.1,0.2]); (x==10).should.eql(true); });
it('testStraddleShort', function() { var bs1=new OptionsStrategy([ { q: -1, o: new BlackScholes('C',80,0,0.25,0.2)}, { q: -1, o: new BlackScholes('P',80,0,0.25,0.2)} ]); var x=bs1.margin([60,80,100,120],[0,0.1,0.2]); (x>40&&x<41).should.eql(true); });
it('testMarginNumeric', function() { // test that margin is always numeric var bs1=new OptionsStrategy([{q: 1, o: new BlackScholes('P',80,0,0.25,0)}]); var x=bs1.margin(60,0); (is_numeric(x)).should.eql(true); bs1=new OptionsStrategy([{q: 1, o: new BlackScholes('P',80,0,0.25,0)}]); x=bs1.margin([60,80,100,120],0); (is_numeric(x)).should.eql(true); bs1=new OptionsStrategy([{q: 1, o: new BlackScholes('P',80,0,0.25,0.2)}]); x=bs1.margin([60,80,100,120],[0,0.1,0.2]); (is_numeric(x)).should.eql(true); bs1=new OptionsStrategy([ {q:1, o: new BlackScholes('P',80,0,0.25,0)}, {q:-1, o: new BlackScholes('P',90,0,0.25,0)} ]); x=bs1.margin(60,0); (is_numeric(x)).should.eql(true); });
it('testLongCallPremium', function() { var bs1=new OptionsStrategy([{q: 1, o: new BlackScholes('C',80,0,0.25,0,2.12)}]); var x=bs1.margin([60,80,100,120],0); (x==2.12).should.eql(true); });
it('testSecurityShort', function() { var bs1=new OptionsStrategy([{q: -1, o: new BlackScholes('S',80,0,0.25,0)}]); var x=bs1.margin([60,80,100,120],0); (x==120).should.eql(true); });
it('testShortCallVector', function() { var bs1=new OptionsStrategy([{q: -1, o: new BlackScholes('C',80,0,0.25,0)}]); var x=bs1.margin([60,80,100,120],0); (x==40).should.eql(true); });