Esempio n. 1
0
        internal static Transaction CreateBookTran(InstrumentCategory instrumentCategory, Account account, Protocal.TransactionBookData tranData)
        {
            var factory = CreateAddTranCommandFactory(tranData.OrderType, instrumentCategory);
            var command = factory.CreateBookTran(account, tranData);

            return(command.ExecuteAndGetResult());
        }
Esempio n. 2
0
        internal static TransactionBookData ToTransactionBookData(XmlNode tranNode)
        {
            string tranCode = string.Empty;
            Guid?  orderBatchInstructionId;
            TransactionBookData tranData = TransactionParser.ParseTransactionBookData(tranNode, out orderBatchInstructionId);

            tranData.Id     = Guid.Parse(tranNode.Attributes["ID"].Value);
            tranData.Orders = new List <OrderBookData>();

            var instrument = InstrumentManager.Default.Get(tranData.InstrumentId);
            InstrumentCategory instrumentCategory = instrument.Category;

            foreach (XmlNode orderNode in tranNode.ChildNodes)
            {
                if (orderNode.Name == "Order")
                {
                    OrderBookData orderData = null;
                    if (instrumentCategory == InstrumentCategory.Forex)
                    {
                        orderData = OrderDataHelper.InitializeBookData(orderNode);
                    }
                    else
                    {
                        orderData = OrderDataHelper.InitalizePhysicalBookData(orderNode);
                    }
                    orderData.OrderBatchInstructionID = orderBatchInstructionId;
                    tranData.Orders.Add(orderData);
                }
            }
            tranData.PlaceByRiskMonitor = true;
            return(tranData);
        }
Esempio n. 3
0
        //Only Update the fields that should take effect in the past
        internal override void Update(IDBRow instrumentRow)
        {
            base.Update(instrumentRow);

            this._category      = (InstrumentCategory)instrumentRow.GetColumn <int>("Category");
            this._numeratorUnit = instrumentRow.GetColumn <int>("NumeratorUnit");
            this._denominator   = instrumentRow.GetColumn <int>("Denominator");
            this._isNormal      = instrumentRow.GetColumn <bool>("IsNormal");

            this.DayOpenTime  = (instrumentRow["DayOpenTime"] == DBNull.Value) ? default(DateTime) : (DateTime)instrumentRow["DayOpenTime"];
            this.DayCloseTime = (instrumentRow["DayCloseTime"] == DBNull.Value) ? default(DateTime) : (DateTime)instrumentRow["DayCloseTime"];
            if (instrumentRow.Contains("EndTime"))
            {
                _endTime = (instrumentRow["EndTime"] == DBNull.Value) ? default(DateTime) : (DateTime)instrumentRow["EndTime"];
            }
            this.ValueDate       = (instrumentRow["ValueDate"] == DBNull.Value) ? default(DateTime) : (DateTime)instrumentRow["ValueDate"];
            this.NextDayOpenTime = (instrumentRow["NextDayOpenTime"] == DBNull.Value) ? default(DateTime) : (DateTime)instrumentRow["NextDayOpenTime"];

            this._commissionFormula = (FeeFormula)instrumentRow.GetColumn <byte>("CommissionFormula");
            this._levyFormula       = (FeeFormula)instrumentRow.GetColumn <byte>("LevyFormula");
            _otherFeeFormula        = (FeeFormula)instrumentRow.GetColumn <byte>("OtherFeeFormula");
            this._marginFormula     = (MarginFormula)instrumentRow.GetColumn <byte>("MarginFormula");
            this._tradePLFormula    = (TradePLFormula)instrumentRow.GetColumn <byte>("TradePLFormula");

            this._isExpired = this.DayOpenTime == default(DateTime) && this.DayCloseTime == default(DateTime) && this.ValueDate == default(DateTime) && this.NextDayOpenTime == default(DateTime);
        }
Esempio n. 4
0
        internal static Transaction CreateMultipleCloseTran(InstrumentCategory instrumentCategory, Account account, Guid instrumentId, decimal contractSize, Guid submitorId)
        {
            var addTranCommandFactory = TransactionFacade.CreateAddTranCommandFactory(OrderType.MultipleClose, instrumentCategory);
            var command = addTranCommandFactory.CreateMultipleCloseTran(account, instrumentId, contractSize, submitorId);

            return(command.ExecuteAndGetResult());
        }
Esempio n. 5
0
        public void SaveInstrumentCategory(InstrumentCategory instrumentCategory)
        {
            DanielsEntities context = new DanielsEntities();

            COSC4210.MusicalIntruments.Web.Models.Category instrumentItemCategory = new COSC4210.MusicalIntruments.Web.Models.Category();

            if (instrumentCategory.ID != 0)
            {
                var etItemCategory = from t in context.Categories
                                     where t.ID == instrumentCategory.ID
                                     select t;

                instrumentItemCategory = etItemCategory.FirstOrDefault();

                instrumentItemCategory.CategoryName = instrumentCategory.InstrumentCategoryName;
            }
            else
            {
                instrumentItemCategory.CategoryName = instrumentCategory.InstrumentCategoryName;
                context.Categories.Add(instrumentItemCategory);
            }

            instrumentItemCategory.LastModified   = DateTime.Now;
            instrumentItemCategory.LastModifiedBy = "Phil";
            context.SaveChanges();
        }
