public ActionResult AddTradeDetails([FromBody] TradeDetails tradeDetails)
 {
     if (ModelState.IsValid)
     {
         _tradeServices.CreateTradeDetails(tradeDetails);
         return(new OkObjectResult(StatusCode(200)));
     }
     return(BadRequest());
 }
Example #2
0
        public TradeDetails PopluateTD(string TradedPairName, Leverage Ltype, decimal percent, decimal price)
        {
            TradeDetails y = new TradeDetails()
            {
                TradePairName = TradedPairName,
                //TimeTradeOpened = _KrakenUtils.MakeTrade(TradedPairName),
                //FailureLimitTimeSet = _KrakenUtils.MakeTrade(TradedPairName),
                //SuccessLimitTimeSet = _KrakenUtils.GetTradeDetails(),
                Direction = percent > 0 ? OrderSide.buy : OrderSide.sell,
                Leverage  = Ltype
            };

            return(y);
        }
 public ActionResult UpdateTradeDetails(long id, [FromBody] TradeDetails tradeDetails)
 {
     if (ModelState.IsValid)
     {
         TradeDetails model = _tradeServices.GetTradeDetailsById(id);
         model.Language     = tradeDetails.Language;
         model.LevelId      = tradeDetails.LevelId;
         model.Manager      = tradeDetails.Manager;
         model.PlanFile     = tradeDetails.PlanFile;
         model.SyllabusFile = tradeDetails.SyllabusFile;
         model.SyllabusName = tradeDetails.SyllabusName;
         model.TradeId      = tradeDetails.TradeId;
         _tradeServices.UpdateTradeDetails(model);
         return(new OkObjectResult(StatusCode(200)));
     }
     return(BadRequest());
 }
Example #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TradeDetailsViewModel" /> class.
        /// </summary>
        /// <param name="details">The details.</param>
        /// <param name="trackedItemIds">The tracked item ids.</param>
        /// <exception cref="System.ArgumentNullException">
        /// details
        /// or
        /// trackedItemIds
        /// </exception>
        public TradeDetailsViewModel(TradeDetails details, IEnumerable <int> trackedItemIds)
        {
            if (details == null)
            {
                throw new ArgumentNullException("details");
            }

            if (trackedItemIds == null)
            {
                throw new ArgumentNullException("trackedItemIds");
            }

            ItemId       = details.Item.Id;
            ItemName     = details.Item.Name;
            Quantity     = details.Quantity;
            IsTracked    = trackedItemIds.Contains(details.Item.Id);
            ItemCategory = details.Item.Details.Category;
        }
        public ActionResult <TradeDetails> GetTradeDetailsById(long id)
        {
            TradeDetails tradeDetails = _tradeServices.GetTradeDetailsById(id);

            tradeDetails.LanguageList = _tradeServices.GetLanguages().ToList();
            tradeDetails.TradeList    = _tradeServices.GetTrades().ToList();
            tradeDetails.LevelList    = tradeDetails.TradeList.Where(m => m.Id == tradeDetails.TradeId).FirstOrDefault().Level;
            string[] selectedlanguages = tradeDetails.Language.Split(',').ToArray();
            foreach (var language in tradeDetails.LanguageList)
            {
                foreach (var selectedlanguage in selectedlanguages)
                {
                    if (language.ShortName == selectedlanguage)
                    {
                        language.isCheck = true;
                    }
                }
            }

            return(tradeDetails);
        }
Example #6
0
        public void Dispose()
        {
            if (Commoditys != null)
            {
                Commoditys.Clear();
            }
            if (Users != null)
            {
                Users.Clear();
            }
            if (Accounts != null)
            {
                Accounts.Clear();
            }
            if (ClosedTradeDetails != null)
            {
                ClosedTradeDetails.Clear();
            }
            if (CommoditySummarizations != null)
            {
                CommoditySummarizations.Clear();
            }
            if (FundStatus != null)
            {
                FundStatus.Clear();
            }
            if (Parameters != null)
            {
                Parameters.Clear();
            }
            if (PositionDetails != null)
            {
                PositionDetails.Clear();
            }
            if (Positions != null)
            {
                Positions.Clear();
            }
            if (Remittances != null)
            {
                Remittances.Clear();
            }
            if (Stocks != null)
            {
                Stocks.Clear();
            }
            if (TradeDetails != null)
            {
                TradeDetails.Clear();
            }
            if (Trades != null)
            {
                Trades.Clear();
            }

            Commoditys              = null;
            Users                   = null;
            Accounts                = null;
            ClosedTradeDetails      = null;
            CommoditySummarizations = null;
            FundStatus              = null;
            Parameters              = null;
            PositionDetails         = null;
            Positions               = null;
            Remittances             = null;
            Stocks                  = null;
            TradeDetails            = null;
            Trades                  = null;
        }
