Ejemplo n.º 1
0
        /// <summary>
        /// Returns true if the specified order is within IB's order size limits
        /// </summary>
        private bool IsForexWithinOrderSizeLimits(Order order, out BrokerageMessageEvent message)
        {
            /* https://www.interactivebrokers.com/en/?f=%2Fen%2Ftrading%2FforexOrderSize.php
             * Currency    Currency Description	    Minimum Order Size	Maximum Order Size
             * USD	        US Dollar	                25,000              7,000,000
             * AUD	        Australian Dollar	        25,000              6,000,000
             * CAD	        Canadian Dollar	            25,000              6,000,000
             * CHF	        Swiss Franc	                25,000	            6,000,000
             * CNH	        China Renminbi (offshore)	160,000	            40,000,000
             * CZK	        Czech Koruna	            USD 25,000(1)	    USD 7,000,000(1)
             * DKK	        Danish Krone	            150,000	            35,000,000
             * EUR	        Euro	                    20,000	            5,000,000
             * GBP	        British Pound Sterling	    17,000	            4,000,000
             * HKD	        Hong Kong Dollar	        200,000	            50,000,000
             * HUF	        Hungarian Forint	        USD 25,000(1)	    USD 7,000,000(1)
             * ILS	        Israeli Shekel	            USD 25,000(1)	    USD 7,000,000(1)
             * KRW	        Korean Won	                50,000,000	        750,000,000
             * JPY	        Japanese Yen	            2,500,000	        550,000,000
             * MXN	        Mexican Peso	            300,000	            70,000,000
             * NOK	        Norwegian Krone	            150,000	            35,000,000
             * NZD	        New Zealand Dollar	        35,000	            8,000,000
             * RUB	        Russian Ruble	            750,000	            30,000,000
             * SEK	        Swedish Krona	            175,000	            40,000,000
             * SGD	        Singapore Dollar	        35,000	            8,000,000
             */

            message = null;

            // switch on the currency being bought
            string baseCurrency, quoteCurrency;

            Forex.DecomposeCurrencyPair(order.Symbol, out baseCurrency, out quoteCurrency);


            decimal max;

            ForexCurrencyLimits.TryGetValue(baseCurrency, out max);

            var orderIsWithinForexSizeLimits = order.Quantity < max;

            if (!orderIsWithinForexSizeLimits)
            {
                message = new BrokerageMessageEvent(BrokerageMessageType.Warning, "OrderSizeLimit",
                                                    string.Format("The maximum allowable order size is {0}{1}.", max, baseCurrency)
                                                    );
            }
            return(orderIsWithinForexSizeLimits);
        }
Ejemplo n.º 2
0
        private bool IsForexWithinOrderSizeLimits(string currencyPair, int quantity, out BrokerageMessageEvent message)
        {
            message = null;
            string baseCurrency, quoteCurrency;

            Forex.DecomposeCurrencyPair(currencyPair, out baseCurrency, out quoteCurrency);
            decimal max;

            ForexCurrencyLimits.TryGetValue(baseCurrency, out max);
            var orderIsWithinForexSizeLimits = quantity < max;

            if (!orderIsWithinForexSizeLimits)
            {
                message = new BrokerageMessageEvent(BrokerageMessageType.Warning, "OrderSizeLimit",
                                                    string.Format("The maximum allowable order size is {0}{1}.", max, baseCurrency)
                                                    );
            }
            return(orderIsWithinForexSizeLimits);
        }