Exemplo n.º 1
0
 public virtual int SendContOrderRZ(int sessionId, ref RezefContinuousOrder Order, ref int AsmachtaFmr, int AsmachtaRezef, out string VBMsg, out int ErrNO,
                                    out OrdersErrorTypes ErrorType, ref int OrderID, string AuthUserName, string AuthPassword, string ReEnteredValue)
 {
     ErrorType = OrdersErrorTypes.NoError;
     ErrNO     = 0;
     VBMsg     = "";
     return(0);
 }
Exemplo n.º 2
0
        /// <summary>
        /// Outdated. Use SendOrderRZ instead.
        /// </summary>
        public virtual int SendRezefOrder(int sessionId, ref RezefBasicOrder Order, string Location, string Trade_Type, ref string VBMsg, ref int ErrNO,
                                          out OrdersErrorTypes ErrorType, ref int OrderID, string AuthUserName, string AuthPassword, string ReEnteredValue)
        {
            ErrorType = OrdersErrorTypes.NoError;
            // i need an accurate cleanup - market simulation is far from trivial
            if (marketSimulationRezef == default(JQuant.MarketSimulationRezef))
            {
                return(-1);
            }

            // place order in the MarketSimulation, get OrderId
            // return Ok
            return(0);
        }
Exemplo n.º 3
0
        protected FMROrder(LMTOrderParameters orderParams, Connection connection)
            : base(orderParams)
        {
            //initialize FMR-specific data to be defualt values
            //if order processing logic will require, either FSM
            //or TaskBar will set them to something else
            this.VBMsg = default(string);
            this.ErrNO = default(int);
            this.ErrorType = default(OrdersErrorTypes);
            this.OrderID = 0;   //make sure that the broker's tests don't fail - start from the begining
            this.AuthUser = default(string);
            this.AuthPassword = default(string);
            this.ReEnteredValue = default(string);

            //initialize the state
            this.OrderState = OrderFSMState.IDLE;
        }
