Skip to content

Commit

Permalink
Merge pull request #102 from Premian-Labs/fix/patch-0dte-and-strikes
Browse files Browse the repository at this point in the history
Updates Strike intervals, validate 0 DTE options
  • Loading branch information
froggiedev committed Feb 20, 2024
2 parents 3384388 + 94d7b84 commit 4afe7c0
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@premia/v3-sdk",
"version": "2.5.2",
"version": "2.5.3",
"description": "The official SDK for building applications on Premia V3.",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
Expand Down
3 changes: 1 addition & 2 deletions src/api/optionAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,7 @@ export class OptionAPI extends BaseAPI {
*/
getStrikeInterval(price: number): number {
const orderOfTens = Math.floor(Math.log10(price))
const base = price / 10 ** orderOfTens
return base < 5 ? 10 ** (orderOfTens - 1) : 5 * 10 ** (orderOfTens - 1)
return 10 ** (orderOfTens - 1)
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/utils/dayjs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ export function nextYearOfMaturities(): dayjs.Dayjs[] {
const today = dayjs().utc().startOf('day')
const nextYear = today.add(1, 'year')

// if today is Fri and hour < 8:00 AM
if (dayjs().utc().day() === FRIDAY && dayjs().utc().hour() < 8)
maturities.push(today)
// if there's still time to 8:00 AM UTC - 1 hours buffer
if (dayjs().utc().hour() < 8)
maturities.push(today.add(8, 'hours'))

const tomorrow = today.add(1, 'day').add(8, 'hours')
const afterTomorrow = today.add(2, 'days').add(8, 'hours')
Expand Down
2 changes: 1 addition & 1 deletion test/it/option.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe('Option API', function (this: any) {
// end of array
if (Number.isNaN(strikeRange)) return true

return nextStrike - strike === 50
return nextStrike - strike === 10
})
).to.be.true

Expand Down

0 comments on commit 4afe7c0

Please sign in to comment.