Esempio n. 1
0
        public SweepUnit_FO(
            long signedGoalCountFO,
            String code,
            double initEnterPrice,
            POrder initOrder,
            Account accountFO,
            ISweeper parent,
            int muteSec)
        {
            this.ID = SweepUnitIDManager.NextID++;

            this.InitEnterPrice = initEnterPrice;
            this.InitSignedGoalCount = this.CurSignedTargetCount = signedGoalCountFO;
            this.Code = code;
            this._initOrder = initOrder;
            this.AccountFO = accountFO;
            this._parent = parent;
            this._muteSec = muteSec;
            this.InitLongShort = InitSignedGoalCount > 0 ? TradingDirection.Long : TradingDirection.Short;

            this._mute = new Timer(muteSec, "");
            this._bResumed = false;
            this._bCompleteQuickly = false;

            this.RealOrders = new List<POrder>();

            RequestInitOrder();
        }
Esempio n. 2
0
        public SweepUnit_OE(
            POrder goalOrder, 
            Account accountFO, 
            Account accountSpot, 
            OptionTribe ot,
            ISweeper parent,
            Boolean bConservativeOptionPolicyOn,
            int muteSec)
        {
            ID = SweepUnitIDManager.NextID++;

            _parent = parent;

            GoalOrder = goalOrder;

            RealOrders = new List<POrder>();
            _ot = ot;

            _mute = new Timer(muteSec, ""); // 2초

            _candidateCodes = ElwOptionUtil.GetSameCandidateCodes(goalOrder.Code);

            _accountSpot = accountSpot;
            _accountFO = accountFO;

            _bConservativeOptionPolicyOn = bConservativeOptionPolicyOn;

            if (!RequestInitOrder())
            {
                GoalOrder.Free();
            }

            _State = State._1_MuteFewSecs;
            ShowState();
        }
Esempio n. 3
0
        private SoundManager()
        {
            myPlayerAlarm = new System.Media.SoundPlayer();
            myPlayerAlarm.SoundLocation = @"c:\windows\media\tada.wav";

            myPlayerContract = new System.Media.SoundPlayer();
            myPlayerContract.SoundLocation = @"c:\windows\media\ringin.wav";

            myPlayerException = new System.Media.SoundPlayer();
            myPlayerException.SoundLocation = @"c:\windows\media\Windows XP Critical Stop.wav";

            myAliveAlarm = new System.Media.SoundPlayer();
            myAliveAlarm.SoundLocation = @"c:\windows\media\Windows XP Hardware Fail.wav";

            int useAccount = Convert.ToInt32(Util.RemoveComma(ConfigManager.Ins().Config.GetValue(ConfigKeyConst.USE_ACCOUNT)));

            if (useAccount == 1)
            {
                _aliveTimer = new Timer(10, "");
            }
            else
            {
                _aliveTimer = new Timer(60 * 60 * 24, ""); // 24시간 뒤에 플레이 하도록 한다.
            }

            this.IsContractSoundOn = false;
        }
        // 선물의 Velocity를 검사하고 일정 이상의 속도라면 정보를 수집한다.
        public FoxWatchCaptureController(Boolean bToDB_InRunning)
        {
            this.IsToDB_InRunning = bToDB_InRunning;
            _futureCode = KospiFutureUtil.Ins().KFI.Code;
            _mute = new Timer(MUTE_SEC, "");
            _mute.SetAsForcedTimeOut();

            InitPolicy();
        }
        public FoxCaptureSlideController(
            double futureVelocity, 
            int groupID, 
            int timeOffsetCount, 
            FoxCapturePolicy policy,
            Boolean bToDB_InRunning)
        {
            this.IsToDB_InRunning = bToDB_InRunning;

            _slide = new FoxCaptureSlide(futureVelocity, groupID, timeOffsetCount, DateTime.Now);

            this._policy = policy;
            this._futureCode = KospiFutureUtil.Ins().KFI.Code;

            _timer = new Timer(1, "");
            _timer.SetAsForcedTimeOut();
        }
        public FoxRawDataEachCollector(String code, long agentRunningPeriod)
        {
            // 50 ms 마다 한번씩 실행해야 한다.
            Trace.Assert(agentRunningPeriod == WATCH_RUN_PERIOD_MILLI_SEC * TimeConst.ONE_SEC / 1000);

            this.Code = code;

            Dictionary<String, OptionTribe> tribes = OptionFamily.Ins().Tribes;

            String futureCode = KospiFutureUtil.Ins().KFI.Code;

            if (this.Code.CompareTo(futureCode) == 0)
            {
                OT = null; // 선물인 경우에는 이런 일이 가능하다.
            }
            else
            {
                String koiKey = ElwOptionUtil.GetKOIKey(this.Code);

                if (tribes.ContainsKey(koiKey))
                {
                    OT = tribes[koiKey];
                }
                else
                {
                    Debug.Assert(false);
                }
            }

            this._timerForMinutePeriodControllers = new Timer(TIMER_MINUTE_PERIOD_SEC, "");

            _priceDataController = new FoxPriceDataController(code, WATCH_RUN_PERIOD_MILLI_SEC);

            //FoxPriceRangeController를 생성한다.
            _priceRangeController = new FoxPriceRangeController(code);

            //FoxPriceVolController를 생성한다.
            _priceVolController = new FoxPriceVolController(code);

            //FoxPriceVelocityController를 생성한다.
            _priceVelocityController = new FoxPriceVelocityController(code);
        }
