private double ComputeProcentOfProfit(Instrument instrument, decimal volumen, double amountOfCash, double takeProfit) { var valueOfOnePips = instrument.ComputeValueOfOnePips(volumen, instrument.Valuation.BidPrice); var valueOfTransactionProfit = valueOfOnePips * takeProfit; var percentOfProfit = valueOfTransactionProfit / amountOfCash * 100; return(percentOfProfit); }
public void CloseTransaction(double closePrice, DateTime dateClose) { if (ClosePrice != null) { throw new DomainException("Is not possible to close transaction twice."); } ClosePrice = closePrice; DateClose = dateClose; ProfitPips = ComputeProfitInPips(closePrice); var valueOfOnePips = (decimal)Instrument.ComputeValueOfOnePips(Position.Volumen, Position.OpenPrice); SetProfit(Math.Round(valueOfOnePips * ProfitPips, 2)); }
public void Should_return_value_of_one_pips_equal_to_656dot34_when_give_0dot01_volument_on_index_EURUSD() { var symbol = "EURUSD"; var categoryName = CategoryName.Forex; var contractSize = 100000; var bidPrice = 1.12451; var askPrice = 1.1246; var currency = "EUR"; var laverage = 3.33; var precision = 5; var spread = 1; var valuation = new Valuation(bidPrice, askPrice); var instrument = new Instrument(symbol, categoryName, currency, valuation, new TimeSpan(02, 00, 00)); instrument.SetContractSize(contractSize); instrument.SetLeverage(laverage); instrument.SetPrecision(precision); instrument.SetSpread(spread); var valueOfOnePips = instrument.ComputeValueOfOnePips(0.01M, instrument.Valuation.BidPrice); Assert.Equal(0.38, valueOfOnePips); }
public void Should_return_value_of_one_pips_equal_to_1dot075_when_give_0dot01_volument_on_index_DE30() { var symbol = "DE30"; var categoryName = CategoryName.Index; var contractSize = 25; var bidPrice = 12265.3; var askPrice = 12267.8; var currency = "EUR"; var laverage = 5; var precision = 1; var spread = 1; var valuation = new Valuation(bidPrice, askPrice); var instrument = new Instrument(symbol, categoryName, currency, valuation, new TimeSpan(02, 00, 00)); instrument.SetContractSize(contractSize); instrument.SetLeverage(laverage); instrument.SetPrecision(precision); instrument.SetSpread(spread); var valueOfOnePips = instrument.ComputeValueOfOnePips(0.01M, instrument.Valuation.BidPrice); Assert.Equal(1.08, valueOfOnePips); }