Exemple #1
0
        private async Task <int> StartLoadHistory()
        {
            int result;
            var dateStart = DateConvert(GeneralSettingsView.DateStart);
            var dateEnd   = DateConvert(GeneralSettingsView.DateEnd);

            if (!isLoadAll)
            {
                if (!dateStart.HasValue)
                {
                    MessageBox.Show("Введена неверная стартовая дата.");
                    IsCheckedDownloadHistory = false;
                    return(-1);
                }
                if (!dateEnd.HasValue)
                {
                    MessageBox.Show("Введена неверная конечная дата.");
                    IsCheckedDownloadHistory = false;
                    return(-1);
                }
                if (dateStart.Value > dateEnd.Value)
                {
                    MessageBox.Show("Начальная дата больше конечной.");
                    IsCheckedDownloadHistory = false;
                    return(-1);
                }
                if (dateStart.Value > DateTime.Now)
                {
                    MessageBox.Show("Начальная дата: введена дата из будущего.");
                    IsCheckedDownloadHistory = false;
                    return(-1);
                }
                tradesHistory = new TradesHistory($"{GeneralSettingsView.BaseAsset}{GeneralSettingsView.QuoteAsset}", dateStart, dateEnd, tradeHistoryRepository);
            }
            else
            {
                tradesHistory = new TradesHistory($"{GeneralSettingsView.BaseAsset}{GeneralSettingsView.QuoteAsset}", null, null, tradeHistoryRepository);
            }

            tradesHistory.LoadStateEvent += TradesHistory_LoadStateEvent;
            result = await tradesHistory.Load();

            IsCheckedDownloadHistory = false;
            return(result);
        }
        /// <summary>
        /// This Function Will return the missing trades
        /// </summary>
        /// <param name="trade">trade</param>
        /// <param name="slavelist">slavelist</param>
        /// <returns>List of BOMAM Trade</returns>
        public List <BOMAMTrade> AddMissingOpenTrades(TradesHistory trade, List <R_AssetManager_IntroducingBroker_ClientAccount> slavelist)
        {
            try
            {
                var boMAMTradeList = new List <BOMAMTrade>();

                //Checking the Count
                if (slavelist.Count > 0)
                {
                    //Loop through all the slavelist and create missing trade
                    foreach (var item in slavelist)
                    {
                        var boMAMTrade = new BOMAMTrade()
                        {
                            OrderID            = (int)trade.OrderID,
                            FK_IBID            = (int)item.FK_IBID,
                            FK_ClientAccountID = (int)item.FK_ClientAccountID,
                            OpenPrice          = trade.OpenPrice,
                            ClosePrice         = trade.ClosePrice,
                            OpenTime           = trade.OpenTime,
                            CloseTime          = trade.CloseTime,
                            Symbol             = trade.Symbol,
                            Agent           = "",
                            LastIDProcessed = trade.PK_TradeID,
                            Size            = (double)trade.Volume * (double)item.AllocationRatio,
                            Swap            = trade.Storage * item.AllocationRatio,
                            Commission      = trade.Commission * item.AllocationRatio,
                            Pnl             = trade.Profit * item.AllocationRatio,
                            IsopenTrades    = false
                        };
                        boMAMTradeList.Add(boMAMTrade);
                    }
                }

                return(boMAMTradeList);
            }
            catch (Exception exceptionMessage)
            {
                CommonErrorLogger.CommonErrorLog(exceptionMessage, System.Reflection.MethodBase.GetCurrentMethod().Name);
                return(null);
            }
        }
Exemple #3
0
 public void Delete(TradesHistory entity)
 {
     Repository.Delete(entity);
 }
Exemple #4
0
 public void Add(TradesHistory entity)
 {
     Repository.Add(entity);
 }