Exemplo n.º 4
0
        /// <summary>
        /// i am using MarketSimulation to handle the orders. I do not need all arguments of the FMR API.
        /// Only RezefBasicOrder and OrderID are in this phase.
        /// This one is going to be our workhorse at the moment.
        /// Sends Single Rezef Order. Replaces SendRezefOrder function.
        /// </summary>
        /// <param name="sessionId">Use FMRShell.Connection.GetSessionId()</param>
        /// <param name="Order">Structure of RezefSimpleOrder Type containing all details regarding the order that is being sent.</param>
        /// <param name="AsmachtaFmr">Unique order reference number provided by FMR systems.
        /// This reference is returned as an out parameter, and should be provided when updating or canceling the order.</param>
        /// <param name="AsmachtaRezef">Unique order reference number provided by the stock exchange.
        /// The reference should be retrieved using order retrieval function. Must be provided when updating/canceling.</param>
        /// <param name="VBMsg">If the sending order operation is unsuccessful, a message is relayed back to the client application
        /// with the reason for the failure. If the operation is successful, VBMsg remains empty. </param>
        /// <param name="ErrNO">If an error occurs during the operation, an error number will be relayed back to the client application.
        /// see wiki/ fmr's help for details.</param>
        /// <param name="ErrorType">Type of error returned by function call.
        /// Error type is defined by OrdersErrorTypes enumeration. </param>
        /// <param name="OrderID">Unique order id allocated by taskbar returned by function for order transaction identification.
        /// Must be provided when resending order due to user confirmation requirement. </param>
        /// <param name="AuthUserName">In the event that the operation requires password authorization,
        /// this field will contain the authorizing user name. </param>
        /// <param name="AuthPassword">In the event that the operation requires password authorization,
        /// this field will contain the password for the authorizing user. </param>
        /// <param name="ReEnteredValue">In case that the operation requires confirmation,
        /// the field will contain the value re-entered by the user. </param>
        /// <returns>The function returns 0 upon success and -1 upon failure. </returns>
        public virtual int SendOrderRZ(int sessionId, ref RezefSimpleOrder Order, ref int AsmachtaFmr, int AsmachtaRezef, out string VBMsg, out int ErrNO,
                                       out OrdersErrorTypes ErrorType, ref int OrderID, string AuthUserName, string AuthPassword, string ReEnteredValue)
        {
            //initialize data
            int rc = 0;

            VBMsg     = "";
            ErrNO     = 0;
            ErrorType = OrdersErrorTypes.NoError;

            //continue flag
            bool _continue = false;

            //check the arguments, internal error if something is wrong
            if (sessionId != this._sessionId)
            {
                VBMsg     = "Sending failure";
                ErrNO     = -2;
                ErrorType = OrdersErrorTypes.Fatal;
                rc        = -1;
            }

            else
            {
                if (
                    Order.operation == OrderOperation.OrderOperationDelete ||
                    Order.operation == OrderOperation.OrderOperationUpdBuy ||
                    Order.operation == OrderOperation.OrderOperationUpdSell)
                {
                    if (AsmachtaFmr == 0 || AsmachtaRezef == 0)
                    {
                        VBMsg     = "Missing parameters in RezefBasicOrder Type.";
                        ErrNO     = 91;
                        ErrorType = OrdersErrorTypes.Fatal;
                        rc        = -1;
                    }
                }

                if (Order.Amount >= 99999)
                {
                    if (ReEnteredValue == "YES")
                    {
                        _continue = true;
                    }
                    else
                    {
                        VBMsg     = " Order value above permitted limit.";
                        ErrNO     = 9;
                        ErrorType = OrdersErrorTypes.Confirmation;
                        rc        = -1;
                    }
                }

                else if (Order.price <= 0)
                {
                    if (ReEnteredValue == default(string))
                    {
                        VBMsg     = "LMT Order value above permitted limit.";
                        ErrNO     = 3;
                        ErrorType = OrdersErrorTypes.ReEnter;
                        rc        = -1;
                    }
                    else
                    {
                        Order.price = JQuant.Convert.StrToDouble(ReEnteredValue);
                        _continue   = true;
                    }
                }

                else if (Order.price > 50000)
                {
                    if (AuthPassword == default(string) ||
                        AuthUserName == default(string))
                    {
                        VBMsg     = "Illegal change from base rate.";
                        ErrNO     = 25;
                        ErrorType = OrdersErrorTypes.PasswordReq;
                        rc        = -1;
                    }
                    else
                    {
                        _continue = true;
                    }
                }

                else if (Order.price == 1)
                {
                    VBMsg     = "Illegal difference between Closing price and Base price.";
                    ErrNO     = 22;
                    ErrorType = OrdersErrorTypes.Alert;
                    _continue = true;
                }
                else
                {
                    _continue = true;
                }

                if (_continue)
                {
                    //only in case of success the order is passed to TASE:

                    switch (Order.operation)
                    {
                    //a new order
                    case OrderOperation.OrderOperationNewBuy:
                    case OrderOperation.OrderOperationNewSell:
                        this._rezefSimpleOrder = Order;
                        this._orderId++;                                            //generate unique order id
                        AsmachtaFmr        = _orderId;                              //initialize ref no
                        this._pollsCounter = 0;
                        this._orderState   = rzOrdersStates.WaitingApprove;
                        break;

                    //cancel
                    case OrderOperation.OrderOperationDelete:
                        this._pollsCounter = 0;
                        this._orderState   = rzOrdersStates.WaitingCancel;
                        break;

                    //update
                    case OrderOperation.OrderOperationUpdBuy:
                    case OrderOperation.OrderOperationUpdSell:
                        this._rezefSimpleOrder = Order;                                 //just copy updated order
                        this._pollsCounter     = 0;
                        this._orderState       = rzOrdersStates.WaitingUpdate;
                        break;
                    }
                }
            }

            return(rc);
        }
