public void ReturnsTakerFeeInQuoteCurrency(decimal quantity) { //{ // "channel": "fills", // "type": "update", // "data": { // "id": 4199228419, // "market": "XRP/USDT", // "future": null, // "baseCurrency": "XRP", // "quoteCurrency": "USDT", // "type": "order", // "side": "sell", // "price": 1.07225, // "size": 10, // "orderId": 85922585621, // "time": "2021-10-07T19:25:45.411201+00:00", // "tradeId": 2084391649, // "feeRate": 0.0007, // "fee": 0.00750575, // "feeCurrency": "USDT", // "liquidity": "taker" // } //} //{ // "channel": "fills", // "type": "update", // "data": { // "id": 4199574804, // "market": "XRP/USDT", // "future": null, // "baseCurrency": "XRP", // "quoteCurrency": "USDT", // "type": "order", // "side": "buy", // "price": 1.075725, // "size": 1, // "orderId": 85928918834, // "time": "2021-10-07T20:02:07.116972+00:00", // "tradeId": 2084563562, // "feeRate": 0.0007, // "fee": 0.0007530075, // "feeCurrency": "USDT", // "liquidity": "taker" // } //} var fee = _feeModel.GetOrderFee( new OrderFeeParameters( _ethusd, new MarketOrder(_ethusd.Symbol, quantity, DateTime.UtcNow) ) ); Assert.AreEqual(_ethusd.QuoteCurrency.Symbol, fee.Value.Currency); // 100 (price) * 0.0007 (taker fee, in quote currency) Assert.AreEqual(0.07m, fee.Value.Amount); }
public void ReturnsFeeInQuoteCurrencyInAccountCurrency() { var fee = _feeModel.GetOrderFee( new OrderFeeParameters( _btcusd, new MarketOrder(_btcusd.Symbol, 1, DateTime.UtcNow) ) ); Assert.AreEqual(Currencies.USD, fee.Value.Currency); // 100 (price) * 0.002 (taker fee) Assert.AreEqual(0.2m, fee.Value.Amount); }
/// <summary> /// Gets the order fee associated with the specified order. This returns the cost /// of the transaction in the account currency /// </summary> /// <param name="model">The fee model</param> /// <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 static decimal GetOrderFee(this IFeeModel model, Security security, Order order) { var parameters = new OrderFeeParameters(security, order, security.QuoteCurrency.Symbol); var fee = model.GetOrderFee(parameters); return(fee.Value.Amount); }
public void ReturnsFeeInQuoteCurrencyInAccountCurrency() { var fee = _feeModel.GetOrderFee( new OrderFeeParameters( _sbininr, new MarketOrder(_sbininr.Symbol, 1, DateTime.Now) ) ); Assert.AreEqual(Currencies.INR, fee.Value.Currency); Assert.AreEqual(0.04m, fee.Value.Amount); }
/// <summary> /// Gets the order fee associated with the specified order. This returns the cost /// of the transaction in the account currency /// </summary> /// <param name="model">The fee model</param> /// <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 static decimal GetOrderFee(this IFeeModel model, Security security, Order order) { var parameters = new OrderFeeParameters(security, order); var fee = model.GetOrderFee(parameters); if (fee.Value.Currency != security.QuoteCurrency.AccountCurrency) { throw new InvalidOperationException("The GetOrderFee extension method is only valid" + " for fee models returning fees in the account currency"); } return(fee.Value.Amount); }
public void ReturnsFeeInQuoteCurrencyInAccountCurrency(decimal quantity) { var fee = _feeModel.GetOrderFee( new OrderFeeParameters( _btcusd, new MarketOrder(_btcusd.Symbol, quantity, DateTime.UtcNow) ) ); if (quantity > 0) { Assert.AreEqual("BTC", fee.Value.Currency); // 1 (quantity) * 0.002 (taker fee) Assert.AreEqual(0.002m, fee.Value.Amount); } else { Assert.AreEqual(Currencies.USD, fee.Value.Currency); // 100 (price) * 0.002 (taker fee) Assert.AreEqual(0.2m, fee.Value.Amount); } }
public void USAEquityMinimumFeeInUSD() { var security = SecurityTests.GetSecurity(); security.SetMarketPrice(new Tick(DateTime.UtcNow, security.Symbol, 100, 100)); var fee = _feeModel.GetOrderFee( new OrderFeeParameters( security, new MarketOrder(security.Symbol, 1, DateTime.UtcNow) ) ); Assert.AreEqual(Currencies.USD, fee.Value.Currency); Assert.AreEqual(1m, fee.Value.Amount); }
/// <summary> /// Default implementation returns 0 for fees. /// </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 virtual decimal GetOrderFee(Security security, Order order) { return(_feeModel.GetOrderFee(security, order)); }