Ejemplo n.º 1
0
        void TakeOverPosition_Raw(KospiOptionInfo koi, ElwInfo elw, long optionCount, POrder optionOrder, POrder elwOrder)
        {
            ElwArbSweepUnit eos = new ElwArbSweepUnit(koi, elw, optionCount, optionOrder, elwOrder, _parent);

            logger.Info(
                "{0}\t{1}\t{2}\t ElwArbEach EOS is created...",
                koi.Code,
                elw.Code,
                optionCount.ToString("n0"));

            _lives.Add(eos);
        }
Ejemplo n.º 2
0
        ElwArbSweepUnit EnterPosition_Raw(
            ElwInfo elwInfo,
            String elwCode,

            TradingDirection elwLS,
            long elwEnterCount,
            double elwPrice,
            RawMarketData rmdElw,

            TradingDirection optionLS,
            long optionEnterCount,
            double optionPrice,
            RawMarketData rmdOption)
        {
            POrder optionOrder = null;
            POrder elwOrder = null;

            try
            {
                {
                    // ELW Long
                    // 우선 ELW Long을 진행하도록 한다.
                    Detail.ProductType pt = ProductUtil.Ins().GetProductType(elwCode);

                    if (pt != Detail.ProductType.ELW)
                    {
                        logger.Error(
                            "CRITICAL ERROR!!! 엄청 무서운 일이 벌어졌다. ELW가 아닌 {0} 종목이 {1} 가격에 {2} 개 사려고 했다.",
                            elwCode,
                            elwPrice,
                            elwEnterCount);
                        Util.KillWithNotice("error");

                        _bFinish = true;
                        return null;
                    }
                    else
                    {
                        // ELW 롱
                        elwOrder = new POrder(elwLS, elwCode, elwEnterCount, elwPrice, _elwAccount, rmdElw);
                        elwOrder.AddComment("EAE.EnterPosition_Raw.elwOrder");
                        elwOrder.Free();

                        if (!POrderLegalManager.Ins().IsLegalOrder(elwOrder, false))
                        {
                            return null;
                        }
                    }
                }

                {
                    // 옵션 숏

                    // 그럴리 없겠지만 무서우니까 최종적으로 확인을 한번 더 해보자.
                    Detail.ProductType pt = ProductUtil.Ins().GetProductType(_KospiOptionInfo.Code);

                    if (pt != Detail.ProductType.CallOption && pt != Detail.ProductType.PutOption)
                    {
                        logger.Error(
                            "CRITICAL ERROR!!! 엄청 무서운 일이 벌어졌다. 옵션도 아닌 {0} 종목이 {1} 가격에 {2} 개 사려고 했다.",
                            _KospiOptionInfo.Code,
                            optionPrice,
                            optionEnterCount);
                        Util.KillWithNotice("CRITICAL ERROR!!!");

                        _bFinish = true;
                        return null;
                    }
                    else
                    {
                        optionOrder = new POrder(optionLS, _KospiOptionInfo.Code, optionEnterCount, optionPrice, _optionAccount, rmdOption);
                        optionOrder.AddComment("EAE.EnterPosition_Raw.optionOrder");
                        optionOrder.Free();

                        if (!POrderLegalManager.Ins().IsLegalOrder(optionOrder, false))
                        {
                            return null;
                        }
                    }
                }

                if (optionOrder != null && elwOrder != null)
                {
                    ElwArbSweepUnit eos = new ElwArbSweepUnit(
                        _KospiOptionInfo,
                        elwInfo,
                        _optionAccount,
                        optionOrder,
                        _elwAccount,
                        elwOrder,
                        _parent,
                        MonitoringEndDate);

                    return eos;
                }
                else
                {
                    logger.Error("Unexpected");
                    Util.KillWithNotice("Unexpected");
                }
            }
            catch (System.Exception ex)
            {
                logger.Error(ex.ToString());
                Util.KillWithNotice(ex.ToString());
            }
            return null;
        }