Ejemplo n.º 1
0
        /// <summary>
        /// Calculate order size for signal order
        /// </summary>
        /// <param name="ticket"></param>
        /// <param name="state"></param>
        /// <param name="weight"></param>
        /// <returns></returns>
        public override decimal OrderQuantity(SubmitOrderTicket ticket, SecurityState state, decimal weight)
        {
            //Get the needed weight (instead of the supplied weight we get from the universe, we change it to reflect our own weight)
            if (_adjustedweights.ContainsKey(ticket.Security))
            {
                var oldweight = weight;
                weight = _adjustedweights[ticket.Security];
                Info($"Adjusted weight from {oldweight}, to {weight}");
            }
            else
            {
                Warning($"Could not adjust weight, could not find security {ticket.Security}");
            }

            //Get target amount
            decimal target = TargetWeight(ticket.Security,
                                          (state == SecurityState.EntryShort ? -1 : state == SecurityState.EntryLong ? 1 : 0) * weight);

            //Check if target is valid
            if (target == 0)
            {
                ticket.Cancel();
                return(0);
            }
            else
            {
                return(target);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Calculate order size for signal order
        /// </summary>
        /// <param name="ticket"></param>
        /// <param name="state"></param>
        /// <param name="weight"></param>
        /// <returns></returns>
        public override decimal OrderQuantity(SubmitOrderTicket ticket, SecurityState state, decimal weight)
        {
            //Get target amount
            decimal target = TargetWeight(ticket.Security,
                                          (state == SecurityState.EntryShort ? -1 : state == SecurityState.EntryLong ? 1 : 0) * weight);

            //Check if target is valid
            if (target == 0)
            {
                ticket.Cancel();
                return(0);
            }
            else
            {
                return(target);
            }
        }