UNPKG

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) 2.88 kB
import{d as G,u as F,a as I,b as c,t as l,c as C,j as s,B as w,C as L,e as S,f as d,s as f,g as P,h as j,i as Q,k as A,r as p,S as v,D as k,l as N,G as u,m as D,n as z,o as E,p as T,q as O,v as R,E as q,w as W}from"./index-Du-vO1Hr.js";import{s as H,a as B,b as M,c as U,d as J,e as K,f as V,F as X,S as Y,A as Z,I as _,g as $,B as ss,h as es,i as ts,G as is}from"./SimpleGridForm-CGmW235V.js";function rs(r){const{gridLines:n,symbolId:t,exchangeAccountId:i,botName:a}=r,{currencyPairSymbol:e}=G(t);return{exchangeAccountId:i,data:{name:a,settings:{gridLines:n},symbol:e}}}const ns=()=>{const{showSnackbar:r}=F(),n=I(),t=c(H),{mutate:i,isLoading:a}=l.gridBot.create.useMutation({onSuccess(o){r("Bot created successfully"),setTimeout(()=>{n({to:C("grid-bot/:id",o.id)})},1e3)}}),e=()=>{const o=rs(t);i(o)};return s.jsx(w,{color:"primary",disabled:a,onClick:e,startDecorator:a?s.jsx(L,{size:"md"}):null,type:"submit",variant:"outlined",children:"Create"})},as=()=>{var h;const r=S(),n=c(B),{data:t}=l.symbol.getOne.useQuery({symbolId:n},{refetchOnWindowFocus:!1});if(d(t)&&t){const x=((h=t.filters.limits.amount)!=null&&h.min?t.filters.limits.amount.min*10:"").toString()||"";r(f(x))}const{data:i}=l.gridBot.formOptions.useQuery({symbolId:n},{refetchOnWindowFocus:!1});d(i)&&i&&(r(P(i.highPrice)),r(j(i.lowPrice)));const a=c(M),e=c(U),o=c(J),m=c(K);if([d(a),d(e),d(o),d(m),d(t)].includes(!0)&&t){const g=V(a,e,o,Number(m),t.filters);r(Q(g))}return s.jsxs(A,{sx:{padding:0},children:[s.jsx(X,{advancedForm:s.jsx(p.Suspense,{fallback:s.jsx(v,{height:60,variant:"rectangular",width:"100%"}),children:s.jsx(Z,{})}),simpleForm:s.jsx(Y,{})}),s.jsx(k,{}),s.jsx(N,{sx:{px:2,pt:1,pb:2},children:s.jsxs(u,{container:!0,spacing:2,children:[s.jsx(u,{xs:12,children:s.jsx(p.Suspense,{fallback:s.jsx($,{withLabel:!0}),children:s.jsx(_,{})})}),s.jsx(u,{xs:12,children:s.jsx(ss,{})}),s.jsx(u,{xs:12,children:s.jsx(ns,{})})]})})]})};function os(){const[r]=l.exchangeAccount.list.useSuspenseQuery(),n=r[0],[t]=l.symbol.list.useSuspenseQuery(n.exchangeCode),i=t.find(m=>m.currencyPair==="BTC/USDT")||t[0],[a]=l.symbol.price.useSuspenseQuery({symbolId:i.symbolId}),[{lowPrice:e,highPrice:o}]=l.gridBot.formOptions.useSuspenseQuery({symbolId:i.symbolId});return{exchangeAccount:n,symbol:i,currentPrice:a,lowPrice:e,highPrice:o}}function ls(){var x;const{exchangeAccount:r,symbol:n,lowPrice:t,highPrice:i,currentPrice:a}=os(),e=S();if(D()){const b=(x=n.filters.limits.amount)!=null&&x.min?n.filters.limits.amount.min*10:"";e(z(r.id)),e(E(r.exchangeCode)),e(T(n.symbolId)),e(f(b.toString()||"")),e(j(t)),e(P(i)),e(O(R()))}const m=c(B),y=c(es),h=b=>e(W(b)),g=c(ts);return s.jsx(u,{container:!0,spacing:2,children:s.jsxs(q,{children:[s.jsx(u,{md:9,children:s.jsx(is,{barSize:y,defaultPrice:a,gridLines:g,onBarSizeChange:h,symbolId:m})}),s.jsx(u,{md:3,children:s.jsx(as,{})})]})})}export{ls as default};