Esempio n. 1
0
 public static void InitData(data.baseDS.stockExchangeRow row)
 {
     row.code        = "";
     row.description = "";
     row.country     = "";
     row.weight      = 0;
 }
Esempio n. 2
0
 public static data.baseDS.stockExchangeRow UpdateData(data.baseDS.stockExchangeRow row)
 {
     data.baseDS.stockExchangeDataTable tbl = new data.baseDS.stockExchangeDataTable();
     tbl.ImportRow(row);
     myClient.UpdateStockExchange(ref tbl);
     row.AcceptChanges();
     return(tbl[0]);
 }
Esempio n. 3
0
 public static void InitData(data.baseDS.stockExchangeRow row)
 {
     row.code          = "";
     row.description   = "";
     row.country       = "";
     row.workTime      = "";
     row.holidays      = "";
     row.minBuySellDay = 0;
     row.tranFeePerc   = 0;
     row.priceRatio    = 1;
     row.volumeRatio   = 1;
     row.weight        = 0;
 }
Esempio n. 4
0
 // Stock Exchange
 public static data.baseDS.stockExchangeRow AddStockExchange(data.baseDS.stockExchangeDataTable tbl, string code)
 {
     data.baseDS.stockExchangeRow stockExchangeRow = application.SysLibs.FindAndCache_StockExchange(code);
     if (stockExchangeRow == null)
     {
         stockExchangeRow = tbl.NewstockExchangeRow();
         commonClass.AppLibs.InitData(stockExchangeRow);
         stockExchangeRow.code = code;
         tbl.AddstockExchangeRow(stockExchangeRow);
         application.DbAccess.UpdateData(stockExchangeRow);
         common.fileFuncs.WriteLog(" - Add stockExchange" + common.Consts.constTab + code);
     }
     return(stockExchangeRow);
 }
Esempio n. 5
0
 protected override void RemoveCurrent()
 {
     this.ShowMessage("");
     if (myMasterSource.Current == null)
     {
         return;
     }
     data.baseDS.stockExchangeRow row = (data.baseDS.stockExchangeRow)(myMasterSource.Current as DataRowView).Row;
     if (row.HasVersion(DataRowVersion.Original))
     {
         DataAccess.Libs.DeleteData(row);
     }
     myMasterSource.RemoveCurrent();
     this.ShowMessage(Languages.Libs.GetString("dataWasDeleted"));
 }
Esempio n. 6
0
        public override void AddNew(string code)
        {
            this.AddNewRow();
            data.baseDS.stockExchangeRow row = (data.baseDS.stockExchangeRow)((DataRowView)myMasterSource.Current).Row;
            if (row == null)
            {
                return;
            }
            commonClass.AppLibs.InitData(row);
            row.code = code;
            int position = myMasterSource.Position;

            myMasterSource.Position = -1;
            myMasterSource.Position = position;
        }
Esempio n. 7
0
 public bool GetTransactionInfo(ref TransactionInfo transInfo)
 {
     data.baseDS.priceDataRow     priceRow     = DbAccess.GetLastPriceData(transInfo.stockCode);
     data.baseDS.portfolioRow     portfolioRow = DbAccess.GetPortfolio(transInfo.portfolio);
     data.baseDS.stockExchangeRow marketRow    = application.AppLibs.GetStockExchange(transInfo.stockCode);
     if (priceRow == null || portfolioRow == null || marketRow == null)
     {
         return(false);
     }
     transInfo.price         = priceRow.closePrice;
     transInfo.priceDate     = priceRow.onDate;
     transInfo.availableCash = portfolioRow.startCapAmt - portfolioRow.usedCapAmt;
     transInfo.transFeePerc  = marketRow.tranFeePerc;
     transInfo.priceRatio    = marketRow.priceRatio;
     return(true);
 }
