Matriks Destek ve Yardım Platformu

Matriks Ürünleri ile ilgili tüm sorularınız için bizlere buradan ulaşabilirsiniz. Daha önce sorulan soruları ve verilen cevapları ilgili sekmelerden ve arama üzerinden inceleyebilirsiniz. Sağ taraftaki kategoriler üzerinden İlgilendiğiniz özelliklerle ilgili soruları filtreleyebilirsiniz. Soru ve cevapları sosyal medyada paylaşabilirsiniz. Sorduğunuz ve cevapladığınız soruların ve yorumlarınızın aldığı oylar üzerinden puan kazanırsınız. Puan sistemine bağlı kampanyamızla ücretsiz kullanım avantajlarından faydalanabilirsiniz.

0

Telegram da tek yönlü mesaj geliyor. Stop yada işlem kapanış mesajı gelmiyor.

Soruldu
Görüntülenme
483 görüntülenme
Durum
Cevaplandı
Merhaba,

Binance tarafında hem spot hem de vadeli piyasa da işlem açıyorum.
İşlem açıldığında belirlediğim şablon üzerinden mesaj geliyor yada stratejiyi durdurduğumda.
Lakin, işlem ters yönlü olarak kapandığında yada stop olduğunda herhangi bir bilgi gelmiyor mesaj olarak.

Aşağıda kısa bir örnek bırakıyorum.

 

 

 if (SendsTelegramNotifications)
            {
                string strategyName = this.GetType().Name;
                string message = $"Strateji Başlatıldı!\n" +
                                 $"Strateji: {strategyName}\n" +
                                 $"Sembol: {Symbol1}\n" +
                                 $"Periyot: {SymbolPeriod1}\n" +
                                 $"OTT Periyodu: {OttPeriod1}\n" +
                                 $"OTT Opt: {OttOpt1}";

                SendTelegramBot(message);
            }
        }

        public override void OnDataUpdate(BarDataEventArgs barData)
        {
            if (CrossAbove(ott, ott, 1, 0) && entryPrice == 0m)
            {
                entryPrice = GetLastPrice(Symbol1);
                totalQuantity = OrderQuantity1;
                entryValue = Math.Round(entryPrice * totalQuantity, 2);

                try
                {
                    SendMarketOrder(Symbol1, OrderQuantity1, OrderSide.Buy, includeAfterSession: false);
                    TrailingStopLoss(Symbol1, SyntheticOrderPriceType.Percent, StopLevel1, includeAfterSession: false);
                    StopLoss(Symbol1, SyntheticOrderPriceType.Percent, StopLevel2, includeAfterSession: false);

                    if (SendsTelegramNotifications)
                    {
                        SendTelegramMessage("İŞLEM AÇILDI", Symbol1, entryPrice, OrderQuantity1, entryValue, "Spot Long", OttMovMethod1.ToString());
                    }
                }
                catch (Exception ex)
                {
                    if (SendsTelegramNotifications)
                    {
                        SendTelegramBot($"Emir Gönderilirken Hata Oluştu:\n{ex.Message}");
                    }
                }
            }
        }

        public override void OnOrderUpdate(IOrder order)
        {
            if (order != null && SendsTelegramNotifications)
            {
                string orderStatus = order.OrdStatus?.ToString() ?? "Unknown";

                if (orderStatus == "Filled")
                {
                    decimal filledQty = order.FilledQty;
                    decimal currentPrice = GetLastPrice(order.Symbol);
                    decimal totalValue = Math.Round(filledQty * currentPrice, 2);

                    SendTelegramMessage("İŞLEM GERÇEKLEŞTİ", order.Symbol, currentPrice, filledQty, totalValue, "Spot Long", OttMovMethod1.ToString());
                }
                else if (orderStatus == "Closed" || orderStatus == "Cancelled")
                {
                    decimal exitPrice = GetLastPrice(order.Symbol);
                    decimal exitValue = Math.Round(exitPrice * totalQuantity, 2);
                    decimal profitLoss = exitValue - entryValue;
                    decimal profitLossPercent = Math.Round((profitLoss / entryValue) * 100, 2);

                    SendTelegramMessage("İŞLEM KAPANDI", order.Symbol, exitPrice, totalQuantity, exitValue, "Spot Long", OttMovMethod1.ToString());

                    string profitLossMessage = $"Kar/Zarar: {profitLoss} USD\n" +
                                                $"Kar/Zarar Yüzdesi: {profitLossPercent}%";
                    SendTelegramBot(profitLossMessage);

                    entryPrice = 0m;
                    entryValue = 0m;
                    totalQuantity = 0m;
                }
            }
        }

        public override void OnStopped()
        {
            if (SendsTelegramNotifications)
            {
                decimal exitPrice = GetLastPrice(Symbol1);
                decimal exitValue = Math.Round(exitPrice * totalQuantity, 2);
                decimal profitLoss = exitValue - entryValue;
                decimal profitLossPercent = Math.Round((profitLoss / entryValue) * 100, 2);

                string strategyName = this.GetType().Name;
                string message = $"Strateji Durduruldu!\n" +
                                 $"Strateji: {strategyName}\n" +
                                 $"Sembol: {Symbol1}\n" +
                                 $"Kar/Zarar: {profitLoss} USD\n" +
                                 $"Kar/Zarar Yüzdesi: {profitLossPercent}%\n" +
                                 

                SendTelegramBot(message);

                entryPrice = 0m;
                entryValue = 0m;
                totalQuantity = 0m;
            }
        }

        private void SendTelegramMessage(string title, string symbol, decimal currentPrice, decimal quantity, decimal totalValue, string marketType, string averageType)
        {
            string message = $"{title}\n" +
                             $"Sembol: {symbol}\n" +
                             $"Piyasa: {marketType}\n" +
                             $"Güncel Fiyat: {currentPrice} USD\n" +
                             $"Miktar: {quantity}\n" +
                             $"Toplam Değer: {totalValue} USD\n" +
                             $"Ortalama Türü: {averageType}";

            SendTelegramBot(message);
        }

        public decimal GetLastPrice(string symbol)
        {
            return 1.0m; // Geçici değer
        }
    }
}
Paylaş

1 Cevap

Cevabınız

Cevap yazmak için giriş yapın.Giriş yapKayıt ol