Ejemplo n.º 1
0
 protected OrderTestParameters(Symbol symbol, IOrderProperties properties = null, OrderSubmissionData orderSubmissionData = null)
 {
     Symbol              = symbol;
     SecurityType        = symbol.ID.SecurityType;
     Properties          = properties;
     OrderSubmissionData = orderSubmissionData;
 }
Ejemplo n.º 2
0
 protected OrderTestParameters(Symbol symbol, IOrderProperties properties = null, OrderSubmissionData orderSubmissionData = null)
 {
     Symbol              = symbol;
     SecurityType        = symbol.ID.SecurityType;
     Properties          = properties;
     OrderSubmissionData = orderSubmissionData;
     SPDB = SymbolPropertiesDatabase.FromDataFolder();
 }
 public LimitIfTouchedOrderTestParameters(
     Symbol symbol,
     decimal highLimit,
     decimal lowLimit,
     IOrderProperties properties = null
     )
     : base(symbol, properties)
 {
     _highLimit = highLimit;
     _lowLimit  = lowLimit;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="SubmitOrderRequest"/> class.
 /// The <see cref="OrderRequest.OrderId"/> will default to <see cref="OrderResponseErrorCode.UnableToFindOrder"/>
 /// </summary>
 /// <param name="orderType">The order type to be submitted</param>
 /// <param name="securityType">The symbol's <see cref="SecurityType"/></param>
 /// <param name="symbol">The symbol to be traded</param>
 /// <param name="quantity">The number of units to be ordered</param>
 /// <param name="stopPrice">The stop price for stop orders, non-stop orers this value is ignored</param>
 /// <param name="limitPrice">The limit price for limit orders, non-limit orders this value is ignored</param>
 /// <param name="time">The time this request was created</param>
 /// <param name="tag">A custom tag for this request</param>
 /// <param name="properties">The order properties for this request</param>
 public SubmitOrderRequest(OrderType orderType, SecurityType securityType, Symbol symbol, decimal quantity, decimal stopPrice, decimal limitPrice, DateTime time, string tag, IOrderProperties properties = null)
     : base(time, (int)OrderResponseErrorCode.UnableToFindOrder, tag)
 {
     SecurityType    = securityType;
     Symbol          = symbol;
     OrderType       = orderType;
     Quantity        = quantity;
     LimitPrice      = limitPrice;
     StopPrice       = stopPrice;
     OrderProperties = properties;
 }
Ejemplo n.º 5
0
 public LimitIfTouchedOrderTestParameters(
     Symbol symbol,
     decimal highLimit,
     decimal lowLimit,
     IOrderProperties properties             = null,
     OrderSubmissionData orderSubmissionData = null
     )
     : base(symbol, properties, orderSubmissionData)
 {
     _highLimit = highLimit;
     _lowLimit  = lowLimit;
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SubmitOrderRequest"/> class.
 /// The <see cref="OrderRequest.OrderId"/> will default to <see cref="OrderResponseErrorCode.UnableToFindOrder"/>
 /// </summary>
 /// <param name="orderType">The order type to be submitted</param>
 /// <param name="securityType">The symbol's <see cref="SecurityType"/></param>
 /// <param name="symbol">The symbol to be traded</param>
 /// <param name="quantity">The number of units to be ordered</param>
 /// <param name="stopPrice">The stop price for stop orders, non-stop orers this value is ignored</param>
 /// <param name="limitPrice">The limit price for limit orders, non-limit orders this value is ignored</param>
 /// <param name="time">The time this request was created</param>
 /// <param name="tag">A custom tag for this request</param>
 /// <param name="properties">The order properties for this request</param>
 public SubmitOrderRequest(
     OrderType orderType,
     SecurityType securityType,
     Symbol symbol,
     decimal quantity,
     decimal stopPrice,
     decimal limitPrice,
     DateTime time,
     string tag,
     IOrderProperties properties = null
     )
     : this(orderType, securityType, symbol, quantity, stopPrice, limitPrice, 0, time, tag, properties)
 {
 }
Ejemplo n.º 7
0
 /// <summary>
 /// New order constructor
 /// </summary>
 /// <param name="symbol">Symbol asset we're seeking to trade</param>
 /// <param name="quantity">Quantity of the asset we're seeking to trade</param>
 /// <param name="time">Time the order was placed</param>
 /// <param name="tag">User defined data tag for this order</param>
 /// <param name="properties">The order properties for this order</param>
 protected Order(Symbol symbol, decimal quantity, DateTime time, string tag = "", IOrderProperties properties = null)
 {
     Time          = time;
     Price         = 0;
     PriceCurrency = string.Empty;
     Quantity      = quantity;
     Symbol        = symbol;
     Status        = OrderStatus.None;
     Tag           = tag;
     Duration      = OrderDuration.GTC;
     BrokerId      = new List <string>();
     ContingentId  = 0;
     DurationValue = DateTime.MaxValue;
     Properties    = properties;
 }
Ejemplo n.º 8
0
        private static Order CreateOrder(int orderId, OrderType type, Symbol symbol, decimal quantity, DateTime time,
                                         string tag, IOrderProperties properties, decimal limitPrice, decimal stopPrice, decimal triggerPrice)
        {
            Order order;

            switch (type)
            {
            case OrderType.Market:
                order = new MarketOrder(symbol, quantity, time, tag, properties);
                break;

            case OrderType.Limit:
                order = new LimitOrder(symbol, quantity, limitPrice, time, tag, properties);
                break;

            case OrderType.StopMarket:
                order = new StopMarketOrder(symbol, quantity, stopPrice, time, tag, properties);
                break;

            case OrderType.StopLimit:
                order = new StopLimitOrder(symbol, quantity, stopPrice, limitPrice, time, tag, properties);
                break;

            case OrderType.LimitIfTouched:
                order = new LimitIfTouchedOrder(symbol, quantity, triggerPrice, limitPrice, time, tag, properties);
                break;

            case OrderType.MarketOnOpen:
                order = new MarketOnOpenOrder(symbol, quantity, time, tag, properties);
                break;

            case OrderType.MarketOnClose:
                order = new MarketOnCloseOrder(symbol, quantity, time, tag, properties);
                break;

            case OrderType.OptionExercise:
                order = new OptionExerciseOrder(symbol, quantity, time, tag, properties);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            order.Status = OrderStatus.New;
            order.Id     = orderId;
            return(order);
        }
Ejemplo n.º 9
0
 /// <summary>
 /// New <see cref="LimitIfTouchedOrder"/> constructor.
 /// </summary>
 /// <param name="symbol">Symbol asset we're seeking to trade</param>
 /// <param name="quantity">Quantity of the asset we're seeking to trade</param>
 /// <param name="limitPrice">Maximum price to fill the order</param>
 /// <param name="time">Time the order was placed</param>
 /// <param name="triggerPrice">Price which must be touched in order to then set a limit order</param>
 /// <param name="tag">User defined data tag for this order</param>
 /// <param name="properties">The order properties for this order</param>
 public LimitIfTouchedOrder(
     Symbol symbol,
     decimal quantity,
     decimal?triggerPrice,
     decimal limitPrice,
     DateTime time,
     string tag = "",
     IOrderProperties properties = null
     )
     : base(symbol, quantity, time, tag, properties)
 {
     TriggerPrice = (decimal)triggerPrice;
     LimitPrice   = limitPrice;
     if (string.IsNullOrEmpty(tag))
     {
         //Default tag values to display trigger price in GUI.
         Tag = Invariant($"Trigger Price: {triggerPrice:C} Limit Price: {limitPrice:C}");
     }
 }
 /// <summary>
 /// Intiializes a new instance of the <see cref="MarketOnCloseOrder"/> class.
 /// </summary>
 /// <param name="symbol">The security's symbol being ordered</param>
 /// <param name="quantity">The number of units to order</param>
 /// <param name="time">The current time</param>
 /// <param name="tag">A user defined tag for the order</param>
 /// <param name="properties">The order properties for this order</param>
 public MarketOnCloseOrder(Symbol symbol, decimal quantity, DateTime time, string tag = "", IOrderProperties properties = null)
     : base(symbol, quantity, time, tag, properties)
 {
 }
Ejemplo n.º 11
0
        /// <summary>
        /// New Stop Market Order constructor -
        /// </summary>
        /// <param name="symbol">Symbol asset we're seeking to trade</param>
        /// <param name="quantity">Quantity of the asset we're seeking to trade</param>
        /// <param name="time">Time the order was placed</param>
        /// <param name="stopPrice">Price the order should be filled at if a limit order</param>
        /// <param name="tag">User defined data tag for this order</param>
        /// <param name="properties">The order properties for this order</param>
        public StopMarketOrder(Symbol symbol, decimal quantity, decimal stopPrice, DateTime time, string tag = "", IOrderProperties properties = null)
            : base(symbol, quantity, time, tag, properties)
        {
            StopPrice = stopPrice;

            if (string.IsNullOrEmpty(tag))
            {
                //Default tag values to display stop price in GUI.
                Tag = Invariant($"Stop Price: {stopPrice:C}");
            }
        }
Ejemplo n.º 12
0
 public MarketOrderTestParameters(Symbol symbol, IOrderProperties properties = null)
     : base(symbol, properties)
 {
 }
Ejemplo n.º 13
0
 private SubmitOrderRequest CreateSubmitOrderRequest(OrderType orderType, Security security, decimal quantity, string tag, IOrderProperties properties, decimal stopPrice = 0m, decimal limitPrice = 0m)
 {
     return new SubmitOrderRequest(orderType, security.Type, security.Symbol, quantity, stopPrice, limitPrice, UtcTime, tag, properties);
 }
Ejemplo n.º 14
0
        /// <summary>
        /// New Stop Market Order constructor -
        /// </summary>
        /// <param name="symbol">Symbol asset we're seeking to trade</param>
        /// <param name="quantity">Quantity of the asset we're seeking to trade</param>
        /// <param name="limitPrice">Maximum price to fill the order</param>
        /// <param name="time">Time the order was placed</param>
        /// <param name="stopPrice">Price the order should be filled at if a limit order</param>
        /// <param name="expiryDate">Timespan till the expiry of the order</param>
        /// <param name="tag">User defined data tag for this order</param>
        /// <param name="properties">The order properties for this order</param>
        public StopLimitOrder(Symbol symbol, decimal quantity, decimal stopPrice, decimal limitPrice, DateTime time, DateTime?expiryDate = null, string tag = "", IOrderProperties properties = null)
            : base(symbol, quantity, time, expiryDate, tag, properties: properties)
        {
            StopPrice  = stopPrice;
            LimitPrice = limitPrice;

            if (tag == "")
            {
                //Default tag values to display stop price in GUI.
                Tag = Invariant($"Stop Price: {stopPrice:C} Limit Price: {limitPrice:C}");
            }
        }
Ejemplo n.º 15
0
 /// <summary>
 /// New order constructor
 /// </summary>
 /// <param name="symbol">Symbol asset we're seeking to trade</param>
 /// <param name="quantity">Quantity of the asset we're seeking to trade</param>
 /// <param name="time">Time the order was placed</param>
 /// <param name="expiryDate">Expiry date of the order</param>
 /// <param name="tag">User defined data tag for this order</param>
 /// <param name="properties">The order properties for this order</param>
 protected Order(Symbol symbol, decimal quantity, DateTime time, DateTime?expiryDate = null, string tag = "", OrderReason?orderReason = null, IOrderProperties properties = null)
 {
     Time          = time;
     Price         = 0;
     PriceCurrency = string.Empty;
     Quantity      = quantity;
     Symbol        = symbol;
     Status        = OrderStatus.None;
     ExpiryDate    = expiryDate;
     Reason        = orderReason;
     Tag           = tag;
     BrokerId      = new List <string>();
     ContingentId  = 0;
     Properties    = properties ?? new OrderProperties();
 }
Ejemplo n.º 16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DefaultMarginCallModel"/> class
 /// </summary>
 /// <param name="portfolio">The portfolio object to receive margin calls</param>
 /// <param name="defaultOrderProperties">The default order properties to be used in margin call orders</param>
 public DefaultMarginCallModel(SecurityPortfolioManager portfolio, IOrderProperties defaultOrderProperties)
 {
     Portfolio = portfolio;
     DefaultOrderProperties = defaultOrderProperties;
 }
Ejemplo n.º 17
0
        /// <summary>
        /// Initialise security portfolio manager.
        /// </summary>
        public SecurityPortfolioManager(SecurityManager securityManager, SecurityTransactionManager transactions, IOrderProperties defaultOrderProperties = null)
        {
            Securities      = securityManager;
            Transactions    = transactions;
            MarginCallModel = new DefaultMarginCallModel(this, defaultOrderProperties);

            CashBook              = new CashBook();
            UnsettledCashBook     = new CashBook();
            _unsettledCashAmounts = new List <UnsettledCashAmount>();

            _baseCurrencyCash          = CashBook[CashBook.AccountCurrency];
            _baseCurrencyUnsettledCash = UnsettledCashBook[CashBook.AccountCurrency];

            // default to $100,000.00
            _baseCurrencyCash.SetAmount(100000);

            CashBook.Updated          += (sender, args) => InvalidateTotalPortfolioValue();
            UnsettledCashBook.Updated += (sender, args) => InvalidateTotalPortfolioValue();
        }
 public TestDefaultMarginCallModel(SecurityPortfolioManager portfolio, IOrderProperties defaultOrderProperties)
     : base(portfolio, defaultOrderProperties)
 {
 }
Ejemplo n.º 19
0
 /// <summary>
 /// New option exercise order constructor. We model option exercising as an underlying asset long/short order with strike equal to limit price.
 /// This means that by exercising a call we get into long asset position, by exercising a put we get into short asset position.
 /// </summary>
 /// <param name="symbol">Option symbol we're seeking to exercise</param>
 /// <param name="quantity">Quantity of the option we're seeking to exercise. Must be a positive value.</param>
 /// <param name="time">Time the order was placed</param>
 /// <param name="tag">User defined data tag for this order</param>
 /// <param name="properties">The order properties for this order</param>
 public OptionExerciseOrder(Symbol symbol, decimal quantity, DateTime time, string tag = "", IOrderProperties properties = null)
     : base(symbol, quantity, time, tag: tag, properties: properties)
 {
     Price = Symbol.ID.StrikePrice;
 }
Ejemplo n.º 20
0
        /// <summary>
        /// New Stop Market Order constructor -
        /// </summary>
        /// <param name="symbol">Symbol asset we're seeking to trade</param>
        /// <param name="quantity">Quantity of the asset we're seeking to trade</param>
        /// <param name="limitPrice">Maximum price to fill the order</param>
        /// <param name="time">Time the order was placed</param>
        /// <param name="stopPrice">Price the order should be filled at if a limit order</param>
        /// <param name="tag">User defined data tag for this order</param>
        /// <param name="properties">The order properties for this order</param>
        public StopLimitOrder(Symbol symbol, decimal quantity, decimal stopPrice, decimal limitPrice, DateTime time, string tag = "", IOrderProperties properties = null)
            : base(symbol, quantity, time, tag, properties)
        {
            StopPrice  = stopPrice;
            LimitPrice = limitPrice;

            if (tag == "")
            {
                //Default tag values to display stop price in GUI.
                Tag = "Stop Price: " + stopPrice.ToString("C") + " Limit Price: " + limitPrice.ToString("C");
            }
        }
Ejemplo n.º 21
0
 /// <summary>
 /// New order constructor
 /// </summary>
 /// <param name="symbol">Symbol asset we're seeking to trade</param>
 /// <param name="quantity">Quantity of the asset we're seeking to trade</param>
 /// <param name="time">Time the order was placed</param>
 /// <param name="tag">User defined data tag for this order</param>
 /// <param name="properties">The order properties for this order</param>
 protected Order(Symbol symbol, decimal quantity, DateTime time, string tag = "", IOrderProperties properties = null)
 {
     Time          = time;
     PriceCurrency = string.Empty;
     Quantity      = quantity;
     Symbol        = symbol;
     Status        = OrderStatus.None;
     Tag           = tag;
     BrokerId      = new List <string>();
     Properties    = properties ?? new OrderProperties();
 }
Ejemplo n.º 22
0
 public NonUpdateableLimitOrderTestParameters(Symbol symbol, decimal highLimit, decimal lowLimit, IOrderProperties properties = null)
     : base(symbol, highLimit, lowLimit, properties)
 {
 }
Ejemplo n.º 23
0
        /// <summary>
        /// New limit order constructor
        /// </summary>
        /// <param name="symbol">Symbol asset we're seeking to trade</param>
        /// <param name="quantity">Quantity of the asset we're seeking to trade</param>
        /// <param name="time">Time the order was placed</param>
        /// <param name="limitPrice">Price the order should be filled at if a limit order</param>
        /// <param name="tag">User defined data tag for this order</param>
        /// <param name="properties">The order properties for this order</param>
        public LimitOrder(Symbol symbol, decimal quantity, decimal limitPrice, DateTime time, string tag = "", IOrderProperties properties = null)
            : base(symbol, quantity, time, tag, properties)
        {
            LimitPrice = limitPrice;

            if (tag == "")
            {
                //Default tag values to display limit price in GUI.
                Tag = Invariant($"Limit Price: {limitPrice:C}");
            }
        }
Ejemplo n.º 24
0
 public MarketOrderTestParameters(Symbol symbol, IOrderProperties properties = null, OrderSubmissionData orderSubmissionData = null)
     : base(symbol, properties, orderSubmissionData)
 {
 }
Ejemplo n.º 25
0
 /// <summary>
 /// New market order constructor
 /// </summary>
 /// <param name="symbol">Symbol asset we're seeking to trade</param>
 /// <param name="quantity">Quantity of the asset we're seeking to trade</param>
 /// <param name="time">Time the order was placed</param>
 /// <param name="price">Price of the order</param>
 /// <param name="tag">User defined data tag for this order</param>
 /// <param name="properties">The order properties for this order</param>
 public MarketOrder(Symbol symbol, decimal quantity, DateTime time, decimal price, string tag = "", IOrderProperties properties = null)
     : this(symbol, quantity, time, tag, properties)
 {
     Price = price;
 }
Ejemplo n.º 26
0
 /// <summary>
 /// Intiializes a new instance of the <see cref="MarketOnOpenOrder"/> class.
 /// </summary>
 /// <param name="symbol">The security's symbol being ordered</param>
 /// <param name="quantity">The number of units to order</param>
 /// <param name="time">The current time</param>
 /// <param name="expiryDate">Timespan till the expiry of the order</param>
 /// <param name="tag">A user defined tag for the order</param>
 /// <param name="orderReason">The reason for this order</param>
 /// <param name="properties">The order properties for this order</param>
 public MarketOnOpenOrder(Symbol symbol, decimal quantity, DateTime time, DateTime?expiryDate = null, string tag = "", OrderReason?orderReason = null, IOrderProperties properties = null)
     : base(symbol, quantity, time, expiryDate, tag, orderReason, properties)
 {
 }
 protected OrderTestParameters(Symbol symbol, IOrderProperties properties = null)
 {
     Symbol       = symbol;
     SecurityType = symbol.ID.SecurityType;
     Properties   = properties;
 }