Example #1
0
        /// <param name="quantity">Non absolute quantity of the trade</param>
        public static Trade CalculateTrade(BuyStyle style, double from, double to, long timefrom, long timeto, int quantity)
        {
            if (quantity == 0)
            {
                return(new Trade()
                {
                    Profit = 0,
                    Quantity = 0,
                    From = Convert.ToSingle(from),
                    To = Convert.ToSingle(to),
                    EntryTime = timefrom,
                    ExitTime = timeto,
                    TradeState = style == BuyStyle.Long ? TradeState.Longing : TradeState.Shorting
                });
            }

            return(new Trade()
            {
                Profit = Convert.ToSingle(quantity * to - quantity * @from),
                From = Convert.ToSingle(from),
                To = Convert.ToSingle(to),
                EntryTime = timefrom,
                ExitTime = timeto,
                Quantity = quantity,
                TradeState = style == BuyStyle.Long ? TradeState.Longing : TradeState.Shorting
            });
        }
Example #2
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();

            m_StylistChairLoc         = reader.ReadPoint3D();
            m_CutAnimInterval         = reader.ReadTimeSpan();
            m_CutTime                 = reader.ReadTimeSpan();
            m_AllowFemalesBuyingBeard = reader.ReadBool();
            m_PlayScissorSound        = reader.ReadBool();
            m_DropResidueHair         = reader.ReadBool();
            m_NeedsToBeDismounted     = reader.ReadBool();
            m_FreezeCustomer          = reader.ReadBool();
            m_DropHairWhenBald        = reader.ReadBool();
            m_NeedsPeaceForCut        = reader.ReadBool();
            m_UseExtensionSystem      = reader.ReadBool();
            m_HurtOnMove              = reader.ReadBool();
            m_MovementOption          = (MovementOptions)reader.ReadInt();
            m_VendorBuyMethod         = (BuyStyle)reader.ReadInt();

            if (m_VendorBuyMethod == BuyStyle.BuyMenuAndSpeech || m_VendorBuyMethod == BuyStyle.GumpMenuAndSpeech || m_VendorBuyMethod == BuyStyle.SpeechOnly)
            {
                BuildStyleNames();
            }
        }
Example #3
0
 public static double LimitAtProfit(BuyStyle style, double price, int quantity, float profitPrecentage)
 {
     if (quantity == 0)
     {
         throw new ArgumentOutOfRangeException(nameof(quantity));
     }
     return(Math.Round(price * (1 + (style == BuyStyle.Long ? 1 : -1) * ((double)profitPrecentage / 100d)), 2));
 }
Example #4
0
 public static double EntryPrice(BuyStyle style, TickValue tick)
 {
     if (style == BuyStyle.Long)
     {
         return(tick.AskPrice);
     }
     else
     {
         return(tick.BidPrice);
     }
 }
Example #5
0
 public static double ExitPrice(this TickValue tick, BuyStyle style)
 {
     if (style == BuyStyle.Long)
     {
         return(tick.BidPrice);
     }
     else
     {
         return(tick.AskPrice);
     }
 }
Example #6
0
 public static (double Profit, int Quantity) CalculateProfit(BuyStyle style, double from, TickValue to, int quantity)
 {
     if (style == BuyStyle.Long)
     {
         return(CalculateProfit(BuyStyle.Long, from, to.BidPrice, quantity));
     }
     else
     {
         //short
         return(CalculateProfit(BuyStyle.Short, from, to.AskPrice, quantity));
     }
 }
Example #7
0
 public static (float Profit, int Quantity) CalculateProfit(BuyStyle style, float from, TickValue to, float budget)
 {
     if (style == BuyStyle.Long)
     {
         return(CalculateProfit(BuyStyle.Long, from, (float)to.BidPrice, budget));
     }
     else
     {
         //short
         return(CalculateProfit(BuyStyle.Short, from, (float)to.AskPrice, budget));
     }
 }
Example #8
0
 public static (float Profit, int Quantity) CalculateProfit(BuyStyle style, TickValue from, float to, int quantity)
 {
     if (style == BuyStyle.Long)
     {
         return(CalculateProfit(BuyStyle.Long, (float)from.AskPrice, to, quantity));
     }
     else
     {
         //short
         return(CalculateProfit(BuyStyle.Short, (float)from.BidPrice, to, quantity));
     }
 }
Example #9
0
 public static (double Profit, int Quantity) CalculateProfit(BuyStyle style, TickValue from, double to, double budget)
 {
     if (style == BuyStyle.Long)
     {
         return(CalculateProfit(BuyStyle.Long, from.AskPrice, to, budget));
     }
     else
     {
         //short
         return(CalculateProfit(BuyStyle.Short, from.BidPrice, to, budget));
     }
 }