Esempio n. 7
0
        public SweepUnitTemplate(
            ISweepUnitContext context,
            ISweeper sweeper,
            int muteSec)
        {
            this.Context = context;
            this._sweeper = sweeper;

            this._muteSec = muteSec;

            this.ID = SweepUnitIDManager.NextID++;

            this._bResumed = false;
            this._bCompleteQuickly = false;

            Context.RequestInitOrders();
            Context.AfterRequestInitOrders();

            this._mute = new Timer(muteSec, "");

            this.CurState = StateEnum._1_MuteFewSecsAfterInitOrders;
            this.CurOverviewState = OverviewState.Enter;
        }
Esempio n. 8
0
 void CancelLiveOrders()
 {
     _maxWaiting = new Timer(30, "30초 넘도록 주문 취소가 되지 않았습니다. ForceDone을 수행합니다. 불안합니다.");
     Context.CancelLiveOrders();
     CurState = StateEnum._3_WaitUntilCancelAllOrders;
 }
Esempio n. 9
0
        void CancelPriceOrders()
        {
            _maxWaiting = new Timer(30, "CRITICAL ERROR!!! 30초 넘도록 주문 취소가 되지 않았습니다. 불안합니다.");

            foreach (POrder o in ElwOrdersReal)
            {
                o.CancelRemains();
            }

            foreach (POrder o in OptionOrdersReal)
            {
                o.CancelRemains();
            }
        }