Esempio n. 8
0
 public static data.baseDS.stockExchangeRow FindAndCache_StockExchange(string code)
 {
     data.baseDS.stockExchangeRow row = myCachedDS.stockExchange.FindBycode(code);
     if (row != null)
     {
         return(row);
     }
     data.baseDSTableAdapters.stockExchangeTA dataTA = new data.baseDSTableAdapters.stockExchangeTA();
     dataTA.ClearBeforeFill = false;
     dataTA.Fill(myCachedDS.stockExchange);
     row = myCachedDS.stockExchange.FindBycode(code);
     if (row != null)
     {
         return(row);
     }
     return(null);
 }
Esempio n. 9
0
        public virtual void SetEditData(data.baseDS.tradeAlertRow row)
        {
            transCodeEd.Text = "";
            data.baseDS.stockExchangeRow stockExchangeRow = application.AppLibs.GetStockExchange(row.stockCode);
            if (stockExchangeRow != null)
            {
                feePercEd.Value = stockExchangeRow.tranFeePerc;
            }
            codeEd.Text         = row.stockCode;
            onTimeEd.myDateTime = row.onTime;
            portfolioCb.myValue = row.portfolio;
            qtyEd.Value         = 0; subTotalEd.Value = 0; feeAmtEd.Value = 0; totalAmtEd.Value = 0;
            transTypeCb.myValue = (AppTypes.TradeActions)row.tradeAction;
            statusCb.myValue    = AppTypes.CommonStatus.New;
            CalculatePriceAndFeePercentage();

            codeEd.Focus();
        }
Esempio n. 10
0
        public static bool GetOwnStock(string stockCode, string portfolio, int buySellInterval, DateTime sellDate,
                                       out decimal qty, out decimal buyAmt)
        {
            data.baseDS.stockExchangeRow marketRow = AppLibs.GetStockExchange(stockCode);
            qty = 0; buyAmt = 0;
            data.baseDS.investorStockDataTable dataTbl = new data.baseDS.investorStockDataTable();
            LoadData(dataTbl, stockCode, portfolio);
            if (dataTbl.Count == 0)
            {
                return(false);
            }
            DateTime applicableDate = sellDate.AddDays(-marketRow.minBuySellDay);

            for (int idx = 0; idx < dataTbl.Count; idx++)
            {
                if (dataTbl[idx].buyDate > applicableDate)
                {
                    continue;
                }
                qty    += dataTbl[idx].qty;
                buyAmt += dataTbl[idx].buyAmt;
            }
            return(true);
        }
Esempio n. 11
0
 public static void DeleteData(data.baseDS.stockExchangeRow row)
 {
     myClient.DeleteStockExchange(row.code);
 }