Exemplo n.º 5
0
 public virtual int SendMaofOrder(int sessionId, ref MaofOrderType Order, ref string VBMsg, ref int ErrNO, out OrdersErrorTypes ErrorType,
                                  ref int OrderID, string AuthUserName, string AuthPassword, string ReEnteredValue, int SPCOrder)
 {
     ErrorType = OrdersErrorTypes.NoError;
     return(0);
 }
Exemplo n.º 6
0
        /// <summary>
        /// Outdated. Use SendOrderRZ instead.
        /// </summary>
        public virtual int SendRezefOrder(int sessionId, ref RezefBasicOrder Order, string Location, string Trade_Type, ref string VBMsg, ref int ErrNO,
            out OrdersErrorTypes ErrorType, ref int OrderID, string AuthUserName, string AuthPassword, string ReEnteredValue)
        {
            ErrorType = OrdersErrorTypes.NoError;
            // i need an accurate cleanup - market simulation is far from trivial
            if (marketSimulationRezef == default(JQuant.MarketSimulationRezef))
            {
                return -1;
            }

            // place order in the MarketSimulation, get OrderId
            // return Ok
            return 0;
        }
Exemplo n.º 7
0
        /// <summary>
        /// i am using MarketSimulation to handle the orders. I do not need all arguments of the FMR API. 
        /// Only RezefBasicOrder and OrderID are in this phase. 
        /// This one is going to be our workhorse at the moment.
        /// Sends Single Rezef Order. Replaces SendRezefOrder function.
        /// </summary>
        /// <param name="sessionId">Use FMRShell.Connection.GetSessionId()</param>
        /// <param name="Order">Structure of RezefSimpleOrder Type containing all details regarding the order that is being sent.</param>
        /// <param name="AsmachtaFmr">Unique order reference number provided by FMR systems. 
        /// This reference is returned as an out parameter, and should be provided when updating or canceling the order.</param>
        /// <param name="AsmachtaRezef">Unique order reference number provided by the stock exchange. 
        /// The reference should be retrieved using order retrieval function. Must be provided when updating/canceling.</param>
        /// <param name="VBMsg">If the sending order operation is unsuccessful, a message is relayed back to the client application 
        /// with the reason for the failure. If the operation is successful, VBMsg remains empty. </param>
        /// <param name="ErrNO">If an error occurs during the operation, an error number will be relayed back to the client application.
        /// see wiki/ fmr's help for details.</param>
        /// <param name="ErrorType">Type of error returned by function call. 
        /// Error type is defined by OrdersErrorTypes enumeration. </param>
        /// <param name="OrderID">Unique order id allocated by taskbar returned by function for order transaction identification. 
        /// Must be provided when resending order due to user confirmation requirement. </param>
        /// <param name="AuthUserName">In the event that the operation requires password authorization, 
        /// this field will contain the authorizing user name. </param>
        /// <param name="AuthPassword">In the event that the operation requires password authorization, 
        /// this field will contain the password for the authorizing user. </param>
        /// <param name="ReEnteredValue">In case that the operation requires confirmation, 
        /// the field will contain the value re-entered by the user. </param>
        /// <returns>The function returns 0 upon success and -1 upon failure. </returns>
        public virtual int SendOrderRZ(int sessionId, ref RezefSimpleOrder Order, ref int AsmachtaFmr, int AsmachtaRezef, out string VBMsg, out int ErrNO,
            out OrdersErrorTypes ErrorType, ref int OrderID, string AuthUserName, string AuthPassword, string ReEnteredValue)
        {
            //initialize data
            int rc = 0;
            VBMsg = "";
            ErrNO = 0;
            ErrorType = OrdersErrorTypes.NoError;

            //continue flag
            bool _continue = false;

            //check the arguments, internal error if something is wrong
            if (sessionId != this._sessionId)
            {
                VBMsg = "Sending failure";
                ErrNO = -2;
                ErrorType = OrdersErrorTypes.Fatal;
                rc = -1;
            }

            else
            {
                if (
                Order.operation == OrderOperation.OrderOperationDelete ||
                Order.operation == OrderOperation.OrderOperationUpdBuy ||
                Order.operation == OrderOperation.OrderOperationUpdSell)
                {
                    if (AsmachtaFmr == 0 || AsmachtaRezef == 0)
                    {
                        VBMsg = "Missing parameters in RezefBasicOrder Type.";
                        ErrNO = 91;
                        ErrorType = OrdersErrorTypes.Fatal;
                        rc = -1;
                    }
                }

                if (Order.Amount >= 99999)
                {
                    if (ReEnteredValue == "YES")
                    {
                        _continue = true;
                    }
                    else
                    {
                        VBMsg = " Order value above permitted limit.";
                        ErrNO = 9;
                        ErrorType = OrdersErrorTypes.Confirmation;
                        rc = -1;
                    }
                }

                else if (Order.price <= 0)
                {
                    if (ReEnteredValue == default(string))
                    {
                        VBMsg = "LMT Order value above permitted limit.";
                        ErrNO = 3;
                        ErrorType = OrdersErrorTypes.ReEnter;
                        rc = -1;
                    }
                    else
                    {
                        Order.price = JQuant.Convert.StrToDouble(ReEnteredValue);
                        _continue = true;
                    }
                }

                else if (Order.price > 50000)
                {
                    if (AuthPassword == default(string) ||
                        AuthUserName == default(string))
                    {
                        VBMsg = "Illegal change from base rate.";
                        ErrNO = 25;
                        ErrorType = OrdersErrorTypes.PasswordReq;
                        rc = -1;
                    }
                    else
                        _continue = true;
                }

                else if (Order.price == 1)
                {
                    VBMsg = "Illegal difference between Closing price and Base price.";
                    ErrNO = 22;
                    ErrorType = OrdersErrorTypes.Alert;
                    _continue = true;
                }
                else
                {
                    _continue = true;
                }

                if (_continue)
                {
                    //only in case of success the order is passed to TASE:

                    switch (Order.operation)
                    {
                        //a new order
                        case OrderOperation.OrderOperationNewBuy:
                        case OrderOperation.OrderOperationNewSell:
                            this._rezefSimpleOrder = Order;
                            this._orderId++;            //generate unique order id
                            AsmachtaFmr = _orderId;     //initialize ref no
                            this._pollsCounter = 0;
                            this._orderState = rzOrdersStates.WaitingApprove;
                            break;
                        //cancel
                        case OrderOperation.OrderOperationDelete:
                            this._pollsCounter = 0;
                            this._orderState = rzOrdersStates.WaitingCancel;
                            break;
                        //update
                        case OrderOperation.OrderOperationUpdBuy:
                        case OrderOperation.OrderOperationUpdSell:
                            this._rezefSimpleOrder = Order; //just copy updated order
                            this._pollsCounter = 0;
                            this._orderState = rzOrdersStates.WaitingUpdate;
                            break;
                    }
                }
            }

            return rc;
        }
Exemplo n.º 8
0
 public virtual int SendMaofOrder(int sessionId, ref MaofOrderType Order, ref string VBMsg, ref int ErrNO, out OrdersErrorTypes ErrorType,
     ref int OrderID, string AuthUserName, string AuthPassword, string ReEnteredValue, int SPCOrder)
 {
     ErrorType = OrdersErrorTypes.NoError;
     return 0;
 }
Exemplo n.º 9
0
 public virtual int SendContOrderRZ(int sessionId, ref RezefContinuousOrder Order, ref int AsmachtaFmr, int AsmachtaRezef, out string VBMsg, out int ErrNO,
     out OrdersErrorTypes ErrorType, ref int OrderID, string AuthUserName, string AuthPassword, string ReEnteredValue)
 {
     ErrorType = OrdersErrorTypes.NoError;
     ErrNO = 0;
     VBMsg = "";
     return 0;
 }