/// <summary>
        /// Validates the instrument properties
        /// </summary>
        bool ValidateSymbol(string symbol, Instrumet_Type instrType)
        {
            bool isResult = false;

            if (instrType == Instrumet_Type.Forex)
            {
                Regex regex = new Regex(@"^[A-Z]{6}$");
                isResult = (regex.IsMatch(symbol) && symbol.Substring(0, 3) != symbol.Substring(3, 3));
            }
            else
            {
                Regex regex = new Regex(@"^[a-zA-Z\$\#]");
                isResult = regex.IsMatch(symbol);
            }

            return(isResult);
        }
Esempio n. 2
0
 /// <summary>
 /// Constructor
 /// </summary>
 public Instrument_Properties(string symbol, Instrumet_Type instrType)
 {
     if (instrType == Instrumet_Type.Forex)
     {
         this.symbol     = symbol;
         this.instrType  = instrType;
         comment         = symbol.Substring(0, 3) + " vs " + symbol.Substring(3, 3);
         Digits          = (symbol.Contains("JPY") ? 3 : 5);
         lotSize         = 100000;
         spread          = 20;
         swapType        = Commission_Type.pips;
         swapLong        = 2;
         swapShort       = -2;
         commissionType  = Commission_Type.pips;
         commissionScope = Commission_Scope.lot;
         commissionTime  = Commission_Time.openclose;
         commission      = 0;
         slippage        = 0;
         priceIn         = symbol.Substring(3, 3);
         rateToUSD       = (symbol.Contains("JPY") ? 100 : 1);
         rateToEUR       = (symbol.Contains("JPY") ? 100 : 1);
         baseFileName    = symbol;
     }
     else
     {
         this.symbol     = symbol;
         this.instrType  = instrType;
         comment         = symbol + " " + instrType.ToString();
         Digits          = 2;
         lotSize         = 100;
         spread          = 4;
         swapType        = Commission_Type.percents;
         swapLong        = -5;
         swapShort       = -1;
         commissionType  = Commission_Type.percents;
         commissionScope = Commission_Scope.deal;
         commissionTime  = Commission_Time.openclose;
         commission      = 0.25f;
         slippage        = 0;
         priceIn         = "USD";
         rateToUSD       = 1;
         rateToEUR       = 1;
         baseFileName    = symbol;
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Parses the instruments file.
        /// </summary>
        static void ParseInstruments()
        {
            int instrumentsCount = xmlInstruments.GetElementsByTagName("instrument").Count;

            dictInstrument = new Dictionary <string, Instrument_Properties>(instrumentsCount);

            try
            {
                foreach (XmlNode nodeInstr in xmlInstruments.GetElementsByTagName("instrument"))
                {
                    string                symbol    = nodeInstr.SelectSingleNode("symbol").InnerText;
                    Instrumet_Type        instrType = (Instrumet_Type)Enum.Parse(typeof(Instrumet_Type), nodeInstr.SelectSingleNode("instrumentType").InnerText);
                    Instrument_Properties instrProp = new Instrument_Properties(symbol, instrType);
                    instrProp.Comment         = nodeInstr.SelectSingleNode("comment").InnerText;
                    instrProp.Digits          = int.Parse(nodeInstr.SelectSingleNode("digits").InnerText);
                    instrProp.LotSize         = int.Parse(nodeInstr.SelectSingleNode("contractSize").InnerText);
                    instrProp.Spread          = StringToFloat(nodeInstr.SelectSingleNode("spread").InnerText);
                    instrProp.SwapType        = (Commission_Type)Enum.Parse(typeof(Commission_Type), nodeInstr.SelectSingleNode("swapType").InnerText);
                    instrProp.SwapLong        = StringToFloat(nodeInstr.SelectSingleNode("swapLong").InnerText);
                    instrProp.SwapShort       = StringToFloat(nodeInstr.SelectSingleNode("swapShort").InnerText);
                    instrProp.CommissionType  = (Commission_Type)Enum.Parse(typeof(Commission_Type), nodeInstr.SelectSingleNode("commissionType").InnerText);
                    instrProp.CommissionScope = (Commission_Scope)Enum.Parse(typeof(Commission_Scope), nodeInstr.SelectSingleNode("commissionScope").InnerText);
                    instrProp.CommissionTime  = (Commission_Time)Enum.Parse(typeof(Commission_Time), nodeInstr.SelectSingleNode("commissionTime").InnerText);
                    instrProp.Commission      = StringToFloat(nodeInstr.SelectSingleNode("commission").InnerText);
                    instrProp.Slippage        = int.Parse(nodeInstr.SelectSingleNode("slippage").InnerText);
                    instrProp.PriceIn         = nodeInstr.SelectSingleNode("priceIn").InnerText;
                    instrProp.RateToUSD       = StringToFloat(nodeInstr.SelectSingleNode("rateToUSD").InnerText);
                    instrProp.RateToEUR       = StringToFloat(nodeInstr.SelectSingleNode("rateToEUR").InnerText);
                    instrProp.BaseFileName    = nodeInstr.SelectSingleNode("baseFileName").InnerText;
                    dictInstrument.Add(symbol, instrProp);
                }
            }
            catch (Exception e)
            {
                System.Windows.Forms.MessageBox.Show(e.Message, "Parsing Instruments");
            }
        }
        /// <summary>
        /// Validates the instrument properties
        /// </summary>
        bool ValidateSymbol(string symbol, Instrumet_Type instrType)
        {
            bool isResult = false;

            if (instrType == Instrumet_Type.Forex)
            {
                Regex regex = new Regex(@"^[A-Z]{6}$");
                isResult = (regex.IsMatch(symbol) && symbol.Substring(0,3) != symbol.Substring(3,3));
            }
            else
            {
                Regex regex = new Regex(@"^[a-zA-Z\$\#]");
                isResult = regex.IsMatch(symbol);
            }

            return isResult;
        }
 /// <summary>
 /// Constructor
 /// </summary>
 public Instrument_Properties(string symbol, Instrumet_Type instrType)
 {
     if (instrType == Instrumet_Type.Forex)
     {
         this.symbol     = symbol;
         this.instrType  = instrType;
         comment         = symbol.Substring(0,3) + " vs " + symbol.Substring(3, 3);
         Digits          = (symbol.Contains("JPY") ? 3 : 5);
         lotSize         = 100000;
         spread          = 20;
         swapType        = Commission_Type.pips;
         swapLong        = 2;
         swapShort       = -2;
         commissionType  = Commission_Type.pips;
         commissionScope = Commission_Scope.lot;
         commissionTime  = Commission_Time.openclose;
         commission      = 0;
         slippage        = 0;
         priceIn         = symbol.Substring(3, 3);
         rateToUSD       = (symbol.Contains("JPY") ? 100 : 1);
         rateToEUR       = (symbol.Contains("JPY") ? 100 : 1);
         baseFileName    = symbol;
     }
     else
     {
         this.symbol     = symbol;
         this.instrType  = instrType;
         comment         = symbol + " " + instrType.ToString();
         Digits          = 2;
         lotSize         = 100;
         spread          = 4;
         swapType        = Commission_Type.percents;
         swapLong        = -5;
         swapShort       = -1;
         commissionType  = Commission_Type.percents;
         commissionScope = Commission_Scope.deal;
         commissionTime  = Commission_Time.openclose;
         commission      = 0.25f;
         slippage        = 0;
         priceIn         = "USD";
         rateToUSD       = 1;
         rateToEUR       = 1;
         baseFileName    = symbol;
     }
 }