{"size": 6256, "ext": "js", "max_stars_repo_path": "website/build/static/js/main.76fd2254.chunk.js", "max_stars_repo_name": "ajmal017/Option_Warning", "max_stars_repo_stars_event_min_datetime": "2020-07-02T10:58:41.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-23T09:08:28.000Z", "max_issues_repo_path": "website/build/static/js/main.76fd2254.chunk.js", "max_issues_repo_name": "lit26/Option_Warning", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "website/build/static/js/main.76fd2254.chunk.js", "max_forks_repo_name": "lit26/Option_Warning", "max_forks_repo_forks_event_min_datetime": "2020-06-28T07:55:44.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-01T05:01:37.000Z"}
{"max_stars_count": 6, "max_issues_count": null, "max_forks_count": 2, "avg_line_length": 3128.0, "max_line_length": 6208, "alphanum_fraction": 0.6982097187}
(this["webpackJsonpoption-warning"]=this["webpackJsonpoption-warning"]||[]).push([[0],{25:function(e,t,a){e.exports=a(44)},30:function(e,t,a){},31:function(e,t,a){},44:function(e,t,a){"use strict";a.r(t);var n=a(0),r=a.n(n),l=a(20),i=a.n(l),c=(a(30),a(31),a(32),{paddingTop:"30px",paddingBottom:"30px",color:"#fff",background:"#2e2e2e",textAlign:"left"});var o=function(){return r.a.createElement("div",{style:c},r.a.createElement("div",{style:{margin:"30px"}},r.a.createElement("h2",null,"Option Warning"),r.a.createElement("div",{style:{width:"300px"}},"This website will calculate max profit and max loss for your option tradings.")))},u=a(7),s=a(9),m=a(10),d=a(12),p=a(11),E=a(16),h=a(14),f=a(45),y=a(46),b=a(24),v=a(47),g=a(21),x=a(48),k=a(49),P=a(22),S=a.n(P),C={textAlign:"left",margin:"10px"},T=function(e){Object(d.a)(a,e);var t=Object(p.a)(a);function a(e){var n;return Object(s.a)(this,a),(n=t.call(this,e)).handleChange=function(e){var t=e.target.name,a=e.target.value;n.setState(Object(g.a)({},t,a))},n.handleSubmit=function(e){e.preventDefault(),n.props.onSubmit({id:S.a.generate(),strikePrice:parseFloat(n.state.strikePrice),buySell:n.state.buySell,tradeType:n.state.tradeType,price:parseFloat(n.state.price)}),n.setState({strikePrice:"",buySell:"",tradeType:"",price:""})},n.state={id:"",strikePrice:"",buySell:"",tradeType:"",price:""},n}return Object(m.a)(a,[{key:"render",value:function(){var e=this.state,t=e.strikePrice,a=e.buySell,n=e.tradeType,l=e.price;return r.a.createElement(x.a,{onSubmit:this.handleSubmit,style:C},r.a.createElement(x.a.Group,{controlId:"formGridStrikePrice"},r.a.createElement(x.a.Label,null,"Strike Price"),r.a.createElement(x.a.Control,{type:"text",name:"strikePrice",value:t,onChange:this.handleChange})),r.a.createElement(x.a.Group,{controlId:"formGridTradeType"},r.a.createElement(x.a.Label,null,"Trade Type"),r.a.createElement(x.a.Row,null,r.a.createElement(b.a,null,r.a.createElement(x.a.Control,{as:"select",name:"buySell",value:a,onChange:this.handleChange},r.a.createElement("option",null,"Choose"),r.a.createElement("option",{value:"Buy"},"Buy"),r.a.createElement("option",{value:"Sell"},"Sell"))),r.a.createElement(b.a,null,r.a.createElement(x.a.Control,{as:"select",name:"tradeType",value:n,onChange:this.handleChange},r.a.createElement("option",null,"Choose"),r.a.createElement("option",{value:"Call"},"Call"),r.a.createElement("option",{value:"Put"},"Put"))))),r.a.createElement(x.a.Group,{controlId:"formGridPrice"},r.a.createElement(x.a.Label,null,"Price"),r.a.createElement(x.a.Control,{type:"text",name:"price",value:l,onChange:this.handleChange})),r.a.createElement("div",null,"Contract size: 100"),r.a.createElement("br",null),r.a.createElement(k.a,{variant:"primary",type:"submit"},"Add"))}}]),a}(n.Component);function O(e,t){var a,n=0,r=Object(h.a)(t.entries());try{for(r.s();!(a=r.n()).done;){var l=Object(E.a)(a.value,2)[1],i=l.strikePrice,c=l.price,o=0;"Call"===l.tradeType?o=Math.max(e-i,0)-c:"Put"===l.tradeType&&(o=Math.max(i-e,0)-c),"Sell"===l.buySell&&(o=-o),n+=1*o*100}}catch(u){r.e(u)}finally{r.f()}return n}var j={cursor:"pointer"},w=function(e){Object(d.a)(a,e);var t=Object(p.a)(a);function a(e){var n;return Object(s.a)(this,a),(n=t.call(this,e)).addTrades=function(e){var t=[e.strikePrice].concat(Object(u.a)(n.state.strikePrices));t.sort((function(e,t){return e-t})),n.setState((function(a){return{trades:[e].concat(Object(u.a)(a.trades)),strikePrices:t}}))},n.handleDelete=function(e){n.setState((function(t){return{trades:t.trades.filter((function(t){return t.id!==e.id})),strikePrices:t.strikePrices.filter((function(t){return t!==e.strikePrice}))}}))},n.calculateProfitLoss=function(e){},n.state={trades:[],strikePrices:[0]},n}return Object(m.a)(a,[{key:"render",value:function(){var e=this,t=this.state.trades,a=[],n=this.state.strikePrices,l=n[n.length-1]+1;n=[].concat(Object(u.a)(n),[l]);var i,c=Object(h.a)(n.entries());try{for(c.s();!(i=c.n()).done;){a=[O(Object(E.a)(i.value,2)[1],t)].concat(Object(u.a)(a))}}catch(k){c.e(k)}finally{c.f()}var o=a[0],s=a[1];a.shift();var m=0;m=o>s?Number.POSITIVE_INFINITY:Math.max.apply(null,a);var d=0,p=!1;o<s?(d=Number.NEGATIVE_INFINITY,p=!0):(d=Math.min.apply(null,a))<-1e4&&(p=!0);var g="",x="";return g=m<0?"-$"+Math.abs(m).toFixed(2):"$"+m.toFixed(2),x=d<0?"-$"+Math.abs(d).toFixed(2):"$"+d.toFixed(2),console.log(n),r.a.createElement(f.a,null,r.a.createElement(y.a,{style:{margin:"50px",minHeight:"480px"}},r.a.createElement(b.a,null,r.a.createElement(T,{onSubmit:this.addTrades})),r.a.createElement(b.a,null,r.a.createElement(v.a,null,r.a.createElement("tbody",null,t.map((function(t){return r.a.createElement("tr",{key:t.id},r.a.createElement("td",null,"$",t.strikePrice," ",t.tradeType),r.a.createElement("td",null,"Sell"===t.buySell?"-$"+t.price.toFixed(2):"$"+t.price.toFixed(2)),r.a.createElement("td",{style:j,onClick:function(){return e.handleDelete(t)}},"x"))})))),r.a.createElement(v.a,{style:{textAlign:"left"}},r.a.createElement("tbody",null,r.a.createElement("tr",null,r.a.createElement("td",null,"Max profit:"),r.a.createElement("td",null,g)),r.a.createElement("tr",null,r.a.createElement("td",null,"Max loss:"),r.a.createElement("td",null,x)))),p&&r.a.createElement("div",null,"Warning: system suggest not to trade. Exceed max loss of $10000."))))}}]),a}(n.Component),I={paddingTop:"30px",paddingBottom:"30px",color:"#fff",background:"#2e2e2e",textAlign:"left"};var F=function(){return r.a.createElement("footer",{style:I},r.a.createElement(f.a,null,r.a.createElement(y.a,null,r.a.createElement(b.a,{sm:"6"},"Copyright \xa9 2020 Tianning Li. All Rights Reserved."))))};var M=function(){return r.a.createElement("div",{className:"App"},r.a.createElement(o,null),r.a.createElement(w,null),r.a.createElement(F,null))};Boolean("localhost"===window.location.hostname||"[::1]"===window.location.hostname||window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/));i.a.render(r.a.createElement(r.a.StrictMode,null,r.a.createElement(M,null)),document.getElementById("root")),"serviceWorker"in navigator&&navigator.serviceWorker.ready.then((function(e){e.unregister()})).catch((function(e){console.error(e.message)}))}},[[25,1,2]]]);
//# sourceMappingURL=main.76fd2254.chunk.js.map