Esempio n. 10
0
        public ElwArbSweepUnit(
            KospiOptionInfo koi,
            ElwInfo elwInfo,
            Account optionAccount,
            POrder optionOrder,
            Account elwAccount,
            POrder elwOrder,
            STR_ElwArb parent,
            DateTime dtEnd)
        {
            try
            {
                KOI = koi;
                CurID = ++ID_GENERATOR;

                OptionAccount = optionAccount;
                OptionOrderGoal = optionOrder;

                OptionOrderGoal.AddComment("EOS Constructor");

                ElwAccount = elwAccount;
                ElwOrderGoal = elwOrder;

                ElwOrderGoal.AddComment("EOS Constructor");

                _elwInfo = elwInfo;

                OptionOrdersReal = new List<POrder>();
                ElwOrdersReal = new List<POrder>();

                _state = State._1_MuteFewSecs;

                Key = String.Format("{0};{1}", OptionOrderGoal.Code, ElwOrderGoal.Code);

                ShowState();
                _mute = new Timer(ENTER_POSITION_MUTE, "");

                RequestInitOrder(ElwOrderGoal, ElwOrdersReal);

                _parent = parent;
                _parent.IncreaseEnteredArbCount(KOI.Code, OptionOrderGoal.ReqCount);
                _dtEnd = dtEnd;

                IsBodySweepQuickly = false;
            }
            catch (System.Exception ex)
            {
                logger.Error(ex.ToString());
                Util.KillWithNotice(ex.ToString());
            }
            finally
            {
                ElwAccount.DiffFastExactPossibleShortCount(ElwOrderGoal.Code, "ElwOptionSweeper 생성자");

                OptionOrderGoal.Free();
                optionOrder.Free();
                ElwOrderGoal.Free();
                elwOrder.Free();
            }
        }
Esempio n. 11
0
 void Handle_SweepHedge_State()
 {
     if (_mute.On())
     {
         // 그냥 정해진 시간 동안 mute하도록 한다
         //if (IsAllDone())
         //{
         //    _state = State._2_WaitingGotOrderNumber;
         //    ShowState();
         //}
         //return;
     }
     else
     {
         if (IsStillGoodChance())
         {
             _mute = new Timer(STILL_GOOD_CHANCE_WAITING_SEC, ""); // 대기
         }
         else
         {
             // Particle은 무시하고 Hedge에서 아직 기다려볼만 한 상태라면 대기한다.
             _state = State._2_WaitingGotOrderNumber;
             ShowState();
         }
     }
 }
Esempio n. 12
0
        void Handle_CancelPriceOrders_State()
        {
            Boolean bDone = IsAllDone();

            if (!bDone && !_maxWaiting.On())
            {
                // 최대로 기다리는 시간이 지났는데 Done이 안되었다. 강제로 Done으로 만들어버려야겠다.
                // 참 안좋다.
                ReportLiveOrders();
                logger.Error(_maxWaiting.Log);
                Util.KillWithNotice("Handle_CancelPriceOrders_State error");

                _state = State._0_Exception;
                ShowState();
                _parent.MonitoringOff();
                return;
            }

            if (bDone)
            {
                ++_aging;

                if (ExecuteSweepHedge())
                {
                    _state = State._4_SweepHedge;
                    ShowState();

                    UpdateSweepingModeAsQuickOrNormal();

                    _mute = new Timer(SWEEPER_HEDGE_STATE_WAITING_SEC, ""); // 기다린다.
                }
            }
        }
Esempio n. 13
0
 void HandleExecuteSweepHedge()
 {
     try
     {
         if (ExecuteSweepHedge())
         {
             _State = State._6_SweepHedge;
             ShowState();
             _mute = new Timer(_sweepWaitingSec, ""); // 평소에는 15초, 비상시에는 5초 동안 기다린다.
         }
     }
     catch (System.Exception ex)
     {
         logger.Error(ex.ToString());
         Util.KillWithNotice(ex.ToString());
     }
 }
Esempio n. 14
0
 public void CompleteQuickly()
 {
     try
     {
         _bCompleteQuickly = true;
         _sweepWaitingSec = 5;
         _mute = new Timer(_sweepWaitingSec, "");
     }
     catch (System.Exception ex)
     {
         logger.Error(ex.ToString());
         Util.KillWithNotice(ex.ToString());
     }
 }
 public S3_WaitFewSec_PositionTakerState(PositionTakerController parent, POrder thisTurnOrder)
 {
     _parent = parent;
     this.ThisTurnOrder = thisTurnOrder;
     _timer = new Timer(kWaitSec, "");
 }
