1(function(){try{var e=typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:typeof self<`u`?self:{};e.SENTRY_RELEASE={id:`2b3fa98cecb9ecded9edb92f06263a16f8cab334`}}catch{}})();try{(function(){var e=typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:typeof self<`u`?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`a22943d4-c9de-466d-91d4-ed89599ad27c`,e._sentryDebugIdIdentifier=`sentry-dbid-a22943d4-c9de-466d-91d4-ed89599ad27c`)})()}catch{}import{s as e}from"./rolldown-runtime-BtEJSlmX.js";import{k as t}from"./dist-C0lFuP4d.js";import{Ql as n,Yt as r,in as i}from"./GlobalEventEmitter-BUqOyzy1.js";import{At as a,qt as o}from"./settings-CH5WINdC.js";var s=e(t()),useInstrumentObj=(e,t={includeSynthetic:!1})=>{let n=o(a);return(0,s.useMemo)(()=>n&&e&&e in n?i.extendInstrumentData(n[e]):t.includeSynthetic&&e?i.getSyntheticInstrumentData(e):null,[e,n,t.includeSynthetic])},N=e=>{let t=Math.abs(e),n=1/(1+.2316419*t),r=1-1/2.5066282746310002*Math.exp(-t*t/2)*(.31938153*n+-.356563782*n*n+1.781477937*n*n*n+-1.821255978*n*n*n*n+1.330274429*n*n*n*n*n);return e<0?1-r:r},getBlackScholesPutPrice=(e,t,n,r,i,a)=>{let o,s,c,l;return l=a/365,s=(Math.log(e/t)+(i-r+n*n/2)*l)/(n*Math.sqrt(l)),c=(Math.log(e/t)+(i-r-n*n/2)*l)/(n*Math.sqrt(l)),o=Math.exp(-i*l)*t*N(-c)-Math.exp(-r*l)*e*N(-s),o},getBlackScholesCallPrice=(e,t,n,r,i,a)=>{let o,s,c,l;return l=a/365,s=(Math.log(e/t)+(i-r+n*n/2)*l)/(n*Math.sqrt(l)),c=(Math.log(e/t)+(i-r-n*n/2)*l)/(n*Math.sqrt(l)),o=Math.exp(-r*l)*e*N(s)-Math.exp(-i*l)*t*N(c),o},getBlackScholesImpliedVolatility=({optionType:e,underlyingPrice:t,optionStrike:n,optionExpDays:r,priceUSD:i,interestRate:a})=>{let o=e,s=t,c=n,l=r,u=i,d=a,f=1e-5,p,m,h=0,g=1e-4,_=5,v=.5;if(typeof d==`number`&&(h=d),o===`call`){for(p=0,m=getBlackScholesCallPrice(s,c,v,0,h,l)-u;p<32&&Math.abs(m)>f;){if(m<0)g=v,v=(_+v)/2;else if(m>0)_=v,v=(g+v)/2;else return v;m=getBlackScholesCallPrice(s,c,v,0,h,l)-u,p+=1}return v}for(p=0,m=getBlackScholesPutPrice(s,c,v,0,h,l)-u;p<32&&Math.abs(m)>f;)m<0?(g=v,v=(_+v)/2):(_=v,v=(g+v)/2),m=getBlackScholesPutPrice(s,c,v,0,h,l)-u,p+=1;return v},getBlackScholesPrice=({optionType:e,underlyingPrice:t,optionStrike:n,optionExpDays:r,priceIV:i,interestRate:a})=>{let o=e,s=t,c=n,l=r,u=i,d=a,f=0;return typeof d==`number`&&(f=d),(o===`call`?getBlackScholesCallPrice:getBlackScholesPutPrice)(s,c,u/100,0,f,l)};function getOrderPrices({price:e,advanced:t,instrumentObj:a,indexPrice:o,underlyingPrice:s,interestRate:c}){let l=0,u=0,d=0,f=0;if(!a)return null;let p=a.option_type,m=Number(a.strike),h=a.expiration_timestamp,g=Math.round(Math.abs((Date.now()-h)/864e5)*1e4)/1e4,_=i.isLinearOptionInstrument(a.instrument_name);switch(t){case void 0:d=e,u=n(d*o,.01,Math.round),l=n(d*s,.01,Math.round),f=Math.round(getBlackScholesImpliedVolatility({optionType:p,underlyingPrice:s,optionStrike:m,optionExpDays:g,priceUSD:_?e:l,interestRate:c})*100*10)/10;break;case`usd`:u=e,d=n(u/o,r(a.instrument_name,u/o),Math.round),l=n(d*s,.01,Math.round),f=Math.round(getBlackScholesImpliedVolatility({optionType:p,underlyingPrice:s,optionStrike:m,optionExpDays:g,priceUSD:l,interestRate:c})*100*10)/10;break;case`implv`:f=e,l=getBlackScholesPrice({optionType:p,underlyingPrice:s,optionStrike:m,optionExpDays:g,priceIV:f,interestRate:c}),d=_?n(l,r(a.instrument_name,l),Math.round):n(l/s,r(a.instrument_name,l/s),Math.round),u=n(d*o,.01,Math.round)}return{priceUsd:u,priceCrypto:d,priceImplv:f}}var calculateOrderBidAskDifference=(e,t,n,r)=>e===`buy`&&n!==0?(t-n)/n:e===`sell`&&r!==0?(r-t)/r:0,calculateOrderMarkPriceDifference=(e,t)=>t===0?0:Math.abs((e-t)/t);function checkIsOrderDeepIntoTheMarket({tickerData:e,orderSpec:t,priceCrypto:n}){let{type:a,direction:o,price:s}=t;if(a!==`limit`)return!1;let c=i.getInstrumentData(t.instrument_name)??i.splitInstrument(t.instrument_name);if(c){let{isFuture:i,isSpot:a,isOption:l,isOptionCombo:u,isFutureCombo:d}=c,f=n??s??0,{best_bid_price:p,best_ask_price:m,mark_price:h}=e;if((l||u||d)&&calculateOrderMarkPriceDifference(f,h)>.02){if(u){let e=.0015;return o===`buy`?f-h>e:h-f>e}let e=r(t.instrument_name,f);if(e){let t=d?5*e:3*e;return o===`buy`?f-h>t:h-f>t}}let g=calculateOrderBidAskDifference(o,f,p,m);if(i&&g>.01||a&&g>.02)return!0}return!1}export{getBlackScholesImpliedVolatility as a,getOrderPrices as i,calculateOrderMarkPriceDifference as n,getBlackScholesPrice as o,checkIsOrderDeepIntoTheMarket as r,useInstrumentObj as s,calculateOrderBidAskDifference as t};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.