Exemplo n.º 1
0
        /// <summary>
        /// Add cash
        /// </summary>
        /// <param name="quantfund"></param>
        /// <param name="currency"></param>
        /// <param name="cash"></param>
        /// <param name="settlementutc"></param>
        public void AddCash(CurrencyType currency, decimal cash, IQuantFund quantfund = null, DateTime?settlementutc = null)
        {
            //Get funds for quant fund
            CashPosition cashposition;

            if (quantfund == null)
            {
                cashposition = GetBaseAccount(currency);
            }
            else
            {
                //Check if we know this quant fund
                if (!_cashknown.ContainsKey(quantfund.FundId))
                {
                    _cashknown[quantfund.FundId] = new Dictionary <CurrencyType, CashPosition>();
                }

                //Check if we know this currency type
                if (!_cashknown[quantfund.FundId].TryGetValue(currency, out cashposition))
                {
                    cashposition = new CashPosition(currency, 0);
                    _cashknown[quantfund.FundId].Add(currency, cashposition);
                }
            }

            //Set items
            cashposition.AddCash(settlementutc.HasValue
                ? new UnsettledCash(cash, settlementutc.Value)
                : new SettledCash(cash));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets the base account cash position
        /// </summary>
        /// <param name="currency">The currency.</param>
        /// <returns></returns>
        private CashPosition GetBaseAccount(CurrencyType currency)
        {
            //See if this currency is known
            if (!_cashknown[BaseAccount].TryGetValue(currency, out CashPosition value))
            {
                value = new CashPosition(currency, 0);
                _cashknown[BaseAccount].Add(currency, value);
            }

            //Return value
            return(value);
        }