Example #1
0
 public static void LoadInvestor(databases.tmpDS.investorDataTable tbl, bool force)
 {
     if (force) tbl.Clear();
     if (tbl.Count > 0) return;
     databases.tmpDS.investorDataTable newTbl = Libs.GetInvestorShortList();
     if (newTbl != null) common.system.Concat(newTbl, 0, tbl);
 }
Example #2
0
 //Add to database
 private void ImportICB_AddToDb(databases.importDS.icbCodeDataTable tbl, string fldName, bool haveDefitionFld, 
                                       databases.baseDS.sysCodeDataTable sysCodeTbl,string category,string codeGroupFldName)
 {
     databases.baseDS.sysCodeRow sysCodeRow;
     common.myKeyValueItem item;
     for (int idx = 0; idx < tbl.Count; idx++)
     {
         if (tbl[idx].RowState == DataRowState.Deleted) continue;
         item = Imports.Libs.SplitKeyValue(tbl[idx][fldName].ToString(), " ");
         if (item == null)
         {
             common.SysLog.WriteLog(tbl[idx][fldName].ToString() + " not found.");
             continue;
         }
         if (sysCodeTbl.FindBycategorycode(category, item.Key) == null)
         {
             sysCodeRow = sysCodeTbl.NewsysCodeRow();
             databases.AppLibs.InitData(sysCodeRow);
             sysCodeRow.category = category;
             sysCodeRow.code = item.Key;
             sysCodeRow.description1 = item.Value;
             sysCodeRow.tag1 = fldName;
             if (codeGroupFldName != null) sysCodeRow.inGroup = tbl[idx][codeGroupFldName].ToString();
             if (haveDefitionFld && !tbl[idx].IsdefinitionNull()) sysCodeRow.notes = tbl[idx].definition;
             sysCodeTbl.AddsysCodeRow(sysCodeRow);
         }
         tbl[idx][fldName] = item.Key;
     }
 }
Example #3
0
 public bool IsSameData(databases.importDS.importPriceRow row1, databases.importDS.importPriceRow row2)
 {
     if (row1==null && row2==null) return false;
     if (row1 == null && row2 != null) return false;
     if (row1 != null && row2 == null) return false;
     return  (row1.closePrice == row2.closePrice) &&(row1.volume == row2.volume);
 }
Example #4
0
 public static void InitData(databases.baseDS.sysCodeCatRow row)
 {
     row.category = "";
     row.description = "";
     row.isSystem = false;
     row.isVisible = true;
 }
Example #5
0
        //Database Name contructor = 1
        public dataBase(databases Database, string DatabaseName)
        {
            this.Database     = Database;
            this.DatabaseName = DatabaseName;

            SelectedDatabase = Database.ToString();
        }
Example #6
0
 public static void InitData(databases.importDS.importPriceRow row)
 {
     row.onDate = common.Consts.constNullDate;
     row.stockCode = "";
     row.closePrice = 0;
     row.volume = 0;
     row.isTotalVolume = false;
 }
 private void DeletePortfolioData(databases.baseDS.portfolioDetailDataTable dataTbl, string portfolioCode,string code)
 {
     for (int idx = 0; idx < dataTbl.Count; idx++)
     {
         if (dataTbl[idx].RowState== DataRowState.Deleted) continue;
         if ( (dataTbl[idx].portfolio==portfolioCode) && (dataTbl[idx].code==code) ) 
             dataTbl[idx].Delete();
     }
 }
Example #8
0
        //Full data constructor = 0
        public dataBase(databases Database, string DatabaseName, string UserName, string Password, string Host)
        {
            this.Database     = Database;
            this.DatabaseName = DatabaseName;
            this.Host         = Host;
            this.UserName     = UserName;
            this.Password     = Password;

            SelectedDatabase = Database.ToString();
        }
