opentrader
Version:
OpenTrader is a powerful open-source crypto trading bot designated to automate your trading strategies on various cryptocurrency exchanges.
2 lines (1 loc) • 3.06 kB
JavaScript
import{t as d,x as L,y as F,z as k,u as v,a as N,b as n,au as Q,c as D,d as T,av as z,e as R,m as w,aw as G,ax as q,ay as M,az as U,aA as H,aB as J,aC as K,aD as V,aE as W,aF as X,aG as Y,aH as Z,aI as _,aJ as $,aK as ee,aL as se,aM as te,aN as ae,aO as ne,aP as oe,j as s,G as l,E as ce,aQ as re,aR as S,r as ie,aS as de,aT as ue,aU as le,aV as ye,S as me,l as ge,aW as be,aX as he,aY as pe,k as xe,D as Se,aZ as fe,a_ as Ie}from"./index-Du-vO1Hr.js";function Pe(o){const[a]=d.dcaBot.getOne.useSuspenseQuery(o),[t]=d.exchangeAccount.getOne.useSuspenseQuery(a.exchangeAccountId),c=L(t.exchangeCode,k(a.symbol),F(a.symbol)),[r]=d.symbol.getOne.useSuspenseQuery({symbolId:c}),[u]=d.symbol.price.useSuspenseQuery({symbolId:r.symbolId});return{bot:a,exchangeAccount:t,symbol:r,currentPrice:u}}function je(){const{showSnackbar:o}=v(),a=N(),t=n(Q),{mutate:c,isLoading:r}=d.dcaBot.update.useMutation({onSuccess(e){o("Bot created successfully"),setTimeout(()=>{a({to:D("dca-bot/:id",e.id)})},1e3)}});return{isLoading:r,handleSubmit:()=>{const e=Be(t);c(e)}}}function Be(o){const{entryOrderType:a,entryOrderQuantity:t,entryConditions:c,takeProfitPercent:r,stopLossPercent:u,stopLossEnabled:e,safetyOrders:h,symbolId:m,exchangeAccountId:g,botName:y}=o,{currencyPairSymbol:b}=T(m);return{botId:o.botId,data:{name:y,settings:{entry:{type:a,quantity:Number(t),conditions:c},tp:{percent:r},sl:e?{percent:u}:void 0,safetyOrders:h},symbol:b,exchangeAccountId:g}}}function Oe(){var p,x;const{id:o}=z.useParams(),a=Number(o),{bot:t,exchangeAccount:c,symbol:r,currentPrice:u}=Pe(a),e=R();w()&&(e(G(t.id)),e(q(c.id)),e(M(c.exchangeCode)),e(U(r.symbolId)),e(H(t.name)),e(J(t.settings.entry.quantity.toString())),e(K(t.settings.entry.type)),e(V(t.settings.entry.conditions)),e(W(t.settings.tp.percent)),e(X(((p=t.settings.sl)==null?void 0:p.percent)||0)),e(Y(!!((x=t.settings.sl)!=null&&x.percent))),e(Z(t.settings.safetyOrders)));const m=n(_),[g]=d.exchangeAccount.getOne.useSuspenseQuery(m),y=n($),[b]=d.symbol.getOne.useSuspenseQuery({symbolId:y}),f=n(ee),I=n(se),P=i=>e(Ie(i)),j=n(te),B=n(ae),E=n(ne),O=n(oe),{handleSubmit:A,isLoading:C}=je();return s.jsx(l,{container:!0,spacing:2,children:s.jsxs(ce,{children:[s.jsx(l,{md:9,children:s.jsx(re,{barSize:I,defaultPrice:u,safetyOrders:j,takeProfitPercent:B,stopLossPercent:O?E:void 0,onBarSizeChange:P,symbolId:y})}),s.jsxs(l,{md:3,children:[s.jsx(S,{level:"h2",sx:{mb:1},children:"Bot settings"}),s.jsx(ie.Suspense,{fallback:s.jsx(me,{animation:"wave",height:300,sx:{borderRadius:8},variant:"rectangular",width:"100%"}),children:s.jsx(de,{hideTimeframe:!0,defaultBot:t,isLoading:C,onSubmit:A,botName:f,onBotNameChange:i=>e(ye(i)),exchangeAccount:g,onExchangeAccountChange:({id:i})=>e(le(i)),symbol:b,onSymbolChange:({symbolId:i})=>e(ue(i))})})]}),s.jsx(l,{md:9,children:s.jsxs(ge,{display:"flex",flexDirection:"column",gap:2,children:[s.jsx(be,{}),s.jsx(he,{}),s.jsx(pe,{}),s.jsxs(xe,{children:[s.jsx(S,{level:"title-lg",children:"Safety orders"}),s.jsx(Se,{}),s.jsx(fe,{})]})]})}),s.jsx(l,{md:3})]})})}export{Oe as default};