Esempio n. 16
0
 void RequestSweepOrdersViaTargetCount()
 {
     try
     {
         ++_aging;
         if (RequestSweepOrdersViaTargetCount_Raw())
         {
             _State = State._6_MonitorRequestedSweepOrders;
             ShowState();
             _mute = new Timer(_sweepMonitorSec, ""); // 평소에는 15초, 비상시에는 5초 동안 기다린다.
         }
     }
     catch (System.Exception ex)
     {
         logger.Error(ex.ToString());
         Util.KillWithNotice(ex.ToString());
     }
 }
Esempio n. 17
0
 void MonitorRequestedSweepOrders()
 {
     if (_mute.On())
     {
     }
     else
     {
         if (_bCompleteQuickly || IsOverAging() || !IsStillGoodChance())
         {
             GotoWaitingGotOrderNumber();
         }
         else
         {
             _mute = new Timer(_sweepMonitorSec, ""); // 15초 대기
             _aging++;
         }
     }
 }
Esempio n. 18
0
        void CancelPriceOrders()
        {
            _maxWaiting = new Timer(30, "30초 넘도록 주문 취소가 되지 않았습니다. ForceDone을 수행합니다. 불안합니다.");

            foreach (POrder o in RealOrders)
            {
                if (!o.IsCancelRemains())
                {
                    o.CancelRemains();
                }
            }
        }
Esempio n. 19
0
        void MonitorRequestedSweepOrders()
        {
            if (_mute.On())
            {
                if (Context.IsStateDone())
                {
                    GotoWaitingGotOrderNumber();
                }
            }
            else
            {
                _aging++;

                if (_bCompleteQuickly || IsOverAging() || !Context.IsStillGoodChance())
                {
                    GotoWaitingGotOrderNumber();
                }
                else
                {
                    //SweepMonitorSec(보통 15초)만큼 대기하도록 한다.
                    _mute = new Timer(_sweepMonitorSec, "");
                }
            }
        }
Esempio n. 20
0
        void RequestSweepOrders()
        {
            try
            {
                if (RequestSweepOrders_Raw())
                {
                    // Sweep orders를 요청한 뒤에 상태를 확인한다.
                    if (Context.IsStateDone() && CurState != StateEnum._7_Done)
                    {
                        // Done으로 가도 좋다면 여기서 보낸다.
                        SetAsDone();
                    }
                    else
                    {
                        // 그렇지 않다면 모니터링을 하러 보낸다.
                        CurState = StateEnum._6_MonitorRequestedSweepOrders;
                        // 평소에는 15초, 비상시에는 5초 동안 기다린다. Careful인 경우에는 하루종일 주문을 내도록 한다.
                        _mute = new Timer(_sweepMonitorSec, "");
                    }
                    ShowState();
                }
                else
                {
                    logger.Warn("({0})'s RequestSweepOrders_Raw == false", this.ID);

                    CurState = StateEnum._6_MonitorRequestedSweepOrders;
                    // 3초간 기다렸다가 다시 시도해본다.
                    const int waitingSec = 3;
                    _mute = new Timer(waitingSec, "");
                }
            }
            catch (System.Exception ex)
            {
                logger.Error(ex.ToString());
                Util.KillWithNotice(ex.ToString());
            }
        }
 public OptionContOOR_Monitoring(OptionContOORData context)
 {
     _context = context;
     _timer = new Timer(60, "");
 }
 public OptionContOOR_CancelCheck(OptionContOORData context)
 {
     _context = context;
     _timer = new Timer(10, "");
 }
Esempio n. 23
0
 void HandleSweepHedge()
 {
     if (_mute.On())
     {
         if (IsAllDone())
         {
             GotoWaitingGotOrderNumber();
         }
         return;
     }
     else
     {
         if (!_bCompleteQuickly && IsStillGoodChance())
         {
             _mute = new Timer(15, ""); // 15초 대기
         }
         else
         {
             // Particle은 무시하고 Hedge에서 아직 기다려볼만 한 상태라면 대기한다.
             GotoWaitingGotOrderNumber();
         }
     }
 }