Esempio n. 12
0
        /// <summary>
        /// Create alerts for all stock in portfolio
        /// </summary>
        /// <param name="alertList"> all alert resulted from analysis </param>
        private static void CreateTradeAlert(TradeAlert[] alertList)
        {
            decimal          availabeQty;
            string           msg;
            StringCollection timeScaleList;

            data.baseDS.tradeAlertRow            tradeAlertRow;
            data.baseDS.tradeAlertDataTable      tradeAlertTbl      = new data.baseDS.tradeAlertDataTable();
            data.baseDS.portfolioDetailDataTable portfolioDetailTbl = application.DbAccess.GetPortfolioDetail_ByType(new AppTypes.PortfolioTypes[] { AppTypes.PortfolioTypes.WatchList, AppTypes.PortfolioTypes.Portfolio });
            DataView portfolioDetailView = new DataView(portfolioDetailTbl);

            //Sort by  Stock code + Strategy code
            portfolioDetailView.Sort = portfolioDetailTbl.codeColumn.ColumnName + "," + portfolioDetailTbl.subCodeColumn.ColumnName;
            DataRowView[] portfolioDetailFound;
            data.baseDS.portfolioDetailRow portfolioDataRow;

            // Only alert on stock codes that were selected by user.
            for (int alertId = 0; alertId < alertList.Length; alertId++)
            {
                // Check if alert's strategy in user's wish list ??
                portfolioDetailFound = portfolioDetailView.FindRows(new object[] { alertList[alertId].StockCode, alertList[alertId].Strategy.Trim() });
                for (int dataIdx = 0; dataIdx < portfolioDetailFound.Length; dataIdx++)
                {
                    // Check if time alert's time scale in user's wish list ??
                    portfolioDataRow = ((data.baseDS.portfolioDetailRow)portfolioDetailFound[dataIdx].Row);
                    timeScaleList    = common.MultiValueString.String2List(portfolioDataRow.data.Trim());
                    if (!timeScaleList.Contains(alertList[alertId].TimeScale.Code))
                    {
                        continue;
                    }

                    //Ignore duplicate alerts.
                    tradeAlertRow = application.DbAccess.GetAlert(alertList[alertId].OnDateTime,
                                                                  portfolioDataRow.portfolio,
                                                                  alertList[alertId].StockCode,
                                                                  alertList[alertId].Strategy,
                                                                  alertList[alertId].TimeScale.Code,
                                                                  AppTypes.CommonStatus.All);
                    if (tradeAlertRow != null)
                    {
                        continue;
                    }

                    //Availabe stock
                    if (withAplicableCheckInAlert)
                    {
                        data.baseDS.stockExchangeRow stockExchangeRow = application.AppLibs.GetStockExchange(alertList[alertId].StockCode);
                        int sell2BuyInterval = (stockExchangeRow == null?0:stockExchangeRow.minBuySellDay);
                        availabeQty = application.DbAccess.GetAvailableStock(alertList[alertId].StockCode, portfolioDataRow.portfolio,
                                                                             sell2BuyInterval, alertList[alertId].OnDateTime);
                    }
                    else
                    {
                        availabeQty = 0;
                    }

                    //Aplicable to sell
                    if ((alertList[alertId].TradePoint.TradeAction == AppTypes.TradeActions.Sell ||
                         alertList[alertId].TradePoint.TradeAction == AppTypes.TradeActions.ClearAll) && (availabeQty <= 0))
                    {
                        continue;
                    }

                    string infoText = alertList[alertId].TradePoint.BusinessInfo.ToText().Trim();
                    infoText = (infoText != "" ? infoText : common.Consts.constNotAvailable);

                    //Create alert template message, AlertMessageText() will convert it to specified-language text.
                    msg = commonClass.Consts.constTextMergeMarkerLEFT + "price" + commonClass.Consts.constTextMergeMarkerRIGHT + " : " + alertList[alertId].Price.ToString() + common.Consts.constCRLF +
                          commonClass.Consts.constTextMergeMarkerLEFT + "volume" + commonClass.Consts.constTextMergeMarkerRIGHT + " : " + alertList[alertId].Volume.ToString() + common.Consts.constCRLF +
                          commonClass.Consts.constTextMergeMarkerLEFT + "marketInfo" + commonClass.Consts.constTextMergeMarkerRIGHT + " : " + infoText + common.Consts.constCRLF;
                    if (availabeQty > 0)
                    {
                        msg += commonClass.Consts.constTextMergeMarkerLEFT + "ownedQty" + commonClass.Consts.constTextMergeMarkerRIGHT + " : " + availabeQty.ToString() + common.Consts.constCRLF;
                    }

                    CreateTradeAlert(tradeAlertTbl, portfolioDataRow.portfolio, alertList[alertId].StockCode, alertList[alertId].Strategy,
                                     alertList[alertId].TimeScale, alertList[alertId].TradePoint, alertList[alertId].OnDateTime, msg);
                }
            }
            application.DbAccess.UpdateData(tradeAlertTbl);
        }
Esempio n. 13
0
 public static void UpdateData(data.baseDS.stockExchangeRow data)
 {
     stockExchangeTA.Update(data);
     data.AcceptChanges();
 }