Ejemplo n.º 1
0
 public static decimal GetBalance(BotTabSimple tab)
 {
     if (tab.Connector.MyServer.ServerType == ServerType.Tester ||
         tab.Connector.MyServer.ServerType == ServerType.Optimizer)
     {
         if (tab.Portfolio.ValueBlocked != 0)
         {
             Console.WriteLine("Заблокировано " + tab.Portfolio.ValueBlocked);
         }
         return(tab.Portfolio.ValueCurrent);
     }
     if (tab.Connector.MyServer.ServerType == ServerType.BinanceFutures)
     {
         List <PositionOnBoard> bal = tab.Portfolio.GetPositionOnBoard();
         if (bal != null && bal.Count > 0)
         {
             PositionOnBoard b = bal.FindLast(x => x.SecurityNameCode == "USDT");
             if (b != null)
             {
                 return(b.ValueCurrent);
             }
         }
     }
     if (tab.Connector.MyServer.ServerType == ServerType.Binance)
     {
         List <PositionOnBoard> bal = tab.Portfolio.GetPositionOnBoard();
         if (bal != null && bal.Count > 0)
         {
             PositionOnBoard b = bal.FindLast(x => x.SecurityNameCode == tab.Securiti.NameClass);
             if (b != null)
             {
                 return(b.ValueCurrent);
             }
         }
     }
     if (tab.Connector.MyServer.ServerType == ServerType.GateIoFutures)
     {
         List <PositionOnBoard> bal = tab.Portfolio.GetPositionOnBoard();
         if (bal != null && bal.Count > 0)
         {
             PositionOnBoard b = bal.FindLast(x => x.SecurityNameCode == "USDT");
             if (b != null)
             {
                 return(b.ValueCurrent);
             }
         }
     }
     if (tab.Connector.MyServer.ServerType == ServerType.BitMex)
     {
         return(tab.Portfolio.ValueCurrent - tab.Portfolio.ValueBlocked);
     }
     return(0);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// обновить позицию по инструменту в торговой системе
        /// </summary>
        public void SetNewPosition(PositionOnBoard position)
        {
            if (_positionOnBoard != null && _positionOnBoard.Count != 0)
            {
                for (int i = 0; i < _positionOnBoard.Count; i++)
                {
                    if (_positionOnBoard[i].SecurityNameCode == position.SecurityNameCode)
                    {
                        _positionOnBoard[i] = position;
                        return;
                    }
                }
            }

            if (_positionOnBoard == null)
            {
                _positionOnBoard = new List <PositionOnBoard>();
            }

            _positionOnBoard.Add(position);
        }