Beispiel #1
0
        public AssetClassAccount Calculate(List <OpenPosition> listOfPosition)
        {
            AssetClassAccount acAcct = new AssetClassAccount();

            SortedList <string, PositionAmountPair> mapOfSecAmount = new SortedList <string, PositionAmountPair>();

            //acAcct.AccountId = accountId;

            double dBalance = ExtractSecurityAmount(listOfPosition, ref mapOfSecAmount);

            acAcct.Balance = dBalance;

            List <AssetClass> listOfAssetClass = _brokerMgrRepository.GetAssetClassification(false);

            //mapOfACSecurity = BuildACSecurityMap(listOfAssetClass);


            acAcct.ACPositions = new List <AssetClassPosition>();
            foreach (AssetClass assetObj in listOfAssetClass)
            {
                if (assetObj.AssetType == "O")
                {
                    continue;
                }

                string lGSecID     = assetObj.SecId;
                long   lPositionID = 0;
                double dPct        = 0.0;
                mapOfSecAmount.TryGetValue(lGSecID, out PositionAmountPair posAmtPair);
                if (posAmtPair != null)
                {
                    lPositionID = mapOfSecAmount[lGSecID].m_lPositionID;
                    if (dBalance > 0.0)
                    {
                        dPct = ((mapOfSecAmount[lGSecID].m_dAmount) / dBalance) * 100;
                    }
                }
                AssetClassPosition acPos = new AssetClassPosition();
                acPos.assetClass       = assetObj;
                acPos.Pct              = dPct;
                acPos.assetClass.SecId = lGSecID;
                acPos.PositionId       = lPositionID;
                acAcct.ACPositions.Add(acPos);
            }
            return(acAcct);
        }
Beispiel #2
0
        public void GetAssetClassification()
        {
            List <AssetClass> result = _brokerMgrRepository.GetAssetClassification(false);

            Assert.True(result.Count > 0);
        }