コード例 #1
0
 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);
 });
コード例 #2
0
 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);
 });
コード例 #3
0
 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);
 });
コード例 #4
0
 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);
 });
コード例 #5
0
 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);
 });
コード例 #6
0
 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);
 });
コード例 #7
0
 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);
 });