コード例 #1
0
        protected virtual void UpdateItemInfo(TriplePairArbitrageInfo info)
        {
            double             profit    = info.Profit;
            OperationDirection direction = info.Direction;

            info.Calculate();
            if (info.Profit != profit || direction != info.Direction)
            {
                StrategyData.Add(new TriplePairInfoHistoryItem(info));
                if (EnableNotifications)
                {
                    SendNotification("dir = " + info.Direction + " profit = " + info.Profit.ToString("0.########") + " disb = " + info.Disbalance.ToString("0.########"));
                }
            }
            if (!DemoMode && !ShouldProcessArbitrage && info.IsSelected)
            {
                ShouldProcessArbitrage = true;
                if (!info.MakeOperation())
                {
                    info.IsErrorState = true;
                    Log(LogType.Error, GetLogDescription(info, "arbitrage failed. resolve conflicts manually."), 0, 0, StrategyOperation.MarketBuy);
                }
                if (info.OperationExecuted)
                {
                    info.OperationExecuted = false;
                    Log(LogType.Error, GetLogDescription(info, "operation executed"), 0, 0, StrategyOperation.MarketBuy);
                }
                ShouldProcessArbitrage = false;
            }
            info.IsUpdating = false;
        }
コード例 #2
0
        protected override void OnTickCore()
        {
            if (!Enabled)
            {
                return;
            }
            for (int i = 0; i < Items.Count; i++)
            {
                if (ShouldProcessArbitrage)
                {
                    return;
                }

                TriplePairArbitrageInfo current = Items[i];
                current.DemoMode = DemoMode;

                if (current.IsUpdating)
                {
                    continue;
                }
                if (!current.ObtainingData)
                {
                    TickerCollectionUpdateHelper.Default.Update(current, this);
                    continue;
                }
            }
        }
コード例 #3
0
 async Task UpdateArbitrageInfoTask(TriplePairArbitrageInfo info)
 {
     Task task = Task.Factory.StartNew(() => {
         TickerCollectionUpdateHelper.Default.Update(info, this);
     });
     await task;
 }
コード例 #4
0
        private void bbShowHistory_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            TriplePairArbitrageInfo    info = (TriplePairArbitrageInfo)this.gridView1.GetFocusedRow();
            StaticArbitrageHistoryForm form = new StaticArbitrageHistoryForm();

            form.Info      = info;
            form.MdiParent = MdiParent;
            form.Show();
        }
コード例 #5
0
        void OnUpdateTickers()
        {
            timer.Start();
            long lastGUIUpdateTime = 0;

            while (true)
            {
                for (int i = 0; i < Items.Count; i++)
                {
                    if (ShouldProcessArbitrage)
                    {
                        Thread.Sleep(10);
                        continue;
                    }
                    if (timer.ElapsedMilliseconds - lastGUIUpdateTime > 2000)
                    {
                        lastGUIUpdateTime = timer.ElapsedMilliseconds;
                        if (IsHandleCreated)
                        {
                            BeginInvoke(new Action(RefreshGUI));
                        }
                    }
                    if (this.bbMonitorSelected.Checked && !Items[i].IsSelected)
                    {
                        continue;
                    }
                    TriplePairArbitrageInfo current = Items[i];
                    if (current.IsUpdating)
                    {
                        continue;
                    }
                    if (!current.ObtainingData)
                    {
                        TickerCollectionUpdateHelper.Default.Update(current, this);
                        continue;
                    }
                    int currentUpdateTimeMS = (int)(timer.ElapsedMilliseconds - current.StartUpdateMs);
                    if (currentUpdateTimeMS > current.NextOverdueMs)
                    {
                        current.UpdateTimeMs   = currentUpdateTimeMS;
                        current.IsActual       = false;
                        current.NextOverdueMs += 3000;
                        if (IsHandleCreated)
                        {
                            BeginInvoke(new Action <TriplePairArbitrageInfo>(RefreshGridRow), current);
                        }
                    }
                    continue;
                }
            }
        }
コード例 #6
0
 void IStaticArbitrageUpdateListener.OnUpdateInfo(TriplePairArbitrageInfo info, bool useInvokeForUI)
 {
     info.Calculate();
     if (!ShouldProcessArbitrage && info.IsSelected)
     {
         ShouldProcessArbitrage = true;
         if (!info.MakeOperation())
         {
             info.IsErrorState = true;
             XtraMessageBox.Show("Static Arbitrage Operation Failed. Resolve conflicts manually. " + info.Exchange + "-" + info.AltCoin + "-" + info.BaseCoin);
         }
         if (info.OperationExecuted)
         {
             info.OperationExecuted = false;
             BeginInvoke(new MethodInvoker(UpdateBalanceItems));
         }
         ShouldProcessArbitrage = false;
     }
     this.BeginInvoke(new Action <TriplePairArbitrageInfo>(RefreshGridRow), info);
     info.IsUpdating = false;
 }
コード例 #7
0
 protected string GetLogDescription(TriplePairArbitrageInfo info, string text)
 {
     return(text + ". " + info.Exchange + "-" + info.AltCoin + "-" + info.BaseCoin);
 }
コード例 #8
0
 void IStaticArbitrageUpdateListener.OnUpdateInfo(TriplePairArbitrageInfo info, bool useInvokeForUI)
 {
     UpdateItemInfo(info);
 }
コード例 #9
0
 public void RefreshGridRow(TriplePairArbitrageInfo info)
 {
     this.gridView1.RefreshRow(this.gridView1.GetRowHandle(Items.IndexOf(info)));
 }