Skip to content

Commit

Permalink
fix(quantil-prime-oob): out of bounds test for quantile prime
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexangelj committed Aug 4, 2021
1 parent 79dfb91 commit 08991de
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
6 changes: 2 additions & 4 deletions test/book.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ describe('Book', () => {
const premiums = poolKeys.map(key => {
const iv = +pools[strike][key].iv / 100
const premium = math.callPremium(strike, iv, tau, spot)
console.log({ strike, iv, tau, spot, premium })
return premium
})

Expand Down Expand Up @@ -54,9 +53,8 @@ describe('Book', () => {
return costs.reduce((a, b) => a + b) / totalSize
}

const avg = calcAvgPrice(costs, totalSize)

console.log({ avg, costs, premiums })
calcAvgPrice(costs, totalSize)
//console.log({ avg, costs, premiums })
})
})
})
9 changes: 9 additions & 0 deletions test/cumulativeNormalDistribution.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ describe('Stats Math Library', () => {
const x = 1.5
expect(math.quantilePrime(x)).toEqual(NaN)
})

it('return a number for in bounds number', () => {
const x = 1
expect(math.quantilePrime(x) > 0).toEqual(!NaN)
})
it('return a number for in bounds number', () => {
const x = 0
expect(math.quantilePrime(x) > 0).toEqual(!NaN)
})
})

describe('solidityNormalCDF', () => {
Expand Down
12 changes: 8 additions & 4 deletions test/replicationMath.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import * as math from '../src/ReplicationMath'

describe('Replication math', () => {
describe('trading function', () => {
describe('getStableGivenRisky', () => {
it('return 0 if strike price and invariant is 0', () => {
expect(math.getStableGivenRisky(0.5, 0, 1, 1)).toEqual(0)
})

it('return 0 if risky reserve is 1', () => {
expect(math.getStableGivenRisky(1, 1, 1, 1, 1)).toEqual(0)
expect(math.getStableGivenRisky(1, 1, 1, 1)).toEqual(0)
})

it('return K if risky reserve is 0', () => {
Expand All @@ -21,7 +21,7 @@ describe('Replication math', () => {
})
})

describe('inverse trading function', () => {
describe('getRiskyGivenStable', () => {
it('return 0 if strike price is 0', () => {
expect(2).toEqual(2)
})
Expand All @@ -37,7 +37,11 @@ describe('Replication math', () => {

describe('calculate spot price', () => {
it('shouldnt be nan', () => {
expect(math.getSpotPrice(1, 2, 1, 1) > 0).toBe(!NaN)
expect(math.getSpotPrice(0.999, 1, 1, 1) > 0).toBe(!NaN)
})

it('should be nan if 1 - reserveRisky is 0 or less', () => {
expect(math.getSpotPrice(1, 1, 1, 1)).toBe(NaN)
})

it('should be nan if reserveRisky is greater than 1', () => {
Expand Down

0 comments on commit 08991de

Please sign in to comment.