Example #7
0
        public void Delete(DateTime dateTime, Guid accountId, params Type[] types)
        {
            foreach (var type in types)
            {
                SQLiteCommand cmd = null;

                if (type == typeof(Commodity))
                {
                    continue;
                }
                else if (type == typeof(User))
                {
                    continue;
                }
                else if (type == typeof(Account))
                {
                    continue;
                }
                else if (type == typeof(ClosedTradeDetail))
                {
                    string sql = "DELETE FROM ClosedTradeDetail WHERE AccountId=@AccountId AND ActualDate>=@Date";
                    cmd = new SQLiteCommand(sql);
                    ClosedTradeDetails.RemoveAll(m => m.AccountId == accountId && m.ActualDate >= dateTime.Date);
                }
                else if (type == typeof(CommoditySummarization))
                {
                    string sql = "DELETE FROM CommoditySummarization WHERE AccountId=@AccountId AND Date>=@Date";
                    cmd = new SQLiteCommand(sql);
                    CommoditySummarizations.RemoveAll(m => m.AccountId == accountId && m.Date >= dateTime.Date);
                }
                else if (type == typeof(FundStatus))
                {
                    string sql = "DELETE FROM FundStatus WHERE AccountId=@AccountId AND Date>=@Date";
                    cmd = new SQLiteCommand(sql);
                    FundStatus.RemoveAll(m => m.AccountId == accountId && m.Date >= dateTime.Date);
                }
                else if (type == typeof(Parameter))
                {
                    continue;
                }
                else if (type == typeof(PositionDetail))
                {
                    string sql = "DELETE FROM PositionDetail WHERE AccountId=@AccountId AND DateForPosition>=@Date";
                    cmd = new SQLiteCommand(sql);
                    PositionDetails.RemoveAll(m => m.AccountId == accountId && m.DateForPosition >= dateTime.Date);
                }
                else if (type == typeof(Position))
                {
                    string sql = "DELETE FROM Position WHERE AccountId=@AccountId AND Date>=@Date";
                    cmd = new SQLiteCommand(sql);
                    Positions.RemoveAll(m => m.AccountId == accountId && m.Date >= dateTime.Date);
                }
                else if (type == typeof(Remittance))
                {
                    string sql = "DELETE FROM Remittance WHERE AccountId=@AccountId AND Date>=@Date";
                    cmd = new SQLiteCommand(sql);
                    Remittances.RemoveAll(m => m.AccountId == accountId && m.Date >= dateTime.Date);
                }
                else if (type == typeof(Stock))
                {
                    string sql = "DELETE FROM Stock WHERE AccountId=@AccountId AND Date>=@Date";
                    cmd = new SQLiteCommand(sql);
                    Stocks.RemoveAll(m => m.AccountId == accountId && m.Date >= dateTime.Date);
                }
                else if (type == typeof(TradeDetail))
                {
                    string sql = "DELETE FROM TradeDetail WHERE AccountId=@AccountId AND ActualTime>=@Date";
                    cmd = new SQLiteCommand(sql);
                    TradeDetails.RemoveAll(m => m.AccountId == accountId && m.ActualTime >= dateTime.Date);
                }
                else if (type == typeof(Trade))
                {
                    string sql = "DELETE FROM Trade WHERE AccountId=@AccountId AND Date>=@Date";
                    cmd = new SQLiteCommand(sql);
                    Trades.RemoveAll(m => m.AccountId == accountId && m.Date >= dateTime.Date);
                }
                else
                {
                    continue;
                }
                cmd.Parameters.AddWithValue("@AccountId", accountId.ToString());
                cmd.Parameters.AddWithValue("@Date", dateTime.Date);
                cmds.Add(cmd);
            }
        }
Example #8
0
        public AddTradeView(InvestmentDataModel dataModel, IMarketDataSource marketDataSource, TradeDetails trade)
        {
            _marketDataSource = marketDataSource;
            _dataModel        = dataModel;
            InitializeComponent();

            _displayContext = SynchronizationContext.Current;

            //populate investment names combo
            cmboName.Items.AddRange(_dataModel.GetAllCompanies().ToArray());

            if (trade != null)
            {
                this.Text = "Edit Trade";
                dteTransactionDate.Value = DateTime.Now;
                cmboName.SelectedText    = trade.Name;
                cmboName.Text            = trade.Name;
                nmrcNumber.Value         = (decimal)trade.Quantity;
                nmrcScaling.Value        = (decimal)trade.ScalingFactor;
                txtSymbol.Text           = trade.Symbol;
                txtExchange.Text         = trade.Exchange;
                txtCcy.Text       = trade.Currency;
                txtTotalCost.Text = trade.TotalCost.ToString();
                cmboType.Items.AddRange(Enum.GetNames(typeof(TradeType)));
                cmboType.SelectedItem = trade.Action;
            }
            else
            {
                cmboType.Items.AddRange(Enum.GetNames(typeof(TradeType)));
            }
            btnCheck.Enabled = _marketDataSource != null;
        }
Example #9
0
 public void UpdateTradeDetails(TradeDetails tradeDetails)
 {
     _genericTradeDetailsRepo.Update(tradeDetails);
     _genericTradeDetailsRepo.Save();
 }