public double CloseExistingPosAndGetFixedPnL(TradeBlotter blotter)
        {
            double result = PosCalcsRoudning(CalcCurrentPnL(blotter));

            Quantity = 0;
            return(result);
        }
        public double CalcCurrentPnL(double price)
        {
            TradeBlotter tradeBlotter = new TradeBlotter();

            tradeBlotter.AskPrice = price;
            tradeBlotter.BidPrice = price;
            return(CalcCurrentPnL(tradeBlotter));
        }
Ejemplo n.º 3
0
        public static Futures GetFakeFutures(double enterFutPrice, int futPosition, TradeBlotter blotter, double priceStep, double priceVal)
        {
            Futures fut = new Futures("", DateTime.Now, 0.0, 0.0, priceStep, priceVal);

            fut.AssignTradeBlotter(blotter);
            fut.Position.Quantity   = futPosition;
            fut.Position.EnterPrice = enterFutPrice;
            return(fut);
        }
Ejemplo n.º 4
0
 public void AssignTradeBlotter(TradeBlotter blotter)
 {
     if (blotter != null)
     {
         this.blotter = blotter;
     }
     else
     {
         throw new BasicModelException("Passed blotter to futures is null: " + blotter);
     }
 }
 public double GetMarketPriceToClose(TradeBlotter blotter)
 {
     if (Quantity > 0)
     {
         return(blotter.BidPrice);
     }
     else if (Quantity < 0)
     {
         return(blotter.AskPrice);
     }
     else
     {
         return(0.0);
     }
 }
 public double CalcCurrentPnL(TradeBlotter blotter)
 {
     if (Quantity > 0)
     {
         return(PosCalcsRoudning((blotter.BidPrice - EnterPrice) * Quantity));
     }
     else if (Quantity < 0)
     {
         return(PosCalcsRoudning((blotter.AskPrice - EnterPrice) * Quantity));
     }
     else
     {
         return(0.0);
     }
 }
Ejemplo n.º 7
0
        public static Option GetFakeOption(OptionType type, double strike, double enterOptPrice,
                                           double remainingDays, int optPosition, TradeBlotter futBlotter, TradeBlotter optBlotter, double priceStep, double priceVal)
        {
            Futures fut = Futures.GetFakeFutures(0.0, 0, futBlotter, priceStep, priceVal);

            Option option = new Option(fut, type, strike, 0.0, 0.0, 0.0, "", priceStep, priceVal, DateTime.Now, remainingDays);

            option.AssignTradeBlotter(optBlotter);
            option.Position.EnterPrice = enterOptPrice;
            option.Position.Quantity   = optPosition;

            option.UpdateAllGreeksTogether();

            return(option);
        }
        public double CalculateExpirationPnL(double futPrice)
        {
            double tempPnL = 0.0;

            TradeBlotter tempBlotter = new TradeBlotter();

            tempBlotter.AskPrice = futPrice;
            tempBlotter.BidPrice = futPrice;

            tempPnL += Futures == null ? 0.0 : Futures.Position.CalcCurrentPnL(tempBlotter);
            tempPnL += FixedPnL;

            foreach (Option opt in Options)
            {
                tempPnL += GreeksCalculator.CalculateOptionPnLOnExpiration(opt, futPrice);
            }

            return(tempPnL);
        }
 public double CalcCurrentPnLInCurrency(TradeBlotter blotter, double step, double stepVal)
 {
     return(PosCalcsRoudning(CalcCurrentPnL(blotter) / step * stepVal));
 }