Пример #1
0
        protected void LoadStockList(string[] portfolioCodes, data.tmpDS.portfolioListDataTable toTbl)
        {
            //Load stocks in portfolio
            data.baseDS.stockCodeExtDataTable myStockCodeTbl = new data.baseDS.stockCodeExtDataTable();
            dataLibs.LoadData(myStockCodeTbl, portfolioCodes);

            DataView myStockView = new DataView(myStockCodeTbl);

            data.baseDS.stockCodeExtRow stockRow;
            myStockView.Sort = myStockCodeTbl.codeColumn.ColumnName + "," + myStockCodeTbl.stockExchangeColumn.ColumnName;
            data.tmpDS.portfolioListRow reportRow;
            for (int idx1 = 0; idx1 < myStockView.Count; idx1++)
            {
                stockRow = (data.baseDS.stockCodeExtRow)myStockView[idx1].Row;
                //Ignore duplicate stocks
                reportRow = toTbl.FindBystockCode(stockRow.code);
                if (reportRow != null)
                {
                    continue;
                }
                reportRow = toTbl.NewportfolioListRow();
                dataLibs.InitData(reportRow);
                reportRow.stockCode   = stockRow.code;
                reportRow.stockExCode = stockRow.stockExchange;
                toTbl.AddportfolioListRow(reportRow);
            }
        }
Пример #2
0
        protected void UpdateRealTime(data.tmpDS.portfolioListDataTable reportTbl, string[] portfolioCodes)
        {
            DateTime onTime = application.sysLibs.GetServerDateTime();

            data.baseDS.priceDataRow    priceRow;
            data.tmpDS.portfolioListRow reportRow;
            decimal qty = 0, boughtAmt = 0;

            //Prepare data to get Alert sumary data in AlertSummaryInfo()
            data.baseDS.tradeAlertDataTable tradeAlertTbl = new data.baseDS.tradeAlertDataTable();
            for (int idx = 0; idx < portfolioCodes.Length; idx++)
            {
                dataLibs.LoadData(tradeAlertTbl, portfolioCodes[idx], onTime.Date, onTime, (byte)application.myTypes.commonStatus.New);
            }
            DataView tradeAlertView = new DataView(tradeAlertTbl);

            tradeAlertView.Sort = tradeAlertTbl.stockCodeColumn.ColumnName;
            for (int idx1 = 0; idx1 < reportTbl.Count; idx1++)
            {
                reportRow     = reportTbl[idx1];
                reportRow.qty = 0; reportRow.boughtAmt = 0;
                for (int idx2 = 0; idx2 < portfolioCodes.Length; idx2++)
                {
                    dataLibs.GetOwnStock(reportRow.stockCode, portfolioCodes[idx2], 0, onTime, out qty, out boughtAmt);
                    reportRow.qty += qty; reportRow.boughtAmt += boughtAmt;
                }
                reportRow.boughtPrice = (reportRow.qty == 0 ? 0 : reportRow.boughtAmt / reportRow.qty) / application.Settings.sysStockPriceWeight;

                priceRow                    = application.dataLibs.GetPriceData(onTime.Date, onTime, reportRow.stockCode);
                reportRow.price             = (priceRow == null ? 0 : priceRow.closePrice);
                reportRow.priceVariant      = (priceRow == null ? 0 : reportRow.price - priceRow.openPrice);
                reportRow.volume            = (priceRow == null ? 0 : priceRow.volume);
                reportRow.amt               = reportRow.qty * reportRow.price * application.Settings.sysStockPriceWeight;
                reportRow.profitVariantAmt  = reportRow.amt - reportRow.boughtAmt;
                reportRow.profitVariantPerc = (reportRow.boughtAmt == 0 ? 0 : reportRow.profitVariantAmt / reportRow.boughtAmt) * 100;

                //Alert summary info
                reportRow.notes = AlertSummaryInfo(reportRow.stockCode, tradeAlertView);
            }
        }
Пример #3
0
        protected void LoadStockList(data.tmpDS.portfolioListDataTable toTbl, string[] watchCodes)
        {
            //Load stocks in portfolio
            data.baseDS.stockCodeDataTable myStockCodeTbl = new data.baseDS.stockCodeDataTable();
            switch (watchListCb.WatchType)
            {
            case myTypes.portfolioType.Portfolio:
                dataLibs.LoadStockCode_ByPortfolios(myStockCodeTbl, common.system.List2Collection(watchCodes));
                break;

            case myTypes.portfolioType.WatchList:
                dataLibs.LoadStockCode_ByWatchList(myStockCodeTbl, common.system.List2Collection(watchCodes));
                break;

            default:
                common.system.ThrowException("Imvalid WatchType");
                break;
            }

            DataView myStockView = new DataView(myStockCodeTbl);

            data.baseDS.stockCodeRow stockRow;
            myStockView.Sort = myStockCodeTbl.codeColumn.ColumnName + "," + myStockCodeTbl.stockExchangeColumn.ColumnName;
            data.tmpDS.portfolioListRow reportRow;
            for (int idx1 = 0; idx1 < myStockView.Count; idx1++)
            {
                stockRow = (data.baseDS.stockCodeRow)myStockView[idx1].Row;
                //Ignore duplicate stocks
                reportRow = toTbl.FindBystockCode(stockRow.code);
                if (reportRow != null)
                {
                    continue;
                }
                reportRow = toTbl.NewportfolioListRow();
                dataLibs.InitData(reportRow);
                reportRow.stockCode   = stockRow.code;
                reportRow.stockExCode = stockRow.stockExchange;
                toTbl.AddportfolioListRow(reportRow);
            }
        }
Пример #4
0
 protected virtual void LoadData(data.tmpDS.portfolioListDataTable toTbl, string[] portfolioCodes)
 {
     LoadStockList(portfolioCodes, toTbl);
     UpdateRealTime(toTbl, portfolioCodes);
 }