Example #9
0
 public void Diagnose(string exchangeCode,commonTypes.AppTypes.PriceDataType dataType, double allowVariantPerc, ref databases.tmpDS.priceDiagnoseDataTable priceDiagnoseTbl)
 { 
     databases.tmpDS.stockCodeDataTable codeTbl = new databases.tmpDS.stockCodeDataTable();
     databases.DbAccess.LoadStockCode_ByStockExchange(codeTbl, exchangeCode, AppTypes.CommonStatus.Enable);
     for (int idx = 0; idx < codeTbl.Count; idx++)
     { 
         //Diagnose(dataType,allowVariantPerc, ref databases.tmpDS.priceDiagnoseDataTable priceDiagnoseTbl)
     }
     
 }
Example #10
0
        public virtual bool ImportFromWeb(DateTime updateTime, databases.baseDS.exchangeDetailRow exchangeDetailRow)
        {
            databases.baseDS.priceDataDataTable priceTbl = GetImportFromWeb(updateTime, exchangeDetailRow);
            if (priceTbl == null) return false;

            // Different culture has different start of week, ie in VN culture : start of week is Monday (not Sunday) 
            CultureInfo exchangeCulture = application.AppLibs.GetExchangeCulture(exchangeDetailRow.marketCode);
            databases.AppLibs.AggregatePriceData(priceTbl, exchangeCulture, null);
            return true;
        }
