// given a clean price and idCode will return the yield of the corresponding bond in BondDictionaryData object ICalculator.YieldFromDictionary(string idCode, double Today, double CleanPrice, int Freq, string DayCount, string Compounding) { // int Freq, string DayCount, string Compounding refers to yield calculation // string idCode is the identification code of bond in BondDictionaryData // make it volatile if (m_xlApp != null) { m_xlApp.Volatile(true); } try { BaseBond bond = null; // initialise a bond if (BondDictionaryData.TryGetValue(idCode, out bond)) // is the idCode in dictionary? { // update today since I the bond in dictionary can be the same but I can change my reference date to do simulations bond.SetNewToDay(new Date(Today)); // Parse enum Type Dc dc = (Dc)Enum.Parse(typeof(Dc), DayCount); Compounding comp = (Compounding)Enum.Parse(typeof(Compounding), Compounding); // return the yield given parameters return(bond.Yield(CleanPrice, Freq, dc, comp)); } else { return("IdCode not found"); // bond not found } } catch (Exception e) { return((string)e.ToString()); } }
public override void ClearData(InitOrgStatus status) { MarketType mt = MarketType.NA; List <MarketType> mtList; List <int> removeCode = new List <int>(1); foreach (KeyValuePair <int, List <OneDealDataRec> > oneStock in _allDealData) { mt = Dc.GetMarketType(oneStock.Key); if (SecurityAttribute.InitMarketType.TryGetValue(status, out mtList)) { if (mtList.Contains(mt)) { removeCode.Add(oneStock.Key); } } } foreach (int code in removeCode) { if (_allDealData.ContainsKey(code)) { _allDealData.Remove(code); } } }
// Calculate Clean price from Yield according to customized convection (freq,DayCount and compounding), given a clean price public double CleanPriceFromYield(double yield, int freq, Dc DayCount, Compounding compounding) { double fullPrice = Formula.FullPriceFromYield(yield, bond.schedule.payDates, bond.cashFlows, freq, DayCount, settlementDate, compounding, bond.redemptionValue); return(fullPrice - accruedInterest); // clean price }
// Specification for this class public override void LoadSpecifications() { // standard EoniaSwap Data may be stored on xml this.buildingBlockType = BuildingBlockType.EONIASWAP; // Fixed leg details on swapLeg1 Rule FixSwapRule = Rule.Backward; string FixSwapPayFreqString = "1y"; BusinessDayAdjustment FixSwapBusDayAdjRolls = BusinessDayAdjustment.ModifiedFollowing; string FixSwapLegPaymentString = "1d"; BusinessDayAdjustment FixSwapBusDayAdjPay = BusinessDayAdjustment.ModifiedFollowing; Dc FixDayCount = Dc._Act_360; // day count of fixed leg FixFloat FixFixOrFloat = FixFloat.Fixed; string FixUnderlyingRateTenor = ""; // Floating details on Leg2 Rule FloatSwapRule = Rule.Backward; string FloatSwapPayFreqString = "1y"; BusinessDayAdjustment FloatSwapBusDayAdjRolls = BusinessDayAdjustment.ModifiedFollowing; string FloatSwapLegPaymentString = "1d"; BusinessDayAdjustment FloatSwapBusDayAdjPay = BusinessDayAdjustment.ModifiedFollowing; Dc FloatDayCount = Dc._Act_360; // day count of Floating leg FixFloat FloatFixOrFloat = FixFloat.Floating; string FloatUnderlyingRateTenor = "1d"; // Creating swap legs // create swapLeg1 this.swapLeg1 = new SwapLeg(FixSwapRule, FixSwapPayFreqString, FixSwapBusDayAdjRolls, FixSwapLegPaymentString, FixSwapBusDayAdjPay, FixDayCount, FixFixOrFloat, FixUnderlyingRateTenor); // create swapLeg2 this.swapLeg2 = new SwapLeg(FloatSwapRule, FloatSwapPayFreqString, FloatSwapBusDayAdjRolls, FloatSwapLegPaymentString, FloatSwapBusDayAdjPay, FloatDayCount, FloatFixOrFloat, FloatUnderlyingRateTenor); }
// Specification for this class public override void LoadSpecifications() { // Basis swap 6m vs 3m this.buildingBlockType = BuildingBlockType.EURSWAP3M; // Fixed leg details on swapLeg1 Rule FloatSwapRule1 = Rule.Backward; string FloatSwapPayFreqString1 = "6m"; BusinessDayAdjustment FloatSwapBusDayAdjRolls1 = BusinessDayAdjustment.ModifiedFollowing; string FloatSwapLegPaymentString1 = "0d"; BusinessDayAdjustment FloatSwapBusDayAdjPay1 = BusinessDayAdjustment.ModifiedFollowing; Dc FloatDayCount1 = Dc._Act_360; // day count of Floating leg FixFloat FloatFixOrFloat1 = FixFloat.Floating; string FloatUnderlyingRateTenor1 = "6m"; // Floating details on Leg2 Rule FloatSwapRule2 = Rule.Backward; string FloatSwapPayFreqString2 = "3m"; BusinessDayAdjustment FloatSwapBusDayAdjRolls2 = BusinessDayAdjustment.ModifiedFollowing; string FloatSwapLegPaymentString2 = "0d"; BusinessDayAdjustment FloatSwapBusDayAdjPay2 = BusinessDayAdjustment.ModifiedFollowing; Dc FloatDayCount2 = Dc._Act_360; // day count of Floating leg FixFloat FloatFixOrFloat2 = FixFloat.Floating; string FloatUnderlyingRateTenor2 = "3m"; // Creating swap legs // create swapLeg1 this.swapLeg1 = new SwapLeg(FloatSwapRule1, FloatSwapPayFreqString1, FloatSwapBusDayAdjRolls1, FloatSwapLegPaymentString1, FloatSwapBusDayAdjPay1, FloatDayCount1, FloatFixOrFloat1, FloatUnderlyingRateTenor1); // create swapLeg2 this.swapLeg2 = new SwapLeg(FloatSwapRule2, FloatSwapPayFreqString2, FloatSwapBusDayAdjRolls2, FloatSwapLegPaymentString2, FloatSwapBusDayAdjPay2, FloatDayCount2, FloatFixOrFloat2, FloatUnderlyingRateTenor2); }
public string createAcountLink(string account) { StripeConfiguration.ApiKey = "sk_test_51H4bEIAVJDEhYcbP8AniC54IhmNxi8AOAkQpTgSCdwJjXwd8eoYEZmpBdZPOn7mpkBhQWkuzYYIFUv1y8Y3ncnKO008t1vsMSK"; var options = new AccountLinkCreateOptions { Account = account, RefreshUrl = "https://example.com/reauth", ReturnUrl = "https://localhost:44337/Billing/ListTutorBankAccounts", Type = "account_onboarding", }; var service = new AccountLinkService(); var accountLink = service.Create(options); UserAccount newAccount = new UserAccount() { StripeAccountID = account, UserID = currentUser.UserId }; Dc.UserAccounts.Add(newAccount); Dc.SaveChanges(); return(accountLink.Url); }
protected override void _cm_DoCMReceiveData(object sender, CMRecvDataEventArgs e) { if (e.DataPacket is ResCustomReportOrgDataPacket) { if (ReceiveCustomReportData != null) { ReceiveCustomReportData(((ResCustomReportOrgDataPacket)e.DataPacket).ChangedFields); } if (ReceiveCustomReportDataEmCode != null) { Dictionary <String, List <FieldIndex> > ChangedFields = new Dictionary <String, List <FieldIndex> >( ((ResCustomReportOrgDataPacket)e.DataPacket).ChangedFields.Count); foreach ( KeyValuePair <int, List <FieldIndex> > onePair in ((ResCustomReportOrgDataPacket)e.DataPacket).ChangedFields) { Dictionary <FieldIndex, object> memData; ChangedFields[Dc.GetFieldDataString(onePair.Key, FieldIndex.EMCode)] = onePair.Value; } ReceiveCustomReportDataEmCode(ChangedFields); } } }
// will return yield on BondFixedCoupon double ICalculator.BondFixedCouponYield(double Today, double StartDateBond, double EndDateBond, double Coupon, string CouponTenor, string RuleGenerator, int SettlementDaysLag, string RollAdj, string PayAdj, string DayCount, string LagPayFromRecordDate, double FaceValue, double CleanPrice, int Freq, string DayCountYield, string Compounding) { // for details of input refer to comments on BondFixedCoupon class // make it volatile if (m_xlApp != null) { m_xlApp.Volatile(true); } // Parse enum Type Rule ruleGenerator = (Rule)Enum.Parse(typeof(Rule), RuleGenerator); BusinessDayAdjustment rollAdj = (BusinessDayAdjustment)Enum.Parse(typeof(BusinessDayAdjustment), RollAdj); BusinessDayAdjustment payAdj = (BusinessDayAdjustment)Enum.Parse(typeof(BusinessDayAdjustment), PayAdj); Dc dc = (Dc)Enum.Parse(typeof(Dc), DayCount); Dc dcy = (Dc)Enum.Parse(typeof(Dc), DayCountYield); Compounding comp = (Compounding)Enum.Parse(typeof(Compounding), Compounding); // initialise bond BondFixedCoupon bfc = new BondFixedCoupon(new Date(Today), new Date(StartDateBond), new Date(EndDateBond) , Coupon, CouponTenor, ruleGenerator, SettlementDaysLag, rollAdj, payAdj, dc, LagPayFromRecordDate, FaceValue); // return the yield return((double)bfc.Yield(CleanPrice, Freq, dcy, comp)); }
public async void UpdateTask() { if (Singleton.GetTaskId() != 0) { var updatedItem = new TaskClass( Singleton.GetTaskId(), Tvm.SelectedItem.TaskName = Singleton.GetTaskName(), Tvm.SelectedItem.TaskSchedule = Singleton.GetTaskSchedule(), null, Tvm.SelectedItem.TaskType = Singleton.GetTaskType(), Dc.ConvertToDate(_updateVm.DueDate), null, null, Tvm.SelectedItem.DoneVar = Singleton.GetDoneVar(), Tvm.SelectedItem.EquipmentId = Singleton.GetEquipmentId() ); await _update.Update(updatedItem, "Tasks", Singleton.GetTaskId()); GoTask(); var msg = new MessageDialog("Task updated"); await msg.ShowAsync(); } else { var msg = new MessageDialog("Please select item"); await msg.ShowAsync(); } }
void PlayAnimation() { Da.SetActive(true); Db.SetActive(true); Dc.SetActive(true); Dd.SetActive(true); De.SetActive(true); Hand.SetActive(true); PlayTime = Time.time; MovieOn = true; }
// Calculate Clean price from Yield according to customized convection (freq,DayCount and compounding), given a clean price public double CleanPriceFromYield(double yield, int freq, Dc DayCount, Compounding compounding) { double fullPrice = Formula.FullPriceFromYield(yield, this.cashFlowsDates, this.cashFlows, freq, DayCount, settlementDate, compounding, faceValue); return(fullPrice - accrued); // clean price }
/// <summary> /// 修改用户信息 /// </summary> /// <param name="mUser"></param> /// <param name="oCtrl"></param> /// <returns></returns> public int UpdateUserInfo(SysUserInfoModel mUser, ObjectControls oCtrl) { SYS_USER_INFO sui = new SYS_USER_INFO(); var query = Dc.SYS_USER_INFO.Where(c => c.USER_ID == mUser.UserId); if (query.Count() > 0) { sui = query.First(); if (oCtrl.Exsit(MCtrl.SetPsw)) { sui.PASSWORD = mUser.NewPsw; } if (oCtrl.Exsit(MCtrl.SetUserName)) { sui.USER_NAME = mUser.UserName; } if (oCtrl.Exsit(MCtrl.SetUserNo)) { sui.USER_NO = mUser.UserNo; } if (oCtrl.Exsit(MCtrl.SetRoleId)) { sui.ROLE_ID = mUser.RoleInfo.RoleId; } if (oCtrl.Exsit(MCtrl.SetSkinId)) { sui.SKIN_ID = mUser.SkinId; } sui.UPDATE_DATE = Cmn.DateBaseDate; sui.UPDATE_USERID = mUser.UserId; Dc.SubmitChanges(); return(sui.USER_ID); } return(-1); }
public IHttpActionResult Delete(int imageID) { var img = Dc.Images.Find(imageID); if (img != null) { try { if (File.Exists(img.FilePathThumb)) { File.Delete(img.FilePathThumb); } if (File.Exists(img.FilePath)) { File.Delete(img.FilePath); } } catch (Exception ex) { } _agent.Json = Newtonsoft.Json.JsonConvert.SerializeObject(img); Dc.Images.Remove(img); Dc.SaveChanges(); } return(Ok(new ResultsDTO { status = ResultsDTO.ok })); }
public static void Disconnect() { if (Dc != null) { Dc.Shutdown(); Dc = null; } }
// Calculate Yield according to customized convection (freq,DayCount and compounding), given a clean price public double YieldFromCleanPrice(double cleanPrice, int freq, Dc DayCount, Compounding compounding) { double fullPrice = DirtyPrice(cleanPrice); // calculate full price double guess = 0.05; // initial guess: arbitrary value return(Formula.YieldFromFullPrice(fullPrice, guess, bond.schedule.payDates, bond.cashFlows, freq, DayCount, settlementDate, compounding, bond.redemptionValue)); // calc yield from full price }
// Calculate Yield according to customized convection (freq,DayCount and compounding), given a clean price public double Yield(double cleanPrice, int freq, Dc DayCount, Compounding compounding) { double fullPrice = DirtyPrice(cleanPrice); // it calculates full price double guess = 0.05; // initial guess: arbitrary value return(Formula.YieldFromFullPrice(fullPrice, guess, this.cashFlowsDates, this.cashFlows, freq, DayCount, settlementDate, compounding, faceValue)); // it calculates yield from full price }
public ActionResult Compose(Message getMessage) { getMessage.TimeStamp = DateTime.UtcNow; Dc.Messages.Add(getMessage); Dc.SaveChanges(); return(RedirectToAction("MessageCenter", "Message", new { userID = getMessage.ReceiverID })); }
public ActionResult CancelMeeting(int ID) { Dc.CancelMeeting(ID); var getUser = Dc.Schedules.Where(a => a.SessionID == ID).FirstOrDefault(); var attendee = Dc.Attendees.Where(a => a.SessionID == ID).Select(b => b.AttendeeID).ToList(); SendEmailToUsers(attendee, getUser.User.FirstName + " " + getUser.User.LastName); return RedirectToAction("Schedule", "User"); }
public override int GetHashCode() { int prime = 31; int result = 1; result = prime * result + ((App == null) ? 0 : App.GetHashCode()); result = prime * result + ((Dc == null) ? 0 : Dc.GetHashCode()); result = prime * result + ((Key == null) ? 0 : Key.GetHashCode()); return(result); }
public IHttpActionResult UploadNewImage(int userID, string metaType) { var request = HttpContext.Current.Request; DataHelper.EnsureFolders(_agent.Host); if (request.Files.Count == 0) { return(Ok(new ResultsDTO { status = "error", message = "No file selected" })); } string baseFile = request.Files[0].FileName; string extension = baseFile.Substring(baseFile.LastIndexOf('.')); baseFile = baseFile.Substring(0, baseFile.LastIndexOf('.')); var filePath = ConfigSettings.DeployedPdfRoot + _agent.Host + "\\Images\\" + procID + baseFile + extension; var thumbPath = ConfigSettings.DeployedPdfRoot + _agent.Host + "\\Images\\Thumbs\\" + procID + baseFile + extension; if (File.Exists(filePath) || File.Exists(thumbPath)) { var i = DateTime.Now.Ticks; filePath = ConfigSettings.DeployedPdfRoot + _agent.Host + "\\Images\\" + procID + baseFile + string.Format("_{0}", i) + extension; thumbPath = ConfigSettings.DeployedPdfRoot + _agent.Host + "\\Images\\Thumbs\\" + procID + baseFile + string.Format("_{0}", i) + extension; } request.Files[0].SaveAs(filePath); using (System.Drawing.Image originalImage = System.Drawing.Image.FromFile(filePath)) { using (var thumbImage = DataHelper.GetImageThumbnail(originalImage)) { thumbImage.Save(thumbPath); } } var image = new Images() { UserID = userID, MetaType = metaType, CreatedOn = DateTime.Now, CreatedBy = _agent.User.UserID, LastUpdatedBy = _agent.User.UserID, LastUpdatedOn = DateTime.Now, FilePath = filePath, FilePathThumb = thumbPath }; Dc.Add(image); Dc.SaveChanges(); return(Ok(new ResultsDTO { result = new { UserID = image.UserID, MetaType = image.MetaType, ImageID = image.ImageID, LastUpdatedBy = image.LastUpdatedBy, LastUpdatedOn = image.LastUpdatedOn, Url = BaseUrl + "Images/" + image.ImageID } })); }
// will return yield on BondMultiCoupon object ICalculator.BondMultiCouponYield(double Today, double StartDateBond, double EndDateBond, Excel.Range Coupons, string CouponTenor, string RuleGenerator, int SettlementDaysLag, string RollAdj, string PayAdj, string DayCount, string LagPayFromRecordDate, double FaceValue, double CleanPrice, int Freq, string DayCountYield, string Compounding) { // for details of input refer to comments on BondMultiCoupon class // make it volatile if (m_xlApp != null) { m_xlApp.Volatile(true); } try { // Parse enum Type Rule ruleGenerator = (Rule)Enum.Parse(typeof(Rule), RuleGenerator); BusinessDayAdjustment rollAdj = (BusinessDayAdjustment)Enum.Parse(typeof(BusinessDayAdjustment), RollAdj); BusinessDayAdjustment payAdj = (BusinessDayAdjustment)Enum.Parse(typeof(BusinessDayAdjustment), PayAdj); Dc dc = (Dc)Enum.Parse(typeof(Dc), DayCount); Dc dcy = (Dc)Enum.Parse(typeof(Dc), DayCountYield); Compounding comp = (Compounding)Enum.Parse(typeof(Compounding), Compounding); // create the schedule to how many coupon dates I need Schedule sch = new Schedule(new Date(StartDateBond), new Date(EndDateBond), CouponTenor, ruleGenerator, rollAdj, LagPayFromRecordDate, payAdj); int rows = Coupons.Rows.Count; // number of element in my input array int n = sch.toDates.GetLength(0); // number of coupons List <double> coupons = new List <double>(); // list containing needed coupon // iterate my input array to get no empty cell for (int r = 1; r <= rows; r++) { // Get the value of the current cell as double and add to running result. if ((Coupons[r, 1] as Excel.Range).Value2 != null) // if the cell is not empty { coupons.Add((double)(Coupons[r, 1] as Excel.Range).Value2); } } // usable input coupon in coupons list should equal the number of needed coupon if (n != coupons.Count) { return("Invalid coupons number"); } // initialise BondMultiCoupon BondMultiCoupon bmc = new BondMultiCoupon(new Date(Today), new Date(StartDateBond), new Date(EndDateBond) , coupons.ToArray(), CouponTenor, ruleGenerator, SettlementDaysLag, rollAdj, payAdj, dc, LagPayFromRecordDate, FaceValue); // return the yield return((double)bmc.Yield(CleanPrice, Freq, dcy, comp)); } catch (Exception e) // exception { return((string)e.ToString()); } }
public ActionResult StartMeeting(int? ID) { if (ID == null) { ID = currentUser.UserId; } var DisplaySchedule = Dc.UserSchedule(ID); return View(DisplaySchedule); }
public ActionResult DeleteAttendee(int attendeeID) { var attendee = Dc.Attendees.Find(attendeeID); if (attendee != null) { Dc.Attendees.Remove(attendee); Dc.SaveChanges(); return Json(new { result = "ok" }, JsonRequestBehavior.AllowGet); } return Json(new { result = "error" }, JsonRequestBehavior.AllowGet); }
public void deleteAccount(string accountId) { StripeConfiguration.ApiKey = "sk_test_51H4bEIAVJDEhYcbP8AniC54IhmNxi8AOAkQpTgSCdwJjXwd8eoYEZmpBdZPOn7mpkBhQWkuzYYIFUv1y8Y3ncnKO008t1vsMSK"; var service = new AccountService(); var deleteAccount = Dc.UserAccounts.Where(x => x.UserID == currentUser.UserId && x.StripeAccountID.Substring(x.StripeAccountID.Length - 4) == accountId).FirstOrDefault(); service.Delete(deleteAccount.StripeAccountID); Dc.UserAccounts.Remove(deleteAccount); Dc.SaveChanges(); }
public static void Connect(string user, string pwd, string remote, string local) { Disconnect(); User = user; Pwd = pwd; Remote = remote; Local = local; Dc = Datacenter.Create(Ip, Port, user, pwd, remote, local); Dc.Start(); }
FixFloat fixedFloating; // Fix or Floating // constructor public BaseSwapLeg(Rule SwapScheduleGeneratorRule, string PayFreq, BusinessDayAdjustment SwapBusDayRollsAdj, string SwapLagPayment, BusinessDayAdjustment SwapBusDayPayAdj, Dc DayCount, FixFloat FixedFloating) { // assign to data member this.swapScheduleGeneratorRule = SwapScheduleGeneratorRule; this.payFreq = PayFreq; this.swapBusDayRollsAdj = SwapBusDayRollsAdj; this.swapLagPayment = SwapLagPayment; this.swapBusDayPayAdj = SwapBusDayPayAdj; this.dayCount = DayCount; this.fixedFloating = FixedFloating; }
// Method Member: return an array of yearFraction given two array of date // 18sep10 public static double[] GetYfArray(Date[] d1, Date[] d2, Dc dayCount) { // d1,d2 should have same dimension int n = d1.GetLength(0); double[] outPut = new double[n]; for (int i = 0; i < n; i++) { outPut[i] = d1[i].YF(d2[i], dayCount); } return(outPut); }
public ActionResult AddAccount(PaymentMethodViewModel m) { var expMonthInt = Int32.Parse(m.ExpMonth); var expYearInt = Int32.Parse(m.ExpYear); if (ModelState.IsValid) { m.CardType = m.CardNumber.Substring(0, 1); //m.AccountName = m.CardType + " ending in " + m.CardNumber.Substring(m.CardNumber.Length - 4); m.AccountName = " ending in " + m.CardNumber.Substring(m.CardNumber.Length - 4); StripeConfiguration.ApiKey = "sk_test_51H4bEIAVJDEhYcbP8AniC54IhmNxi8AOAkQpTgSCdwJjXwd8eoYEZmpBdZPOn7mpkBhQWkuzYYIFUv1y8Y3ncnKO008t1vsMSK"; var paymentMethodService = new PaymentMethodService(); //need to send the first digit of the card number to the account list and user account table var paymentMethod = paymentMethodService.Create(new PaymentMethodCreateOptions { Type = "card", Card = new PaymentMethodCardCreateOptions { Number = m.CardNumber, Cvc = m.CvcCode, ExpMonth = expMonthInt, ExpYear = expYearInt, } }); ModelState.AddModelError(String.Empty, paymentMethod.Id); var options = new CustomerCreateOptions { Description = m.AccountName }; var services = new CustomerService(); var cust = services.Create(options); // why do we need to create a useraccount object instead of just using paymentmethodviewmodel object? var userAccount = new UserAccount() { AccountName = m.AccountName, BankReference = paymentMethod.Id, CardType = m.CardType, UserID = currentUser.UserId, Customer = cust.Id }; Dc.UserAccounts.Add(userAccount); Dc.SaveChanges(); return(RedirectToAction("AccountList", "Billing", userAccount));//redirects user to different action" } return(View(m)); }
public override bool Equals(object obj) { if (object.ReferenceEquals(this, obj)) { return(true); } if (obj == null) { return(false); } if (GetType() != obj.GetType()) { return(false); } DcSetting other = (DcSetting)obj; if (App == null) { if (other.App != null) { return(false); } } else if (!App.Equals(other.App)) { return(false); } if (Dc == null) { if (other.Dc != null) { return(false); } } else if (!Dc.Equals(other.Dc)) { return(false); } if (Key == null) { if (other.Key != null) { return(false); } } else if (!Key.Equals(other.Key)) { return(false); } return(true); }
/// <summary> /// 获得最新价(如果没有用昨收价代替) /// </summary> /// <param name="code">证券代码</param> /// <param name="lastestPrice">最新价或则昨收价</param> /// <returns>true,能获得最新价或者昨收价;fasle,不能获取</returns> private bool TryGetLastestPrice(int code, out float lastestPrice) { lastestPrice = Dc.GetFieldDataSingle(code, FieldIndex.Now); if (lastestPrice.Equals(0)) { lastestPrice = Dc.GetFieldDataSingle(code, FieldIndex.PreClose); } if (lastestPrice.Equals(0)) { return(false); } return(true); }