Esempio n. 6
0
 internal Instrument(DataRow row)
 {
     this.Id            = (Guid)(row["ID"]);
     this.NumeratorUnit = (int)(row["NumeratorUnit"]);
     this.Denominator   = (int)(row["Denominator"]);
     this.CurrencyId    = (Guid)row["CurrencyID"];
     this.Category      = (InstrumentCategory)((int)row["Category"]);
 }
Esempio n. 7
0
        internal static TransactionData ToTransactionData(Token token, XmlNode tran)
        {
            string tranCode = string.Empty;

            Protocal.TransactionData tranData = TransactionParser.ParseTransaction(tran);
            tranData.PlaceByRiskMonitor = token.AppType == AppType.RiskMonitor ? true : false;
            tranData.Id     = Guid.Parse(tran.Attributes["ID"].Value);
            tranData.Orders = new List <OrderData>();

            InstrumentCategory instrumentCategory = InstrumentCategory.Forex;

            if (tran.Attributes["InstrumentCategory"] != null)
            {
                instrumentCategory = (InstrumentCategory)Enum.Parse(typeof(InstrumentCategory), tran.Attributes["InstrumentCategory"].Value);
            }

            foreach (XmlNode orderNode in tran.ChildNodes)
            {
                if (orderNode.Name == "Order")
                {
                    OrderData orderData = null;
                    if (tranData.OrderType == OrderType.BinaryOption)
                    {
                        orderData = OrderDataHelper.InitializeBOData(orderNode);
                    }
                    else if (instrumentCategory == InstrumentCategory.Forex)
                    {
                        orderData = OrderDataHelper.Initialize(orderNode);
                    }
                    else
                    {
                        orderData = OrderDataHelper.InitializePhysicalData(orderNode);
                    }
                    tranData.Orders.Add(orderData);
                }
            }

            return(tranData);
        }
Esempio n. 8
0
        internal void Update(XmlNode instrumentNode)
        {
            foreach (XmlAttribute attribute in instrumentNode.Attributes)
            {
                switch (attribute.Name)
                {
                case "NumeratorUnit":
                    this.NumeratorUnit = XmlConvert.ToInt32(attribute.Value);
                    break;

                case "Denominator":
                    this.Denominator = XmlConvert.ToInt32(attribute.Value);
                    break;

                case "CurrencyID":
                    this.CurrencyId = XmlConvert.ToGuid(attribute.Value);
                    break;

                case "Category":
                    this.Category = (InstrumentCategory)XmlConvert.ToInt32(attribute.Value);
                    break;
                }
            }
        }
Esempio n. 9
0
 internal static AddTransactionCommandFactoryBase CreateAddTranCommandFactory(OrderType orderType, InstrumentCategory instrumentCategory)
 {
     if (orderType == OrderType.BinaryOption)
     {
         return(AddBOTransactionCommandFactory.Default);
     }
     else if (instrumentCategory == InstrumentCategory.Physical)
     {
         return(AddPhysicalTransactionCommandFactory.Default);
     }
     else
     {
         return(AddGeneralTransactionCommandFactory.Default);
     }
 }
