From 7404bdf0dcc56f6b8be94f5fb526bb8b621daead Mon Sep 17 00:00:00 2001 From: ying liu Date: Mon, 29 Jul 2024 12:42:15 +0800 Subject: [PATCH] mid price --- .gitignore | 4 +++- otp.png | Bin 2967 -> 3113 bytes pkg/strategy/ccinr/strategy.go | 18 +++++++++++++++--- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 0ca7bbe..12e7f95 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ .idea .vscode *.log -*.exe \ No newline at end of file +*.exe +qbtrade.yaml +*.png \ No newline at end of file diff --git a/otp.png b/otp.png index 171f58358f8cb56613df114b604c1f1e5c7065ed..54c6e89e3eda6830fb7e7b9ccc2779fc8745bc99 100644 GIT binary patch literal 3113 zcmai1eM}R18Xlm@S~ucHms|pf-s#cY^-Oh@<4a@}jmH6l5hJeUL+UBp6lhWU#S}zc z@3y+sbsOYETCzE%YmN`S!j>`}idYnIg$Q1O(xGex71~bukPcAVUj2VNn>?A!KW~2T zJiq6C-e)8yz~h@XhHeA^U{mtnj-CX7K;LU1u*LTTu3pc)005uPCm%h0N?3104;P)+ zgnaQT=DnMv+248sK>s0YbHqNqcAx%m`c|S)xNddmyg^6ZxHAmEwgMX{e&AxS59Q`6 z&3*aszpC;RCnUe0Ma@g^6K=OWUhKG2#s0QQj3+KEDfW5_Fkok@AK0Gmp6av8ieY8T z=^Ty|HYP0anTt04eRP1A-vBRmgmB#3H9-}71AZNkIH`fs`kK284JO$xqGeo6Eaptw ztj%L?xk5-+w>)-=(10&$fM3U$W%ra7OFQ!tnUo|5RQ&XvEw;ai-ACV3Aon2m6Cf|p z4|HE`<6cmreUfZ0JzHSF62#O-Pmw)G+z{`FE+37IdXkv+_c_C)8kIpXH8j1xM|%mS zn9WTT<)+&vSNtV{6U{XwaakrhKtcy1G^o-u7`GtGY=NxByVO43GRS*2o1%ts#kQ6TU&%) z$J6b=*JMA~qX^c19`ch*LyhddXnujQG-&)fn5sp(S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i`;OC`VY*o*gY+>c1^p0y=$Z^vTZM3@LdB5+ujl1 zJ3Pe&2cQA=%v!7upY>-~`Lk7mdUP~U@&%P!N8(z)ScJ{xpED7S_N@KtlX&ehMES5B z^HV`1wiynxxQ~;&c6LjO&6|BgOH*k*`@jPy&fCxNi)&64g0~dV8A|O*L4{!b6%AP_-PwMI-0*jYzZ>1lsBAd+F?DPgS4RJm8(GNy-S#B2IB*E=Yp3{%- zPoA~vsvWC{Zd}1DxAUeAc)R+9L05;?g 1 { qbtrade.Notify(fmt.Sprintf("交易信号未成交,取消订单: %s", symbol)) s.cancelOrders(ctx, symbol) } + + if s.TradeType[symbol] != "" && s.TradeRetry[symbol] <= 1 { + s.TradeRetry[symbol] = s.TradeRetry[symbol] + 1 + } } s.TradeKLine[symbol] = k } @@ -402,6 +411,7 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor qbtrade.OrderExecutor, log.Infof("the long order is filled: %+v,id is %d, symbol is %s, type is %s, status is %s", order, order.OrderID, orderSymbol, order.Type, order.Status) s.Traded[orderSymbol] = true + s.TradeRetry[orderSymbol] = 0 qbtrade.Notify("订单成交通知:\n 币种:%s, 方向:%s, 价格:%s, 数量:%s", order.Symbol, s.TradeType, order.Price, order.Quantity) } @@ -409,6 +419,7 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor qbtrade.OrderExecutor, log.Infof("the short order is filled: %+v,id is %d, symbol is %s, type is %s, status is %s", order, order.OrderID, orderSymbol, order.Type, order.Status) s.Traded[orderSymbol] = true + s.TradeRetry[orderSymbol] = 0 qbtrade.Notify("订单成交通知:\n 币种:%s, 方向:%s, 价格:%s, 数量:%s", order.Symbol, s.TradeType, order.Price, order.Quantity) } @@ -418,6 +429,7 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor qbtrade.OrderExecutor, "status is %s", order, order.OrderID, orderSymbol, order.Type, order.Status) qbtrade.Notify("订单止盈或止损通知:\n %s", order.Symbol) s.Traded[orderSymbol] = false + s.TradeRetry[orderSymbol] = 0 s.TradeType[orderSymbol] = "" } else { log.Infof("the order is: %+v,id is %d, symbol is %s, type is %s, status is %s",