/* public Quote getQuotePremium(Quote quotetemp) { if (quotetemp.Sellamount > 0) { decimal peerfxservicefee = 0; decimal buyamount = 0; decimal peerfxrate = 0; //Calculate peerfx service fee Fees fees = getFeesPremium(quotetemp.Sellcurrency, quotetemp.Buycurrency); //peerfxrate peerfxrate = quotetemp.Peerfx_Rate; if (fees.Fee_Percentage != 0) { peerfxservicefee += (fees.Fee_Percentage * (quotetemp.Sellamount * peerfxrate)); } //peerfx service fee if (fees.Fee_Addon != 0) { peerfxservicefee += fees.Fee_Addon; } if (fees.Fee_Min != 0) { if (fees.Fee_Min > peerfxservicefee) { peerfxservicefee = fees.Fee_Min; } } if (fees.Fee_Max != 0) { if (fees.Fee_Max < peerfxservicefee) { peerfxservicefee = fees.Fee_Max; } } quotetemp.Peerfx_Servicefee += peerfxservicefee; quotetemp.Buyamount -= peerfxservicefee; } return quotetemp; }*/ public Fees getFees(int sellcurrency, int buycurrency) { Fees fees = new Fees(); DataSet dstemp = Peerfx_DB.SPs.ViewInfoFeeTypes(sellcurrency, buycurrency).GetDataSet(); if (dstemp.Tables[0].Rows[0]["organization_name"] != DBNull.Value) { fees.Organization_Name = dstemp.Tables[0].Rows[0]["organization_name"].ToString(); } if (dstemp.Tables[0].Rows[0]["description"] != DBNull.Value) { fees.Description = dstemp.Tables[0].Rows[0]["description"].ToString(); } if (dstemp.Tables[0].Rows[0]["fee_base"] != DBNull.Value) { fees.Fee_Base = Convert.ToDecimal(dstemp.Tables[0].Rows[0]["fee_base"]); } if (dstemp.Tables[0].Rows[0]["fee_percentage"] != DBNull.Value) { fees.Fee_Percentage = Convert.ToDecimal(dstemp.Tables[0].Rows[0]["fee_percentage"]); } if (dstemp.Tables[0].Rows[0]["fee_addon"] != DBNull.Value) { fees.Fee_Addon = Convert.ToDecimal(dstemp.Tables[0].Rows[0]["fee_addon"]); } if (dstemp.Tables[0].Rows[0]["fee_min"] != DBNull.Value) { fees.Fee_Min = Convert.ToDecimal(dstemp.Tables[0].Rows[0]["fee_min"]); } if (dstemp.Tables[0].Rows[0]["fee_max"] != DBNull.Value) { fees.Fee_Max = Convert.ToDecimal(dstemp.Tables[0].Rows[0]["fee_max"]); } if (sellcurrency > 0) { fees.Currency1 = sellcurrency; } if (buycurrency > 0) { fees.Currency2 = buycurrency; } return fees; }
public Fees getFeesPremium(int sellcurrency, int buycurrency) { Fees fees = new Fees(); DataSet dstemp = Peerfx_DB.SPs.ViewInfoFeeTypes(sellcurrency, buycurrency).GetDataSet(); if (dstemp.Tables[0].Rows[0]["organization_name"] != DBNull.Value) { fees.Organization_Name = dstemp.Tables[0].Rows[0]["organization_name"].ToString(); } if (dstemp.Tables[0].Rows[0]["description"] != DBNull.Value) { fees.Description = dstemp.Tables[0].Rows[0]["description"].ToString(); } if ((dstemp.Tables[0].Rows[0]["fee_percentage"] != DBNull.Value) && (dstemp.Tables[0].Rows[0]["premium_fee_percentage"] != DBNull.Value)) { fees.Fee_Percentage = Convert.ToDecimal(dstemp.Tables[0].Rows[0]["fee_percentage"]); fees.Fee_Percentage += Convert.ToDecimal(dstemp.Tables[0].Rows[0]["premium_fee_percentage"]); } if ((dstemp.Tables[0].Rows[0]["fee_addon"] != DBNull.Value) && (dstemp.Tables[0].Rows[0]["premium_fee_addon"] != DBNull.Value)) { fees.Fee_Addon = Convert.ToDecimal(dstemp.Tables[0].Rows[0]["fee_addon"]); fees.Fee_Addon += Convert.ToDecimal(dstemp.Tables[0].Rows[0]["premium_fee_addon"]); } if ((dstemp.Tables[0].Rows[0]["fee_min"] != DBNull.Value) && (dstemp.Tables[0].Rows[0]["premium_fee_min"] != DBNull.Value)) { decimal min = Convert.ToDecimal(dstemp.Tables[0].Rows[0]["fee_min"]); decimal minpremium = Convert.ToDecimal(dstemp.Tables[0].Rows[0]["premium_fee_min"]); if (min < minpremium) { fees.Fee_Min = min; } else { fees.Fee_Min = minpremium; } } if ((dstemp.Tables[0].Rows[0]["fee_max"] != DBNull.Value) && (dstemp.Tables[0].Rows[0]["premium_fee_max"] != DBNull.Value)) { decimal max = Convert.ToDecimal(dstemp.Tables[0].Rows[0]["fee_max"]); decimal maxpremium = Convert.ToDecimal(dstemp.Tables[0].Rows[0]["premium_fee_max"]); if (max > maxpremium) { fees.Fee_Max = max; } else { fees.Fee_Max = maxpremium; } } if (sellcurrency > 0) { fees.Currency1 = sellcurrency; } if (buycurrency > 0) { fees.Currency2 = buycurrency; } return fees; }
public Quote getQuote_reverse(decimal buyamount, int sellcurrency, int buycurrency,Boolean ispremium) { Quote quotetemp = new Quote(); External_APIs.CurrencyCloud cc = new External_APIs.CurrencyCloud(); Hashtable hstemp = cc.Exchange_Rate_ccy_pair(sellcurrency, buycurrency); if (!hstemp.ContainsValue("error")) { quotetemp.Bid_Price_Timestamp = getcurrencyclouddate(hstemp["bid_price_timestamp"].ToString()); quotetemp.Bid_Price = Convert.ToDecimal(hstemp["bid_price"]); quotetemp.Broker_Bid = Convert.ToDecimal(hstemp["broker_bid"]); quotetemp.Offer_Price_Timestamp = getcurrencyclouddate(hstemp["offer_price_timestamp"].ToString()); quotetemp.Offer_Price = Convert.ToDecimal(hstemp["offer_price"]); quotetemp.Broker_Offer = Convert.ToDecimal(hstemp["broker_offer"]); quotetemp.Market_Price = Convert.ToDecimal(hstemp["market_price"]); quotetemp.Value_Date = getcurrencyclouddate(hstemp["value_date"].ToString()); quotetemp.Quote_Condition = hstemp["quote_condition"].ToString(); quotetemp.Real_Market = hstemp["real_market"].ToString(); quotetemp.Ccy_Pair = hstemp["ccy_pair"].ToString(); quotetemp.Buycurrency = buycurrency; quotetemp.Sellcurrency = sellcurrency; //calculate Peerfx servicefee & rate if (buyamount > 0) { quotetemp.Buyamount = buyamount; decimal peerfxservicefee = 0; decimal sellamount = 0; decimal peerfxrate = 0; Fees fees = new Fees(); //Calculate peerfx service fee if (ispremium) { fees = getFeesPremium(sellcurrency, buycurrency); } else { fees = getFees(sellcurrency, buycurrency); } //peerfxrate peerfxrate = quotetemp.Broker_Bid; if (fees.Fee_Percentage != 0) { peerfxservicefee += (buyamount * fees.Fee_Percentage); } //peerfx service fee if (fees.Fee_Base != 0) { peerfxservicefee += fees.Fee_Base; } if (fees.Fee_Addon != 0) { peerfxservicefee += fees.Fee_Addon; } if (fees.Fee_Min != 0) { if (fees.Fee_Min > peerfxservicefee) { peerfxservicefee = fees.Fee_Min; } } if (fees.Fee_Max != 0) { if (fees.Fee_Max < peerfxservicefee) { peerfxservicefee = fees.Fee_Max; } } //calculate buyingamount sellamount = buyamount / peerfxrate; sellamount = sellamount + peerfxservicefee; //assign values quotetemp.Peerfx_Servicefee = decimal.Round(peerfxservicefee, 2); quotetemp.Peerfx_Rate = peerfxrate; quotetemp.Sellamount = decimal.Round(sellamount, 2); } } return quotetemp; }