Esempio n. 10
0
        internal override void Update(XElement instrumentNode)
        {
            base.Update(instrumentNode);

            foreach (XAttribute attribute in instrumentNode.Attributes())
            {
                switch (attribute.Name.ToString())
                {
                case "ID":
                    this._id = XmlConvert.ToGuid(attribute.Value);
                    break;

                case "CurrencyID":
                    this._currencyId = XmlConvert.ToGuid(attribute.Value);
                    break;

                case "Code":
                    this._code = attribute.Value;
                    break;

                case "OriginCode":
                    _originCode = attribute.Value;
                    break;

                case "OriginInactiveTime":
                    this.InactiveTime = XmlConvert.ToInt32(attribute.Value);
                    break;

                case "Category":
                    this._category = (InstrumentCategory)XmlConvert.ToInt32(attribute.Value);
                    break;

                case "NumeratorUnit":
                    this._numeratorUnit = XmlConvert.ToInt32(attribute.Value);
                    break;

                case "Denominator":
                    this._denominator = XmlConvert.ToInt32(attribute.Value);
                    break;

                case "IsActive":
                    this._isActive = XmlConvert.ToBoolean(attribute.Value);
                    break;

                case "LastAcceptTimeSpan":
                    this._lastAcceptTimeSpan = XmlConvert.ToInt32(attribute.Value);
                    break;

                case "OrderTypeMask":
                    this._orderTypeMask = XmlConvert.ToInt32(attribute.Value);
                    break;

                case "MIT":
                    this._mit = XmlConvert.ToBoolean(attribute.Value);
                    break;

                case "AutoAcceptMaxLot":
                    this.AutoAcceptMaxLot = XmlConvert.ToDecimal(attribute.Value);
                    break;

                case "AutoCancelMaxLot":
                    this.AutoCancelMaxLot = XmlConvert.ToDecimal(attribute.Value);
                    break;

                case "IsAutoFill":
                    this._isAutoFill = XmlConvert.ToBoolean(attribute.Value);
                    break;

                case "MaxMinAdjust":
                    this._maxMinAdjust = XmlConvert.ToInt32(attribute.Value);
                    break;

                case "DayOpenTime":
                    this.DayOpenTime = Convert.ToDateTime(attribute.Value);
                    break;

                case "DayCloseTime":
                    this.DayCloseTime = Convert.ToDateTime(attribute.Value);
                    break;

                case "EndTime":
                    _endTime = Convert.ToDateTime(attribute.Value);
                    break;

                case "ValueDate":
                    this.ValueDate = Convert.ToDateTime(attribute.Value);
                    break;

                case "NextDayOpenTime":
                    this.NextDayOpenTime = Convert.ToDateTime(attribute.Value);
                    break;

                case "CommissionFormula":
                    this._commissionFormula = (FeeFormula)XmlConvert.ToByte(attribute.Value);
                    break;

                case "LevyFormula":
                    this._levyFormula = (FeeFormula)XmlConvert.ToByte(attribute.Value);
                    break;

                case "OtherFeeFormula":
                    _otherFeeFormula = (FeeFormula)XmlConvert.ToByte(attribute.Value);
                    break;

                case "MarginFormula":
                    this._marginFormula = (MarginFormula)XmlConvert.ToByte(attribute.Value);
                    break;

                case "TradePLFormula":
                    this._tradePLFormula = (TradePLFormula)XmlConvert.ToByte(attribute.Value);
                    break;

                case "InterestFormula":
                    this._interestFormula = (InterestFormula)XmlConvert.ToByte(attribute.Value);
                    break;

                case "InterestYearDays":
                    this._interestYearDays = XmlConvert.ToInt32(attribute.Value);
                    break;

                case "IsNormal":
                    this._isNormal = XmlConvert.ToBoolean(attribute.Value);
                    break;

                case "HitTimes":
                    this._hitTimes = XmlConvert.ToInt32(attribute.Value);
                    break;

                case "PenetrationPoint":
                    this._penetrationPoint = XmlConvert.ToInt32(attribute.Value);
                    break;

                case "UseSettlementPriceForInterest":
                    this._useSettlementPriceForInterest = XmlConvert.ToBoolean(attribute.Value);
                    break;

                case "CanPlacePendingOrderAtAnyTime":
                    this._canPlacePendingOrderAtAnyTime = XmlConvert.ToBoolean(attribute.Value);
                    break;

                case "AllowedSpotTradeOrderSides":
                    this._allowedSpotTradeOrderSides = (AllowedOrderSides)XmlConvert.ToInt32(attribute.Value);
                    break;

                case "PlaceSptMktTimeSpan":
                    _placeSptMktTimeSpan = TimeSpan.FromSeconds(XmlConvert.ToInt32(attribute.Value));
                    break;

                case "HitPriceVariationForSTP":
                    this.HitPriceVariationForSTP = XmlConvert.ToInt32(attribute.Value);
                    break;

                case "AcceptIfDoneVariation":
                    this._acceptIfDoneVariation = XmlConvert.ToInt32(attribute.Value);
                    break;

                case "FirstOrderTime":
                    _firstOrderTime = XmlConvert.ToInt32(attribute.Value);
                    break;

                case "IsPriceEnabled":
                    this._isPriceEnabled = XmlConvert.ToBoolean(attribute.Value);
                    _priceEnableTime     = DateTime.Now;
                    break;

                case "AutoDQDelay":
                    this.AutoDQDelay = TimeSpan.FromSeconds(XmlConvert.ToInt16(attribute.Value));
                    break;

                case "HolidayAlertDayPolicyID":
                    this.HolidayAlertDayPolicyId = XmlConvert.ToGuid(attribute.Value);
                    break;

                case "SummaryQuantity":
                    this._summaryQuantity = XmlConvert.ToDecimal(attribute.Value);
                    break;

                case "SpotPaymentTime":
                    this.SpotPaymentTime = attribute.Value.Get <DateTime?>();
                    break;
                }
            }
        }
            static InstrumentCategory()
            {
                LayerZero = new InstrumentCategory() { Layer = 0, Name = "通用/专用仪器" };

                LayerFirst = new InstrumentCategory() { Layer = 1, Name = "仪器大类" };

                LayerSecond = new InstrumentCategory() { Layer = 2, Name = "仪器中类" };

                LayerThird = new InstrumentCategory() { Layer = 3, Name = "仪器小类" };

                Dic = new Dictionary<int, InstrumentCategory>();

                Dic.Add(LayerZero.Layer, LayerZero);

                Dic.Add(LayerFirst.Layer, LayerFirst);

                Dic.Add(LayerSecond.Layer, LayerSecond);

                Dic.Add(LayerThird.Layer, LayerThird);
            }