/// <summary> /// Get the fee for this order in units of the account currency /// </summary> /// <param name="security">The security matching the order</param> /// <param name="order">The order to compute fees for</param> /// <returns>The cost of the order in units of the account currency</returns> public decimal GetOrderFee(Securities.Security security, Order order) { decimal fee = TakerFee; var props = order.Properties as BitfinexOrderProperties; if (order.Type == OrderType.Limit && props?.Hidden != true && (props?.PostOnly == true || !order.IsMarketable)) { // limit order posted to the order book fee = MakerFee; } // get order value in account currency var unitPrice = order.Direction == OrderDirection.Buy ? security.AskPrice : security.BidPrice; if (order.Type == OrderType.Limit) { // limit order posted to the order book unitPrice = ((LimitOrder)order).LimitPrice; } unitPrice *= security.QuoteCurrency.ConversionRate * security.SymbolProperties.ContractMultiplier; // apply fee factor, currently we do not model 30-day volume, so we use the first tier return(unitPrice * order.AbsoluteQuantity * fee); }
/// <summary> /// Get the fee for this order in units of the account currency /// </summary> /// <param name="security">The security matching the order</param> /// <param name="order">The order to compute fees for</param> /// <returns>The cost of the order in units of the account currency</returns> public decimal GetOrderFee(Securities.Security security, Order order) { if (order.Type == OrderType.Limit) { // marketable limit orders are considered takers var limitPrice = ((LimitOrder)order).LimitPrice; if (order.Direction == OrderDirection.Buy && limitPrice < security.AskPrice || order.Direction == OrderDirection.Sell && limitPrice > security.BidPrice) { // limit order posted to the order book, 0% fee return(0m); } } // currently we do not model daily rebates decimal fee; Fees.TryGetValue(security.Symbol.Value, out fee); // get order value in account currency, then apply fee factor var unitPrice = order.Direction == OrderDirection.Buy ? security.AskPrice : security.BidPrice; unitPrice *= security.QuoteCurrency.ConversionRate * security.SymbolProperties.ContractMultiplier; return(unitPrice * order.AbsoluteQuantity * fee); }
/// <summary> /// Get the fee for this order /// </summary> /// <param name="security">The security matching the order</param> /// <param name="order">The order to compute fees for</param> /// <returns>The cost of the order in units of the account currency</returns> public decimal GetOrderFee(Securities.Security security, Order order) { //0% maker fee after reimbursement. if (order.Type == OrderType.Limit) { return(0m); } //todo: fee scaling with trade size var divisor = 0.0025m; decimal fee = security.Price * (order.Quantity < 0 ? (order.Quantity * -1) : order.Quantity) * divisor; return(fee); }
/// <summary> /// Get the fee for this order /// </summary> /// <param name="security">The security matching the order</param> /// <param name="order">The order to compute fees for</param> /// <returns>The cost of the order in units of the account currency</returns> public decimal GetOrderFee(Securities.Security security, Order order) { //0% maker fee after reimbursement. if (order.Type == OrderType.Limit) { return(0m); } // currently we do not model daily rebates decimal fee; Fees.TryGetValue(security.Symbol.Value, out fee); return(security.Price * order.AbsoluteQuantity * fee); }
/// <summary> /// Get the fee for this order in units of the account currency /// </summary> /// <param name="security">The security matching the order</param> /// <param name="order">The order to compute fees for</param> /// <returns>The cost of the order in units of the account currency</returns> public decimal GetOrderFee(Securities.Security security, Order order) { //0% maker fee after reimbursement. if (order.Type == OrderType.Limit) { return(0m); } // currently we do not model daily rebates decimal fee; Fees.TryGetValue(security.Symbol.Value, out fee); // get order value in account currency, then apply fee factor return(Math.Abs(order.GetValue(security)) * fee); }
/// <summary> /// Get the fee for this order in units of the account currency /// </summary> /// <param name="security">The security matching the order</param> /// <param name="order">The order to compute fees for</param> /// <returns>The cost of the order in units of the account currency</returns> public decimal GetOrderFee(Securities.Security security, Order order) { // marketable limit orders are considered takers if (order.Type == OrderType.Limit && !order.IsMarketable) { // limit order posted to the order book, 0% maker fee return(0m); } // get order value in account currency, then apply taker fee factor var unitPrice = order.Direction == OrderDirection.Buy ? security.AskPrice : security.BidPrice; unitPrice *= security.QuoteCurrency.ConversionRate * security.SymbolProperties.ContractMultiplier; // currently we do not model 30-day volume, so we use the first tier return(unitPrice * order.AbsoluteQuantity * TakerFee); }
/// <summary> /// Get the fee for this order in units of the account currency /// </summary> /// <param name="security">The security matching the order</param> /// <param name="order">The order to compute fees for</param> /// <returns>The cost of the order in units of the account currency</returns> public decimal GetOrderFee(Securities.Security security, Order order) { //0% maker fee after reimbursement. if (order.Type == OrderType.Limit) { return(0m); } // currently we do not model daily rebates decimal fee; Fees.TryGetValue(security.Symbol.Value, out fee); // get order value in account currency, then apply fee factor var unitPrice = order.Direction == OrderDirection.Buy ? security.AskPrice : security.BidPrice; unitPrice *= security.QuoteCurrency.ConversionRate * security.SymbolProperties.ContractMultiplier; return(unitPrice * order.AbsoluteQuantity * fee); }
public int Publish_to_ESP2() { int successValue = 0; /***************************************deal with security******************************************/ List <ESP2.Securities.Security> esp2_secList = ESP2.Securities.SecurityMaster.Get_secList_cusip(this.CUSIP.Value); ESP2.Securities.Security esp2_sec = null; if (esp2_secList.Count < 1) { Securities.Security drwin_sec = this.Get_security(); if (drwin_sec == null) { return(-1); } ESP2.Securities.Security new_esp2_sec = new ESP2.Securities.Security(); new_esp2_sec.Init_from_DRWIN_sec(drwin_sec); if (new_esp2_sec.Insert_to_DB()) { successValue += 1; } } else { esp2_sec = esp2_secList[0]; } if (esp2_sec == null)//try get esp2 security again { esp2_secList = ESP2.Securities.SecurityMaster.Get_secList_cusip(this.CUSIP.Value); if (esp2_secList.Count < 1) { return(-2); } else { esp2_sec = esp2_secList[0]; } } /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ Event esp2_event = new Event(); esp2_event.Init_from_Dividend(this); esp2_event.security_id.Value = esp2_sec.security_id; /***************************************deal with depository******************************************/ DepositaryInfo depoInfo = DepositaryInfoMaster.GetDepo_by_name(this.Depositary.Value); if (depoInfo == null) { DepositaryInfo new_depo = new DepositaryInfo(); Depositaries.Depositary drwin_depo = Depositaries.DepositaryMaster.GetDepositary_by_name(this.Depositary.Value); new_depo.Init_from_DRWIN_depo(drwin_depo); new_depo.Insert_to_DB(); DepositaryInfoMaster.Reset(); depoInfo = DepositaryInfoMaster.GetDepo_by_name(this.Depositary.Value); if (depoInfo == null) { return(-3); } DepositaryIdemnification di = new DepositaryIdemnification(); di.Init_from_DRWIN_depo(drwin_depo); di.depositary_info_id.Value = depoInfo.depositary_info_id; di.Insert_to_DB(); } /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ esp2_event.depositary_info_id.Value = depoInfo.depositary_info_id;//depositary info Dictionary <int, DividendCustodian> cust_dic = this.Get_dvdCust_dic(null); DividendCustodian primary_DRWIN_cust = null; foreach (DividendCustodian dvdCust in cust_dic.Values) { if (dvdCust.Custodian_Number.Value < 0) { continue; } if (dvdCust.Custodian_Type.Value.StartsWith("custodian", StringComparison.OrdinalIgnoreCase)) { primary_DRWIN_cust = dvdCust; break; } } if (primary_DRWIN_cust == null) { return(-4); } else { if (esp2_event.Insert_to_DB()) { successValue += 2; } else { return(-5); } } /*******************************deal with dividend custodian************************************/ Event inserted_esp2event = EventMaster.GetEvent_DividendIndex(this.DividendIndex); if (inserted_esp2event == null) { return(-6); } Country cty = CountryMaster.GetCountry_name(this.Country.Value); if (cty == null) { return(-7); } PrimaryCustodian pc = new PrimaryCustodian(); pc.Init_from_DRWIN_dvdCust(primary_DRWIN_cust, cty, inserted_esp2event); pc.Insert_to_DB(); EventContactInfo eci = new EventContactInfo(); eci.Init_from_DRWIN_dvdCust(primary_DRWIN_cust, cty, inserted_esp2event); eci.Insert_to_DB(); /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ return(successValue); }