Esempio n. 1
0
        protected static void ProcessCSVForFullPandL()
        {
            string symbol       = ConfigurationManager.AppSettings["SymbolToConsider"];
            double currentPrice = Convert.ToDouble(ConfigurationManager.AppSettings["CurrentPrice"]);
            string csvFile      = ConfigurationManager.AppSettings["InputFile"];

            List <TradeDTO> trades = ExecutionsLoader.GetTrades(csvFile);

            PortfolioCalculator calc = new PortfolioCalculator();

            double profitsAndLosses = calc.CalculateTotalProfitsAndLosses(trades.Where(x => x.Symbol == symbol).OrderBy(x => x.Date).ToList(), currentPrice);

            //Aca intentamos hacer el testing

            Console.WriteLine(string.Format(" P&L for symbol {0}:{1}", symbol, profitsAndLosses));
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            string positionsCSV = ConfigurationManager.AppSettings["PositionsFile"];
            string tradesCSV    = ConfigurationManager.AppSettings["TodayTrades"];

            PositionsCSVDTO positionsDTO = PositionsLoader.GetPositions(positionsCSV);

            List <TradeDTO> todayTrades = ExecutionsLoader.GetTrades(tradesCSV);

            ILogSource Logger = new PerDayFileLogSource(Directory.GetCurrentDirectory() + "\\Log", Directory.GetCurrentDirectory() + "\\Log\\Backup")
            {
                FilePattern = "Log.{0:yyyy-MM-dd}.log",
                DeleteDays  = 20
            };


            MarginCollateralCalculator calc = new MarginCollateralCalculator(pSecurities: positionsDTO.GetSecurityMasterRecords(),
                                                                             pTodayDSPs: positionsDTO.GetTodayDailySettlementPrice(),
                                                                             pPrevDSPs: positionsDTO.GetYesterdayDailySettlementPrice(),
                                                                             pConfig: GetConfig(),
                                                                             pLogger: Logger);


            Console.WriteLine("===================== MARGIN/COLLATERAL grid ===================== ");
            foreach (string firm in positionsDTO.FirmPositions.Keys)
            {
                List <TradeDTO>     firmTrades       = todayTrades.Where(x => x.FirmId == firm).ToList();
                MarginCollateralDTO marginCollateral = calc.CalculateMargin(firmId: firm, todayCollateral: 0, todayPositions: positionsDTO.FirmPositions[firm], todayTrades: firmTrades);


                PrintMarginCollateral(marginCollateral);
            }



            Console.ReadKey();
        }