Example #11
0
        /// <summary>
        /// Private - SU dung ASPWebservices
        /// </summary>
        /// <param name="updateTime"></param>
        /// <param name="exchangeDetailRow"></param>
        /// <returns></returns>
        private databases.importDS.importPriceDataTable GetPriceFromWeb(DateTime updateTime, databases.baseDS.exchangeDetailRow exchangeDetailRow)
        {
            try
            {
                databases.importDS.importPriceDataTable importPriceTbl = new databases.importDS.importPriceDataTable();

                if (ssiPage==null)
                    ssiPage = new SSIPage("http://banggia2.ssi.com.vn/", "http://banggia2.ssi.com.vn/Hnx.aspx");
                    //ssiPage = new SSIPage("file:///C:/Temp/selenium/HOSE%20-%20CTCP%20ch%E1%BB%A9ng%20kho%C3%A1n%20S%C3%A0i%20G%C3%B2n%20-%20B%E1%BA%A3ng%20gi%C3%A1%20tr%E1%BB%B1c%20tuy%E1%BA%BFn.html", "file:///C:/Temp/selenium/HNX%20-%20CTCP%20ch%E1%BB%A9ng%20kho%C3%A1n%20S%C3%A0i%20G%C3%B2n%20-%20B%E1%BA%A3ng%20gi%C3%A1%20tr%E1%BB%B1c%20tuy%E1%BA%BFn.html");

                ssiPage.getHOSEData();
                ssiPage.getHNXData();
                //SaveDatatoImportPriceDataTable(updateTime,importPriceTbl);
                databases.importDS.importPriceRow importRow = null;
                databases.importDS.importPriceRow oldImportRow;

                foreach (var stock in ssiPage.dictStocks)
                {
                    importRow = importPriceTbl.NewimportPriceRow();
                    databases.AppLibs.InitData(importRow);
                    importRow.onDate = updateTime;
                    importRow.stockCode = stock.Key;
                    //Doi de fix error #136 - Lỗi cập nhật HNX
                    //importRow.isTotalVolume = true;
                    importRow.isTotalVolume = false;

                    importRow.closePrice=(decimal)stock.Value.price;

                    //Doi de fix error #136 - Lỗi cập nhật HNX
                    //importRow.volume = (decimal)stock.Value.totalVolume;
                    importRow.volume = (decimal)stock.Value.actualVolume;

                    //Doi de fix error #136 - Lỗi cập nhật HNX
                    if (importRow.closePrice > 0)
                    {
                        //Only add new when there are some changes
                        oldImportRow = lastImportData.Find(importRow);
                        if (!lastImportData.IsSameData(importRow, oldImportRow))
                        {
                            importPriceTbl.AddimportPriceRow(importRow);
                            lastImportData.Update(importRow);
                        }
                        else importRow.CancelEdit();
                    }
                    else importRow.CancelEdit();
                }

                return importPriceTbl;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            return null;
        }
Example #12
0
 public static DataBars GetData(databases.baseDS.priceDataDataTable dataTbl, int startIdx)
 {
     DataBars bars = new DataBars();
     for (int idx = startIdx; idx < dataTbl.Count; idx++)
     {
         bars.Add((double)dataTbl[idx].openPrice, (double)dataTbl[idx].highPrice,
                  (double)dataTbl[idx].lowPrice, (double)dataTbl[idx].closePrice,
                  (double)dataTbl[idx].volume, dataTbl[idx].onDate.ToOADate());
     }
     return bars;
 }
 //Detect new stockCode and create new one
 public static void AddNewCode(string market, databases.importDS.importPriceDataTable tbl, OnCodeAdded onAddstockCodeFunc)
 {
     databases.baseDS.stockCodeDataTable stockCodeTbl = new databases.baseDS.stockCodeDataTable();
     for (int count = 0; count < tbl.Count; count++)
     {
         if (tbl[count].RowState == DataRowState.Deleted) continue;
         if (AddNewCode(tbl[count].stockCode, market, stockCodeTbl) != null &&
             onAddstockCodeFunc != null) onAddstockCodeFunc(tbl[count].stockCode);
     }
     databases.DbAccess.UpdateData(stockCodeTbl);
 }
Example #14
0
        /// <summary>
        /// Override method - /// Import stock data of HOSE and HASTC from  http://banggia.ssi.com.vn/AjaxWebService.asmx
        /// </summary>
        /// <param name="updateTime"></param>
        /// <param name="exchangeDetailRow"></param>
        /// <returns></returns>
        public override databases.baseDS.priceDataDataTable GetImportFromWeb(DateTime updateTime, databases.baseDS.exchangeDetailRow exchangeDetailRow)
        {
            databases.importDS.importPriceDataTable importPriceTbl = GetPriceFromWeb(updateTime, exchangeDetailRow);
            if (importPriceTbl == null) return null;

            Imports.Libs.AddNewCode(exchangeDetailRow.marketCode, importPriceTbl, null);
            databases.DbAccess.UpdateData(importPriceTbl);
            databases.baseDS.priceDataDataTable priceTbl = new databases.baseDS.priceDataDataTable();
            Imports.Libs.AddImportPrice(importPriceTbl, priceTbl);
            databases.DbAccess.UpdateData(priceTbl);
            return priceTbl;
        }
Example #15
0
 public static databases.tmpDS.investorRow FindAndCache(databases.tmpDS.investorDataTable tbl, string code)
 {
     databases.tmpDS.investorRow row = tbl.FindBycode(code);
     if (row != null) return row;
     if (tbl.Count == 0)
     {
         LoadInvestor(tbl, false);
         row = tbl.FindBycode(code);
         if (row != null) return row;
     }
     return null;
 }
Example #16
0
        public static double[] GetDataList(databases.baseDS.priceDataDataTable dataTbl, int startIdx,int endIdx,AppTypes.PriceDataType type)
        {
            double[] data = new double[endIdx - startIdx+1];
            switch (type)
            {
                case AppTypes.PriceDataType.High:
                    for (int i = startIdx, j = 0; i <= endIdx; i++, j++)
                    {
                        if (dataTbl[i].RowState == System.Data.DataRowState.Deleted) continue;
                        data[j] = (double)dataTbl[i].highPrice;
                    }
                    break;
                case AppTypes.PriceDataType.Low:
                    for (int i = startIdx, j = 0; i <=endIdx; i++, j++)
                    {
                        if (dataTbl[i].RowState == System.Data.DataRowState.Deleted) continue;
                        data[j] = (double)dataTbl[i].lowPrice;
                    }
                    break;
                case AppTypes.PriceDataType.Open:
                    for (int i = startIdx, j = 0; i <= endIdx; i++, j++)
                    {
                        if (dataTbl[i].RowState == System.Data.DataRowState.Deleted) continue;
                        data[j] = (double)dataTbl[i].openPrice;
                    }
                    break;
                case AppTypes.PriceDataType.Close:
                    for (int i = startIdx, j = 0; i <= endIdx; i++, j++)
                    {
                        if (dataTbl[i].RowState == System.Data.DataRowState.Deleted) continue;
                        data[j] = (double)dataTbl[i].closePrice;
                    }
                    break;
                case AppTypes.PriceDataType.Volume:
                    for (int i = startIdx, j = 0; i <= endIdx; i++, j++)
                    {
                        if (dataTbl[i].RowState == System.Data.DataRowState.Deleted) continue;
                        data[j] = (double)dataTbl[i].volume;
                    }
                    break;

                case AppTypes.PriceDataType.DateTime:
                    for (int i = startIdx, j = 0; i <= endIdx; i++, j++)
                    {
                        if (dataTbl[i].RowState == System.Data.DataRowState.Deleted) continue;
                        data[j] = dataTbl[i].onDate.ToOADate();
                    }
                    break;
                default:
                    common.system.ThrowException("Invalid dataField in MakeDataList()"); break;
            }
            return data;
        }
 public bool ShowNew(databases.baseDS.tradeAlertRow alertRow)
 {
     this.Refresh();
     qtyEd.Value = 0; subTotalEd.Value = 0; feeAmtEd.Value = 0; totalAmtEd.Value = 0;
     portfolioCb.myValue  = alertRow.portfolio;
     codeEd.Text = alertRow.stockCode.Trim();
     transTypeCb.myValue = (AppTypes.TradeActions)alertRow.tradeAction;
     statusCb.myValue = AppTypes.CommonStatus.New;
     SetFocus();
     ShowDialog();
     return true;
 }
Example #18
0
 protected void ShowTradeTransactions(databases.tmpDS.stockCodeRow stockCodeRow, string strategyCode, DataParams dataParam)
 {
     string formName = stockCodeRow.code.Trim() + "," + dataParam.TimeRange.ToString() + "," + application.Strategy.StrategyLibs.GetMetaName(strategyCode) + "," + dataParam.TimeScale;
     profitEstimate myForm = profitEstimate.GetForm(formName);
     myForm.myDataParam = dataParam;
     myForm.myStockCode = stockCodeRow.code;
     myForm.myStrategyCode = strategyCode;
     myForm.myOptions = new EstimateOptions();
     myForm.ReLoad();
     myForm.Text = "(" + formName + ")";
     if (this.myDockedPane != null) myForm.Show(this.myDockedPane);
     else myForm.ShowDialog();
 }
Example #19
0
 private static commonClass.DataSeries MakeData(databases.tmpDS.marketDataDataTable dataTbl, DataFields type)
 {
     commonClass.DataSeries ds = new commonClass.DataSeries();
     switch (type)
     {
         case DataFields.Count:
             for (int idx = 0; idx < dataTbl.Count; idx++) ds.Add(dataTbl[idx].val0); break;
         case DataFields.Volume:
             for (int idx = 0; idx < dataTbl.Count; idx++) ds.Add(dataTbl[idx].val1); break;
         case DataFields.DateTime:
             for (int idx = 0; idx < dataTbl.Count; idx++) ds.Add(dataTbl[idx].onDate.ToOADate()); break;
     }
     return ds;
 }
Example #20
0
        public override databases.baseDS.priceDataDataTable GetImportFromWeb(DateTime updateTime, databases.baseDS.exchangeDetailRow exchangeDetailRow)
        {
            if (!Get_IDX_HASTC(exchangeDetailRow.address, ref hastcIdx)) return null;
            databases.importDS.importPriceDataTable importPriceTbl = new databases.importDS.importPriceDataTable();
            AddImportRow(updateTime, hastcIdx, true, importPriceTbl);

            Imports.Libs.AddNewCode(exchangeDetailRow.marketCode, importPriceTbl, null);
            databases.DbAccess.UpdateData(importPriceTbl);

            databases.baseDS.priceDataDataTable priceTbl = new databases.baseDS.priceDataDataTable();
            Imports.Libs.AddImportPrice(importPriceTbl, priceTbl);
            databases.DbAccess.UpdateData(priceTbl);
            return priceTbl;
        }
Example #21
0
        private void OnUpdateData(databases.baseDS.priceDataRow row, importStat stat)
        {
            if (fCanceled) stat.cancel =true;
            this.ShowMessage(stat.updateCount.ToString("###,###,##0") + "/" + 
                             stat.errorCount.ToString("###,###,##0") + "/"  + 
                             stat.dataCount.ToString("###,###,##0"), "Import");

            //Do Aggregate and reset import to clear system resource
            if (myDataSet.priceData.Count > constNumberOfImportInBatch)
            {
                databases.DbAccess.UpdateData(myDataSet.priceData);
                DoAggregate(myDataSet.priceData, marketCultureInfo);
                myDataSet.priceData.Clear();
            }
        }
        public static void AddNewCode(databases.importDS.importPriceDataTable tbl, OnCodeAdded onAddstockCodeFunc)
        {
            databases.tmpDS.stockCodeRow shortCodeRow;
            databases.baseDS.stockCodeDataTable stockCodeTbl = new databases.baseDS.stockCodeDataTable();
            for (int count = 0; count < tbl.Count; count++)
            {
                if (tbl[count].RowState == DataRowState.Deleted) continue;
                shortCodeRow = databases.AppLibs.FindAndCache_StockCodeShort(tbl[count].stockCode);
                if (shortCodeRow == null) continue;

                if (AddNewCode(tbl[count].stockCode, shortCodeRow.stockExchange, stockCodeTbl) != null &&
                    onAddstockCodeFunc != null) onAddstockCodeFunc(tbl[count].stockCode);
            }
            databases.DbAccess.UpdateData(stockCodeTbl);
        }
Example #23
0
 public void Update(databases.importDS.importPriceRow row)
 {
     databases.importDS.importPriceRow oldRow = Find(row);
     if (oldRow == null)
     {
         oldRow = dataTbl.NewimportPriceRow();
         databases.AppLibs.InitData(oldRow);
         dataTbl.AddimportPriceRow(oldRow);
     }
     oldRow.onDate = row.onDate;
     oldRow.stockCode = row.stockCode;
     oldRow.closePrice = row.closePrice;
     oldRow.volume = row.volume;
     oldRow.isTotalVolume = row.isTotalVolume;
 }
Example #24
0
 public static void InitData(databases.baseDS.investorRow row)
 {
     row.code = "";
     row.type = 0;
     row.firstName = "";
     row.lastName = "";
     row.displayName = "";
     row.sex = (byte)AppTypes.Sex.Unspecified;
     row.address1 = "";
     row.email = "";
     row.displayName = "";
     row.account = "";
     row.password = "";
     row.catCode = "";
     row.expireDate = DateTime.Today.AddDays(Settings.sysDefaultLoginAccountDayToExpire);
     row.status = (byte)AppTypes.CommonStatus.Enable;
 }
Example #25
0
        public static bool ImportFromWeb(DateTime updateTime, databases.baseDS.exchangeDetailRow exchangeDetailRow)
        {
            bool retVal = true;
            switch (exchangeDetailRow.code.Trim().ToUpper())
            {
                case "HOSE_MHBS":
                    Stock.hoseImport hoseImport = new Stock.hoseImport();
                    retVal = hoseImport.ImportFromWeb(updateTime, exchangeDetailRow);
                    break;
                case "HASTC_MHBS":
                    Stock.htastcImport htastcImport = new Stock.htastcImport();
                    retVal = htastcImport.ImportFromWeb(updateTime, exchangeDetailRow);
                    break;

                case "HOSE_SSI":
                case "HASTC_SSI":
                    Stock.ssi_StockImport ssiStockImport = new Stock.ssi_StockImport();
                    retVal = ssiStockImport.ImportFromWeb(updateTime, exchangeDetailRow);
                    break;

                case "VNIDX_SSI":
                    Stock.ssi_vnIdxImport vnIdxSSI = new Stock.ssi_vnIdxImport();
                    retVal = vnIdxSSI.ImportFromWeb(updateTime, exchangeDetailRow);
                    break;
                case "VNIDX_VSE":
                    Stock.vnIdxImport vnIdxVSE = new Stock.vnIdxImport();
                    retVal = vnIdxVSE.ImportFromWeb(updateTime, exchangeDetailRow);
                    break;

                case "HN_IDX1": //??
                    Stock.hnIdxImport hnIdxImport = new Stock.hnIdxImport();
                    retVal = hnIdxImport.ImportFromWeb(updateTime, exchangeDetailRow);
                    break;

                case "GOLD_FOREX":
                    Gold.forexImport forexImport = new Gold.forexImport();
                    retVal = forexImport.ImportFromWeb(updateTime, exchangeDetailRow);
                    break;
                case "GOLD_KITCO":
                    Gold.kitcoImport kitcoImport = new Gold.kitcoImport();
                    retVal = kitcoImport.ImportFromWeb(updateTime, exchangeDetailRow);
                    break;
            }
            return retVal;
        }
 public static databases.baseDS.stockCodeRow AddNewCode(string comCode, string stockEchangeCode,
     databases.baseDS.stockCodeDataTable toStockCodeTbl)
 {
     databases.baseDS.stockCodeRow stockCodeRow;
     stockCodeRow = application.SysLibs.FindAndCache(toStockCodeTbl, comCode);
     if (stockCodeRow == null)
     {
         stockCodeRow = toStockCodeTbl.NewstockCodeRow();
         databases.AppLibs.InitData(stockCodeRow);
         stockCodeRow.code = comCode;
         stockCodeRow.name = "<New>";
         stockCodeRow.code = comCode;
         stockCodeRow.tickerCode = comCode;
         stockCodeRow.stockExchange = stockEchangeCode;
         stockCodeRow.regDate = DateTime.Today;
         toStockCodeTbl.AddstockCodeRow(stockCodeRow);
     }
     return stockCodeRow;
 }
Example #27
0
        public virtual bool ImportFromWeb(DateTime updateTime, databases.baseDS.exchangeDetailRow exchangeDetailRow)
        {
            try
            {
                databases.baseDS.priceDataDataTable priceTbl = GetImportFromWeb(updateTime, exchangeDetailRow);
                if (priceTbl == null) return false;

                // Different culture has different start of week, ie in VN culture : start of week is Monday (not Sunday) 
                CultureInfo exchangeCulture = application.AppLibs.GetExchangeCulture(exchangeDetailRow.marketCode);
                databases.AppLibs.AggregatePriceData(priceTbl, exchangeCulture, null);
                return true;
            }
            catch (Exception er)
            {
                //retVal = false;
                commonClass.SysLibs.WriteSysLog(common.SysSeverityLevel.Error, "SRV004", er);
                return false;
            }
        }
Example #28
0
        public override databases.baseDS.priceDataDataTable GetImportFromWeb(DateTime updateTime, databases.baseDS.exchangeDetailRow exchangeDetailRow)
        {
            try
            {
                databases.importDS.importPriceDataTable importPriceTbl;
                metaStock meta = GetMeta();
                if (meta == null) return null;

                //try
                //{
                    importPriceTbl = GetPriceFromWeb(updateTime, meta, exchangeDetailRow);
                    Imports.Libs.AddNewCode(exchangeDetailRow.marketCode, importPriceTbl, null);
                    databases.DbAccess.UpdateData(importPriceTbl);
                ////}
                //catch (Exception er)
                //{
                //    commonClass.SysLibs.WriteSysLog(common.SysSeverityLevel.Error, "SRV004 - Import price error", er);
                //    throw er;
                //}

                //try
                //{
                    databases.baseDS.priceDataDataTable priceTbl = new databases.baseDS.priceDataDataTable();
                    Imports.Libs.AddImportPrice(importPriceTbl, priceTbl);
                    databases.DbAccess.UpdateData(priceTbl);
                    return priceTbl;
                //}
                //catch (Exception er)
                //{
                //    commonClass.SysLibs.WriteSysLog(common.SysSeverityLevel.Error, "SRV004 - Price Data table", er);
                //    throw er;
                //}
            }

            catch (Exception er)
            {
                commonClass.SysLibs.WriteSysLog(common.SysSeverityLevel.Error, "SRV004 - GetImport From Web error", er);
                return null;
            }
            
        }
Example #29
0
 public void Diagnose(commonTypes.AppTypes.PriceDataType dataType, double allowVariantPerc, ref databases.tmpDS.priceDiagnoseDataTable priceDiagnoseTbl)
 {
     string dataFld = "";
     switch (dataType)
     {
         case AppTypes.PriceDataType.High:
              dataFld = priceDataTbl.highPriceColumn.ColumnName;
              break;
         case AppTypes.PriceDataType.Low:
              dataFld = priceDataTbl.lowPriceColumn.ColumnName;
              break;
         case AppTypes.PriceDataType.Open:
              dataFld = priceDataTbl.openPriceColumn.ColumnName;
              break;
         case AppTypes.PriceDataType.Volume:
              dataFld = priceDataTbl.volumeColumn.ColumnName;
              break;
         default:
              dataFld = priceDataTbl.closePriceColumn.ColumnName; 
              break;
     }
     databases.tmpDS.priceDiagnoseRow priceDiagnoseRow;
     double d1, d2; 
     for (int idx = 1; idx < priceDataTbl.Count; idx++)
     {
         if (priceDataTbl[idx].RowState == System.Data.DataRowState.Deleted) continue;
         d1 = (double)priceDataTbl[idx-1][dataFld];
         d2 = (double)priceDataTbl[idx][dataFld];
         if (d1 == 0) continue;
         if (Math.Abs((d2 - d1)/d1) < allowVariantPerc) continue;
         priceDiagnoseRow = priceDiagnoseTbl.NewpriceDiagnoseRow();
         priceDiagnoseRow.code = this.DataStockCode;
         priceDiagnoseRow.date1 = priceDataTbl[idx-1].onDate;
         priceDiagnoseRow.date2 = priceDataTbl[idx].onDate;
         
         priceDiagnoseRow.price1 = d1;
         priceDiagnoseRow.price2 = d2;
         priceDiagnoseRow.variance = (d2 - d1) / d1;
         priceDiagnoseTbl.AddpriceDiagnoseRow(priceDiagnoseRow);
     }
 }
Example #30
0
            public override databases.baseDS.priceDataDataTable GetImportFromWeb(DateTime updateTime, databases.baseDS.exchangeDetailRow exchangeDetailRow)
            {
                // Different culture has differebr strt of week, ie in VN culture : start of week is Monday (not Sunday) 
                if (myCulture == null)
                    myCulture = application.AppLibs.GetCulture(exchangeDetailRow.culture);

                databases.importDS.importPriceDataTable importPriceTbl = new databases.importDS.importPriceDataTable();
                ForexData goldData = ImportKitco(exchangeDetailRow.address);
                if (null == goldData) { return null; }

                AddImportRow(updateTime, goldData, false, importPriceTbl);

                Imports.Libs.AddNewCode(exchangeDetailRow.marketCode, importPriceTbl, null);
                databases.DbAccess.UpdateData(importPriceTbl);

                databases.baseDS.priceDataDataTable priceTbl = new databases.baseDS.priceDataDataTable();
                Imports.Libs.AddImportPrice(importPriceTbl, priceTbl);
                databases.DbAccess.UpdateData(priceTbl);

                return priceTbl;
            }
Example #31
0
        public static void InitData(databases.baseDS.stockCodeRow row)
        {
            row.code = "";
            row.tickerCode = "";
            row.stockExchange = "";
            row.name = "";
            row.address1 = "";
            row.email = "";
            row.website = "";
            row.phone = "";
            row.fax = "";
            row.country = Settings.sysDefaultCountry;
            row.bizSectors = "";

            row.regDate = DateTime.Today;
            row.capitalUnit = Settings.sysMainCurrency;
            row.workingCap = 0;
            row.equity = 0;
            row.totalDebt = 0;
            row.totaAssets = 0;
            row.noOutstandingStock = 1000000;
            row.noListedStock = 1000000;
            row.noTreasuryStock = 0;
            row.noForeignOwnedStock = 0;
            row.bookPrice = 0;
            row.targetPrice = 0;
            row.targetPriceVariant = 0;
            row.sales = 0;
            row.profit = 0;
            row.equity = 0;
            row.totalDebt = 0;
            row.totaAssets = 0;
            row.PB = 0;
            row.EPS = 0;
            row.PE = 0;
            row.ROA = 0;
            row.ROE = 0;
            row.BETA = 0;
            row.status = (byte)AppTypes.CommonStatus.Enable;
        }
Example #32
0
        protected virtual bool GetData(databases.baseDS.exchangeDetailRow exchangeDetailRow, ref MarketData vnIdx, ref MarketData vn30Idx)
        {
            CultureInfo dataCulture = common.language.GetCulture("en-US");
            //Hose
            clientHOSE.HoSTC_ServiceSoapClient client = new Imports.clientHOSE.HoSTC_ServiceSoapClient();
            client.Endpoint.Address = new System.ServiceModel.EndpointAddress(exchangeDetailRow.address);

            System.ServiceModel.BasicHttpBinding binding = (client.Endpoint.Binding as System.ServiceModel.BasicHttpBinding);

            binding.OpenTimeout = TimeSpan.FromSeconds(Consts.constWebServiceTimeOutInSecs);
            binding.CloseTimeout = binding.OpenTimeout;
            binding.SendTimeout = binding.OpenTimeout;

            binding.MaxReceivedMessageSize = Consts.constWebServiceMaxReceivedMessageSize;
            binding.MaxBufferSize = Consts.constWebServiceMaxReceivedMessageSize;

            binding.ReaderQuotas.MaxStringContentLength = Consts.constWebServiceMaxStringContentLength;
            binding.ReaderQuotas.MaxBytesPerRead = Consts.constWebServiceMaxBytesPerRead;

            string[] arr = client.GetLiveTotalMKT().Split('*');
            string content = string.Empty;
            List<string> rows = new List<string>();
            foreach (var item in arr)
            {
                if (item.Trim() == "") continue;
                rows.Add(item);
                content += item + Environment.NewLine;
            }
            string[] dRow = rows[8].Split('|');

            vnIdx.Value = decimal.Parse(dRow[0], dataCulture);
            vnIdx.TotalQty = decimal.Parse(dRow[4], dataCulture);
            vnIdx.TotalAmt = decimal.Parse(dRow[5], dataCulture);

            vn30Idx.Value = decimal.Parse(dRow[10], dataCulture);
            vn30Idx.TotalQty = 0;
            vn30Idx.TotalAmt = 0;

            return true;
        }
 public LogicProviderDB(databases db)
 {
     provider = db;
 }