示例#1
0
 public TriplePairInfoHistoryItem(TriplePairArbitrageInfo info)
 {
     Disbalance    = info.Disbalance;
     Direction     = info.Direction;
     AltBasePrice  = info.AltBasePrice;
     AtlUsdtPrice  = info.AltUsdtPrice;
     BaseUsdtPrice = info.BaseUsdtPrice;
     Amount        = info.Amount;
     Profit        = info.Profit;
     Fee           = info.Fee;
     Time          = info.LastUpdate;
     UsdtBalance   = info.UsdtBalance;
     Earned        = info.LastEarned;
 }
        public async void Update(TriplePairArbitrageInfo info, IStaticArbitrageUpdateListener listener)
        {
            info.NextOverdueMs          = 6000;
            info.StartUpdateMs          = timer.ElapsedMilliseconds;
            info.ObtainingData          = true;
            info.ObtainDataSuccessCount = 0;
            info.ObtainDataCount        = 0;

            Task task = Task.Factory.StartNew(() => {
                if (info.AltBase.UpdateOrderBook())
                {
                    info.ObtainDataSuccessCount++;
                }
                info.ObtainDataCount++;
                if (info.AltUsdt.UpdateOrderBook())
                {
                    info.ObtainDataSuccessCount++;
                }
                info.ObtainDataCount++;
                if (info.BaseUsdt.UpdateOrderBook())
                {
                    info.ObtainDataSuccessCount++;
                }
                info.ObtainDataCount++;
            });

            await task;

            if (info.ObtainDataCount == info.Count)
            {
                info.IsActual      = info.ObtainDataSuccessCount == info.Count;
                info.IsUpdating    = true;
                info.ObtainingData = false;
                info.UpdateTimeMs  = (int)(timer.ElapsedMilliseconds - info.StartUpdateMs);
                if (listener != null)
                {
                    listener.OnUpdateInfo(info, true);
                }
            }
            info.LastUpdate = DateTime.UtcNow;
        }