Ejemplo n.º 1
0
        private void CreateOrderBox(MagicBoxOrder magicBox)
        {
            /// need to refactor this messs into another class

            double range = magicBox.Range;
            double takeProfit = 0; // nullify take profit
            double stopLoss = 0; // nullify stop loss, should set after enter the trade.
            double expiredTime = magicBox.MinuteExpiracy;

            var moneyManagement = new MoneyManagement(1, this.Balance);

            double lotSize = moneyManagement.CalculateLotSize(magicBox);

            foreach (var currencyPairs in currencyRepository.GetRelatedCurrencyPairs(this, magicBox.Symbol))
            {
                // check if the order has been created for this pair

                var buyOrder = PendingBuy(currencyPairs, lotSize,
                            BuyOpenPriceFor(currencyPairs) + range * PointFor(currencyPairs));

                var sellOrder = PendingSell(currencyPairs, lotSize,
                            SellOpenPriceFor(currencyPairs) - range * PointFor(currencyPairs));

                orderPool.Add(new OrderWatcher(buyOrder, sellOrder, expiredTime, magicBox.Config));
            }
        }
Ejemplo n.º 2
0
        private void CreateOrderBox(MagicBoxOrder magicBox)
        {
            /// need to refactor this messs into another class

            double range       = magicBox.Range;
            double takeProfit  = 0; // nullify take profit
            double stopLoss    = 0; // nullify stop loss, should set after enter the trade.
            double expiredTime = magicBox.MinuteExpiracy;

            var moneyManagement = new MoneyManagement(1, this.Balance);

            double lotSize = moneyManagement.CalculateLotSize(magicBox);

            foreach (var currencyPairs in currencyRepository.GetRelatedCurrencyPairs(this, magicBox.Symbol))
            {
                // check if the order has been created for this pair

                var buyOrder = PendingBuy(currencyPairs, lotSize,
                                          BuyOpenPriceFor(currencyPairs) + range * PointFor(currencyPairs));

                var sellOrder = PendingSell(currencyPairs, lotSize,
                                            SellOpenPriceFor(currencyPairs) - range * PointFor(currencyPairs));

                orderPool.Add(new OrderWatcher(buyOrder, sellOrder, expiredTime, magicBox.Config));
            }
        }
Ejemplo n.º 3
0
        private void CreateOrderBox(MagicBoxOrder magicBox)
        {
            /// need to refactor this messs into another class

            double range       = magicBox.Range;
            double takeProfit  = magicBox.TakeProfit; // nullify take profit
            double stopLoss    = magicBox.StopLoss;   // nullify stop loss, should set after enter the trade.
            double expiredTime = magicBox.MinuteExpiracy;

            var moneyManagement = new MoneyManagement(1, Balance);

            double lotSize = moneyManagement.CalculateLotSize(magicBox.StopLoss);

            foreach (string currencyPairs in currencyRepository.GetRelatedCurrencyPairs(this, magicBox.Symbol))
            {
                // check if the order has been created for this pair
                if (orderPool.ContainsOrderForSymbol(currencyPairs))
                {
                    continue;
                }

                // refactor to next class and cache the traded value ...(don't let it duplicated like tonight usdcad pairs)
                // the logic should be in orderPool
                Order buyOrder = PendingBuy(currencyPairs, lotSize,
                                            BuyOpenPriceFor(currencyPairs) + range * PointFor(currencyPairs));
                buyOrder.ChangeStopLossInPoints(magicBox.StopLoss);
                buyOrder.ChangeTakeProfitInPoints(magicBox.TakeProfit);

                Order sellOrder = PendingSell(currencyPairs, lotSize,
                                              SellOpenPriceFor(currencyPairs) - range * PointFor(currencyPairs));
                sellOrder.ChangeStopLossInPoints(magicBox.StopLoss);
                sellOrder.ChangeTakeProfitInPoints(magicBox.TakeProfit);

                //var buyOrder = PendingBuy(magicBox.Symbol, lotSize,
                //    BuyOpenPriceFor(magicBox.Symbol) + range * PointFor(magicBox.Symbol),
                //    BuyClosePriceFor(magicBox.Symbol) + ((range - stopLoss) * PointFor(magicBox.Symbol)),
                //    BuyClosePriceFor(magicBox.Symbol) + ((range + takeProfit) * PointFor(magicBox.Symbol)));

                //var sellOrder = PendingSell(magicBox.Symbol, lotSize,
                //    SellOpenPriceFor(magicBox.Symbol) - range * PointFor(magicBox.Symbol),
                //    SellClosePriceFor(magicBox.Symbol) - ((range - stopLoss) * PointFor(magicBox.Symbol)),
                //    SellClosePriceFor(magicBox.Symbol) - ((range + takeProfit) * PointFor(magicBox.Symbol)));

                orderPool.Add(new OrderWatcher(buyOrder, sellOrder, expiredTime, magicBox.Config));
            }
        }