Example #10
0
 public static Trade CalculateTrade(BuyStyle style, long fromTime, TickValue from, long toTime, TickValue to, double budget)
 {
     if (style == BuyStyle.Long)
     {
         return(CalculateTrade(BuyStyle.Long, from.AskPrice, to.BidPrice, fromTime, toTime, budget));
     }
     else
     {
         //short
         return(CalculateTrade(BuyStyle.Short, from.BidPrice, to.AskPrice, fromTime, toTime, budget));
     }
 }
Example #11
0
 public static int CalculateQuantity(BuyStyle style, TickValue from, double budget)
 {
     if (style == BuyStyle.Long)
     {
         return(CalculateQuantity(BuyStyle.Long, from.AskPrice, budget));
     }
     else
     {
         //short
         return(CalculateQuantity(BuyStyle.Short, from.BidPrice, budget));
     }
 }
Example #12
0
        /// <param name="style">The trade style</param>
        /// <param name="price">Price of the stock</param>
        /// <param name="quantity">Absolute quantity</param>
        /// <param name="profitDollar">Profit in dollars, can be negative if loss planned</param>
        /// <returns></returns>
        public static double LimitAtProfit(BuyStyle style, TickValue tick, int quantity, double profitDollar)
        {
            if (quantity == 0)
            {
                throw new ArgumentOutOfRangeException(nameof(quantity));
            }
            quantity = Math.Abs(quantity);

            //161*(1+0.05/100)
            var mod           = style == BuyStyle.Long ? 1 : -1;
            var balance       = (style == BuyStyle.Long ? tick.AskPrice : tick.BidPrice) * quantity;
            var targetbalance = balance + mod * profitDollar;
            var targetPrice   = targetbalance / quantity;

            return(Math.Round(targetPrice, 2));
        }
Example #13
0
 public static (double Profit, int Quantity) CalculateProfit(BuyStyle style, double from, double to, double budget)
 {
     return(CalculateProfit(style, from, to, CalculateQuantity(style, from, budget)));
 }
Example #14
0
 public static (double Profit, int Quantity) CalculateProfit(BuyStyle style, double from, double to, int quantity)
 {
     return(quantity * to - quantity * @from, quantity);
 }
Example #15
0
 public static int CalculateQuantity(BuyStyle style, float from, double budget)
 {
     return((style == BuyStyle.Long ? 1 : -1) * (Math.Abs(@from) < 0.00001f ? 0 : Convert.ToInt32(Math.Floor(budget / (double)@from))));
 }
Example #16
0
 public static int CalculateQuantity(BuyStyle style, double from, double budget)
 {
     return((style == BuyStyle.Long ? 1 : -1) * (from == 0 ? 0 : Convert.ToInt32(Math.Floor(budget / from))));
 }
Example #17
0
 public static (float Profit, int Quantity) CalculateProfit(BuyStyle style, float from, float to, float budget)
 {
     return(CalculateProfit(style, from, to, CalculateQuantity(style, from, budget)));
 }
Example #18
0
 public static (float Profit, int Quantity) CalculateProfit(BuyStyle style, float from, float to, int quantity)
 {
     return(quantity * to - quantity * @from, quantity);
 }
Example #19
0
 public static Trade CalculateTrade(BuyStyle style, double from, double to, long timefrom, long timeto, double budget)
 {
     return(CalculateTrade(style, from, to, timefrom, timeto, CalculateQuantity(style, from, budget)));
 }
Example #20
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();

            m_StylistChairLoc = reader.ReadPoint3D();
            m_CutAnimInterval = reader.ReadTimeSpan();
            m_CutTime = reader.ReadTimeSpan();
            m_AllowFemalesBuyingBeard = reader.ReadBool();
            m_PlayScissorSound = reader.ReadBool();
            m_DropResidueHair = reader.ReadBool();
            m_NeedsToBeDismounted = reader.ReadBool();
            m_FreezeCustomer = reader.ReadBool();
            m_DropHairWhenBald = reader.ReadBool();
            m_NeedsPeaceForCut = reader.ReadBool();
            m_UseExtensionSystem = reader.ReadBool();
            m_HurtOnMove = reader.ReadBool();
            m_MovementOption = (MovementOptions)reader.ReadInt();
            m_VendorBuyMethod =(BuyStyle)reader.ReadInt();

            if (m_VendorBuyMethod == BuyStyle.BuyMenuAndSpeech || m_VendorBuyMethod == BuyStyle.GumpMenuAndSpeech || m_VendorBuyMethod == BuyStyle.SpeechOnly)
                BuildStyleNames();
        }