Ejemplo n.º 1
0
        public TradingItem ReloadTradingItem()
        {
            TradingItem returnVal = new TradingItem();

            BindingFlags flags = BindingFlags.Instance | BindingFlags.GetField | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static;

            FieldInfo[] returnFieldArray = returnVal.GetType().GetFields(flags);

            BindingFlags flagsStrategySave = BindingFlags.Instance | BindingFlags.GetField | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static;

            FieldInfo[] ItemSaveFieldArray = this.GetType().GetFields(flagsStrategySave);


            foreach (FieldInfo field in returnFieldArray)
            {
                foreach (FieldInfo SaveField in ItemSaveFieldArray)
                {
                    if (field.Name == SaveField.Name)
                    {
                        field.SetValue(returnVal, SaveField.GetValue(this));
                    }
                }
            }
            returnVal.tickBongInfoMgr.Clear();
            return(returnVal);
        }
Ejemplo n.º 2
0
 public void CheckUpdateTradingStrategyAddedItem(TradingItem trading_item, double inputValue, CHECK_TIMING checkTiming)
 {
     foreach (TradingStrategyADDItem item in tradingStrategyItemList)
     {
         if (item.strategyCheckTime == checkTiming)
         {
             item.CheckUpdate(trading_item, inputValue);
         }
     }
 }
Ejemplo n.º 3
0
        public override void CheckUpdate(TradingItem item, double value)
        {
            if (!usingStrategy)
            {
                return;
            }

            if (value > d_conditionValue)
            {
                if (OnReceivedTrData != null)
                {
                    OnReceivedTrData.Invoke(this, new OnReceivedTrEventArgs(item, value));
                }
                //usingStrategy = false;
            }
        }
Ejemplo n.º 4
0
 public override void CheckUpdate(TradingItem item, double value)
 {
     if (!usingStrategy)
     {
         return;
     }
     //Console.WriteLine(item.itemName +" "+ TimeSpan.FromTicks((long)(value - d_conditionValue)).TotalSeconds.ToString());
     if (value - d_conditionValue > TIME_OVER_TIME && item.usingBuyCancelByTime)
     {
         if (OnReceivedTrData != null)
         {
             OnReceivedTrData.Invoke(this, new OnReceivedTrBuyCancel(this, item, value));
             item.usingBuyCancelByTime = false;
         }
     }
 }
Ejemplo n.º 5
0
        private void UpdateBuyAutoTradingDataGridStateOnly(string orderNum, string state)
        {
            foreach (TradingStrategy ts in tradingStrategyList)
            {
                foreach (var item in ts.tradingItemList)
                {
                    coreEngine.SendLogWarningMessage("종목명 : " + axKHOpenAPI1.GetMasterCodeName(item.itemCode) + "orderNum : " + item.buyOrderNum);
                }

                TradingItem tradeItem = ts.tradingItemList.Find(o => o.buyOrderNum.Equals(orderNum));

                if (tradeItem != null && tradeItem.GetUiConnectRow() != null)
                {
                    tradeItem.GetUiConnectRow().Cells["매매진행_주문번호"].Value = orderNum;
                    tradeItem.GetUiConnectRow().Cells["매매진행_진행상황"].Value = state;
                }
            }
        }
Ejemplo n.º 6
0
        public override void CheckUpdate(TradingItem item, double value)
        {
            if (!usingStrategy)
            {
                return;
            }

            if (item.startTrailingSell &&
                item.state == TRADING_ITEM_STATE.AUTO_TRADING_STATE_BUY_COMPLETE &&
                item.tickBongInfoMgr.IsCompleteBong(1) &&
                value < item.tickBongInfoMgr.GetTickBong(1).GetLowest()) //전봉 최저가 보다 낮을시
            {
                if (OnReceivedTrData != null)
                {
                    Core.CoreEngine.GetInstance().SaveItemLogMessage(item.itemCode, "1전봉 최저 : " + item.tickBongInfoMgr.GetTickBong(1).GetLowest() + " 현재 : " + value);
                    Core.CoreEngine.GetInstance().SaveItemLogMessage(item.itemCode, "익절 주문 : " + value);
                    OnReceivedTrData.Invoke(this, new OnReceivedTrEventArgs(item, value));

                    item.startTrailingSell = false;
                }
            }

            if (value >= d_conditionValue)
            {
                if (!item.startTrailingSell)
                {
                    Core.CoreEngine.GetInstance().SaveItemLogMessage(item.itemCode, "익절 트레일링 시작");
                    item.startTrailingSell = true;
                }
            }
            else
            {
                if (item.startTrailingSell && item.state == TRADING_ITEM_STATE.AUTO_TRADING_STATE_BUY_COMPLETE)
                {
                    Core.CoreEngine.GetInstance().SaveItemLogMessage(item.itemCode, "익절 상승 후 하락 주문 : " + value);
                    OnReceivedTrData.Invoke(this, new OnReceivedTrEventArgs(item, value));
                    item.startTrailingSell = false;
                }
            }

            item.tickBongInfoMgr.AddPrice(value);
            //Core.CoreEngine.GetInstance().SaveItemLogMessage(item.itemCode, "현재 : " + value);
            //Core.CoreEngine.GetInstance().SaveItemLogMessage(item.itemCode, "평균 : " + tickBongInfoMgr.curTickBong.GetAverage() + " index " + tickBongInfoMgr.curTickBong.CurSaveIndex);
        }
Ejemplo n.º 7
0
        private void UpdateSellAutoTradingDataGridStatePrice(string orderNum, string conclusionPrice)
        {
            coreEngine.SendLogWarningMessage("요청 주문 넘버 : " + orderNum);
            foreach (TradingStrategy ts in tradingStrategyList)
            {
                foreach (var item in ts.tradingItemList)
                {
                    coreEngine.SendLogWarningMessage("검색식 : " + ts.buyCondition.Name + " 종목명 : " + axKHOpenAPI1.GetMasterCodeName(item.itemCode) + "orderNum : " + item.sellOrderNum);
                }

                TradingItem tradeItem = ts.tradingItemList.Find(o => o.sellOrderNum.Equals(orderNum));
                if (tradeItem != null)
                {
                    tradeItem.GetUiConnectRow().Cells["매매진행_진행상황"].Value = TradingItem.StateToString(tradeItem.state);
                    tradeItem.GetUiConnectRow().Cells["매매진행_매도가"].Value  = conclusionPrice;
                    tradeItem.GetUiConnectRow().Cells["매매진행_매도시간"].Value = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                }
            }
        }
Ejemplo n.º 8
0
 private void UpdateBuyAutoTradingDataGridState(string itemCode)
 {
     foreach (TradingStrategy ts in tradingStrategyList)
     {
         coreEngine.SendLogWarningMessage("ui update" + ts.buyCondition.Name);
         List <TradingItem> tradeItemArray = ts.tradingItemList.FindAll(o => o.itemCode.Equals(itemCode));
         foreach (TradingItem tradeItem in tradeItemArray)
         {
             if (tradeItem != null)
             {
                 coreEngine.SendLogWarningMessage("tradeItem uid" + tradeItem.Uid);
                 tradeItem.GetUiConnectRow().Cells["매매진행_진행상황"].Value = TradingItem.StateToString(tradeItem.state);
                 tradeItem.GetUiConnectRow().Cells["매매진행_매수가"].Value  = tradeItem.buyingPrice;
                 tradeItem.GetUiConnectRow().Cells["매매진행_매수량"].Value  = tradeItem.curQnt;
                 tradeItem.GetUiConnectRow().Cells["매매진행_매수금"].Value  = tradeItem.curQnt * tradeItem.buyingPrice;
                 break;
             }
         }
     }
 }
Ejemplo n.º 9
0
 private void UpdateBuyAutoTradingDataGridState(string orderNum, bool buyComplete = false)
 {
     foreach (TradingStrategy ts in tradingStrategyList)
     {
         coreEngine.SendLogWarningMessage(ts.buyCondition.Name);
         TradingItem tradeItem = ts.tradingItemList.Find(o => o.buyOrderNum.Equals(orderNum));
         foreach (var item in ts.tradingItemList)
         {
             coreEngine.SendLogWarningMessage(item.itemName + " 요청 주문 넘버 : " + orderNum);
         }
         if (tradeItem != null)
         {
             tradeItem.GetUiConnectRow().Cells["매매진행_진행상황"].Value = TradingItem.StateToString(tradeItem.state);
             tradeItem.GetUiConnectRow().Cells["매매진행_매수가"].Value  = tradeItem.buyingPrice;
             tradeItem.GetUiConnectRow().Cells["매매진행_매수량"].Value  = tradeItem.curQnt;
             tradeItem.GetUiConnectRow().Cells["매매진행_매수금"].Value  = tradeItem.curQnt * tradeItem.buyingPrice;
             break;
         }
     }
 }
Ejemplo n.º 10
0
        public override void CheckUpdate(TradingItem item, double value)
        {
            if (!usingStrategy)
            {
                Console.WriteLine("usingStrategy : " + usingStrategy);
                return;
            }

            //Console.WriteLine("buyMore : " + item.useBuyMore + " value : " + value + " / d_conditionValue : " + d_conditionValue);
            if (value >= d_conditionValue && item.useBuyMore)
            {
                if (OnReceivedTrData != null)
                {
                    Core.CoreEngine.GetInstance().SendLogMessage(item.itemCode + " 추가 물타기 주문");
                    Core.CoreEngine.GetInstance().SaveItemLogMessage(item.itemCode, " 추가 물타기 주문 : " + value);

                    OnReceivedTrData.Invoke(this, new OnReceivedTrProfitBuyMoreEventArgs(this, item, value));

                    item.useBuyMore = false;
                }
            }
        }
Ejemplo n.º 11
0
        public TradingItemForSave(TradingItem item, TradingStrategyForSave ts)
        {
            this.tsSave = (ts);
            BindingFlags flags = BindingFlags.Instance | BindingFlags.GetField | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static;

            FieldInfo[] fieldArray = item.GetType().GetFields(flags);

            BindingFlags flagsStrategySave = BindingFlags.Instance | BindingFlags.GetField | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static;

            FieldInfo[] ItemSaveFieldArray = this.GetType().GetFields(flagsStrategySave);


            foreach (FieldInfo field in fieldArray)
            {
                foreach (FieldInfo SaveField in ItemSaveFieldArray)
                {
                    if (field.Name == SaveField.Name)
                    {
                        SaveField.SetValue(this, field.GetValue(item));
                    }
                }
            }
        }
Ejemplo n.º 12
0
 public OnReceivedTrProfitBuyMoreEventArgs(TradingStrategyItemProfitBuyingDivide tsItem, TradingItem item, double checkValue)
 {
     this.strategyItem = tsItem;
     this.tradingItem  = item;
     this.checkNum     = checkValue;
 }
Ejemplo n.º 13
0
        private void AddStratgy(TradingStrategyForSave saved)
        {
            List <TradingStrategyADDItem> tradingStrategyItemList = new List <TradingStrategyADDItem>();

            TradingStrategy ts = new TradingStrategy(
                saved.account,
                saved.buyCondition,
                saved.buyOrderOption,
                saved.totalInvestment,
                saved.buyItemCount,
                saved.sellProfitOrderOption,
                saved.sellStopLossOrderOption,
                saved.sellDivideStopLossOrderOption,
                false,
                saved.usingRestart
                );

            //추가전략 적용
            ts.remainItemCount = saved.remainItemCount;

            //trading item load
            foreach (var item in saved.tradingSaveItemList)
            {
                TradingItem itemAdd = item.ReloadTradingItem();
                itemAdd.ts = ts;
                ts.tradingItemList.Add(itemAdd);

                string fidList = "9001;302;10;11;25;12;13"; //9001:종목코드,302:종목명
                axKHOpenAPI1.SetRealReg("9001", itemAdd.itemCode, fidList, "1");

                //매매진행 데이터 그리드뷰 표시
                form.SetTradingItemUI(itemAdd);
            }

            if (saved.usingTimeLimit)
            {
                TradingStrategyItemBuyTimeCheck timeBuyCheck =
                    new TradingStrategyItemBuyTimeCheck(
                        StrategyItemName.BUY_TIME_LIMIT,
                        CHECK_TIMING.BUY_TIME,
                        new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, saved.startDate.Hour, saved.startDate.Minute, 0),
                        new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, saved.endDate.Hour, saved.endDate.Minute, 0));
                ts.AddTradingStrategyItemList(timeBuyCheck);
                ts.usingTimeLimit = true;
                ts.startDate      = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, saved.startDate.Hour, saved.startDate.Minute, 0);
                ts.endDate        = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, saved.endDate.Hour, saved.endDate.Minute, 0);
            }

            ts.usingTickBuy = saved.usingTickBuy;
            ts.tickBuyValue = saved.tickBuyValue;

            ts.usingTrailing   = saved.usingTrailing;
            ts.trailTickValue  = saved.trailTickValue;
            ts.trailMinusValue = saved.trailMinusValue;

            ts.usingPercentageBuy = saved.usingPercentageBuy;
            ts.percentageBuyValue = saved.percentageBuyValue;

            ts.usingVwma       = saved.usingVwma;
            ts.usingEnvelope5  = saved.usingEnvelope5;
            ts.usingEnvelope7  = saved.usingEnvelope7;
            ts.usingEnvelope10 = saved.usingEnvelope10;
            ts.usingEnvelope15 = saved.usingEnvelope15;
            ts.usingCheckIndex = saved.usingCheckIndex;
            ts.trailTickValue  = saved.trailTickValue;

            if (saved.usingGapTrailBuy)
            {
                ts.usingGapTrailBuy            = true;
                ts.gapTrailCostPercentageValue = saved.gapTrailCostPercentageValue;
                ts.gapTrailBuyTimeValue        = saved.gapTrailBuyTimeValue;

                TradingStrategyItemWithUpDownPercentValue trailGapBuy =
                    new TradingStrategyItemWithUpDownPercentValue(
                        StrategyItemName.BUY_GAP_CHECK,
                        CHECK_TIMING.BUY_TIME,
                        string.Empty,
                        ts.gapTrailCostPercentageValue);

                trailGapBuy.OnReceivedTrData += form.OnReceiveTrDataCheckGapTrailBuy;
                ts.AddTradingStrategyItemList(trailGapBuy);
            }

            if (saved.takeProfitRate > 0)
            {
                double takeProfitRate = 0;
                TradingStrategyItemWithUpDownValue takeProfitStrategy = null;
                takeProfitRate     = saved.takeProfitRate;
                takeProfitStrategy =
                    new TradingStrategyItemWithUpDownValue(
                        StrategyItemName.TAKE_PROFIT_SELL,
                        CHECK_TIMING.SELL_TIME,
                        IS_TRUE_OR_FALE_TYPE.UPPER_OR_SAME,
                        takeProfitRate);
                takeProfitStrategy.OnReceivedTrData += form.OnReceiveTrDataCheckProfitSell;
                ts.AddTradingStrategyItemList(takeProfitStrategy);
                ts.takeProfitRate = takeProfitRate;
            }

            if (saved.stoplossRate < 0)
            {
                double stopLossRate = 0;
                stopLossRate = saved.stoplossRate;
                TradingStrategyItemWithUpDownValue stopLossStrategy = null;
                stopLossStrategy =
                    new TradingStrategyItemWithUpDownValue(
                        StrategyItemName.STOPLOSS_SELL,
                        CHECK_TIMING.SELL_TIME,
                        IS_TRUE_OR_FALE_TYPE.DOWN,
                        stopLossRate);

                stopLossStrategy.OnReceivedTrData += form.OnReceiveTrDataCheckStopLoss;
                ts.AddTradingStrategyItemList(stopLossStrategy);
                ts.stoplossRate = stopLossRate;
            }

            if (saved.usingBuyMore)
            {
                ts.usingBuyMore = true;
                //물타기
                TradingStrategyItemBuyingDivide buyMoreStrategy =
                    new TradingStrategyItemBuyingDivide(
                        StrategyItemName.BUY_MORE_LOSS,
                        CHECK_TIMING.SELL_TIME,
                        IS_TRUE_OR_FALE_TYPE.DOWN,
                        saved.buyMoreRateLoss,
                        saved.buyMoreMoney);

                buyMoreStrategy.OnReceivedTrData += form.OnReceiveTrDataBuyMore;
                ts.AddTradingStrategyItemList(buyMoreStrategy);
                //불타기
                TradingStrategyItemBuyingDivide buyMoreStrategyProfit =
                    new TradingStrategyItemBuyingDivide(
                        StrategyItemName.BUY_MORE_PROFIT,
                        CHECK_TIMING.SELL_TIME,
                        IS_TRUE_OR_FALE_TYPE.UPPER_OR_SAME,
                        saved.buyMoreRateProfit,
                        saved.buyMoreMoney);

                buyMoreStrategyProfit.OnReceivedTrData += form.OnReceiveTrDataBuyMore;
                ts.AddTradingStrategyItemList(buyMoreStrategyProfit);
            }

            if (saved.usingBuyCancelByTime)
            {
                ts.usingBuyCancelByTime = true;

                TradingStrategyItemCancelByTime buyCancelStrategy =
                    new TradingStrategyItemCancelByTime(
                        StrategyItemName.BUY_CANCEL_BY_TIME,
                        CHECK_TIMING.BUY_ORDER_BEFORE_CONCLUSION,
                        DateTime.Now.Ticks
                        );

                buyCancelStrategy.OnReceivedTrData += form.OnReceiveTrDataBuyCancelByTime;
                ts.AddTradingStrategyItemList(buyCancelStrategy);
            }

            if (saved.useDivideSellLoss)
            {
                ts.useDivideSellLoss     = true;
                ts.useDivideSellLossLoop = saved.useDivideSellLossLoop;
                TradingStrategyItemWithUpDownValue divideStopLossStrategy = null;
                divideStopLossStrategy =
                    new TradingStrategyItemWithUpDownValue(
                        StrategyItemName.STOPLOSS_DIVIDE_SELL,
                        CHECK_TIMING.SELL_TIME,
                        IS_TRUE_OR_FALE_TYPE.DOWN,
                        saved.divideStoplossRate);

                divideStopLossStrategy.OnReceivedTrData += form.OnReceiveTrDataCheckStopLossDivide;

                ts.AddTradingStrategyItemList(divideStopLossStrategy);
                ts.divideStoplossRate       = saved.divideStoplossRate;
                ts.divideSellLossPercentage = (saved.divideSellLossPercentage);
                ts.divideSellCount          = saved.divideSellCount;
            }

            if (saved.useDivideSellProfit)
            {
                ts.useDivideSellProfit     = true;
                ts.useDivideSellProfitLoop = saved.useDivideSellProfitLoop;
                TradingStrategyItemWithUpDownValue divideProfitStrategy = null;
                divideProfitStrategy =
                    new TradingStrategyItemWithUpDownValue(
                        StrategyItemName.TAKE_PROFIT_DIVIDE_SELL,
                        CHECK_TIMING.SELL_TIME,
                        IS_TRUE_OR_FALE_TYPE.UPPER_OR_SAME,
                        saved.divideTakeProfitRate);

                divideProfitStrategy.OnReceivedTrData += form.OnReceiveTrDataCheckProfitDivide;

                ts.AddTradingStrategyItemList(divideProfitStrategy);
                ts.divideTakeProfitRate       = saved.divideTakeProfitRate;
                ts.divideSellProfitPercentage = (saved.divideSellProfitPercentage);
                ts.divideSellCountProfit      = saved.divideSellCountProfit;
            }

            if (form.tradingStrategyList.FindAll(o => (o.buyCondition.Name == ts.buyCondition.Name)).Count > 0)
            {
                return;
            }

            form.tradingStrategyList.Add(ts);
            form.AddStrategyToDataGridView(ts);

            if (ts.buyCondition.Name.Contains("dummy") == false)
            {
                form.StartMonitoring(ts.buyCondition);
            }

            if (saved.usingDoubleCheck)
            {
                form.StartMonitoring(ts.doubleCheckCondition);
                form.doubleCheckHashTable.Add(ts.doubleCheckCondition.Name, ts);
            }
        }
Ejemplo n.º 14
0
        private void API_OnReceiveChejanData(object sender, AxKHOpenAPILib._DKHOpenAPIEvents_OnReceiveChejanDataEvent e)
        {
            CoreEngine.GetInstance().SendLogMessage("API_OnReceiveChejanData");
            if (e.sGubun.Equals(ConstName.RECEIVE_CHEJAN_DATA_SUBMIT_OR_CONCLUSION))
            {
                CoreEngine.GetInstance().SendLogMessage("RECEIVE_CHEJAN_DATA_SUBMIT_OR_CONCLUSION");
                string orderState  = axKHOpenAPI1.GetChejanData(913).Trim();
                string outstanding = axKHOpenAPI1.GetChejanData(902).Trim();
                string orderType   = axKHOpenAPI1.GetChejanData(905).Replace("+", "").Replace("-", "").Trim();
                string ordernum    = axKHOpenAPI1.GetChejanData(9203).Trim();
                string itemCode    = axKHOpenAPI1.GetChejanData(9001).Replace("A", "");

                string conclusionPrice    = axKHOpenAPI1.GetChejanData(910).Trim();
                string conclusionQuantity = axKHOpenAPI1.GetChejanData(911).Trim();

                if (orderState.Equals(ConstName.RECEIVE_CHEJAN_DATA_SUBMIT))
                {
                    CoreEngine.GetInstance().SendLogMessage("RECEIVE_CHEJAN_DATA_SUBMIT");
                    if (orderType.Equals(ConstName.RECEIVE_CHEJAN_DATA_BUY))
                    {
                        CoreEngine.GetInstance().SendLogMessage("RECEIVE_CHEJAN_DATA_BUY : " + ordernum);
                        CoreEngine.GetInstance().SendLogWarningMessage("conclusionQuantity : " + conclusionQuantity);
                        if (tradingStrategy == null)
                        {
                            return;
                        }

                        List <TradingItem> tradeItemArray = tradingStrategy.tradingItemList.FindAll(o => o.itemCode.Equals(itemCode));
                        if (tradeItemArray.Count > 0)
                        {
                            foreach (var item in tradeItemArray)
                            {
                                if (Item != null && Item.itemCode == itemCode && string.IsNullOrEmpty(item.buyOrderNum) == false)
                                {
                                    Item.buyOrderNum = item.buyOrderNum;
                                }
                            }
                        }
                    }
                    else if (orderType.Equals(ConstName.RECEIVE_CHEJAN_DATA_SELL))
                    {
                        CoreEngine.GetInstance().SendLogMessage("RECEIVE_CHEJAN_DATA_SELL");
                    }
                    else if (orderType.Equals(ConstName.RECEIVE_CHEJAN_CANCEL_BUY_ORDER))
                    {
                        CoreEngine.GetInstance().SendLogMessage("RECEIVE_CHEJAN_CANCEL_BUY_ORDER");
                    }
                    else if (orderType.Equals(ConstName.RECEIVE_CHEJAN_CANCEL_SELL_ORDER))
                    {
                        CoreEngine.GetInstance().SendLogMessage("RECEIVE_CHEJAN_CANCEL_SELL_ORDER");
                    }
                }
                else if (orderState.Equals(ConstName.RECEIVE_CHEJAN_DATA_CONCLUSION))
                {
                    CoreEngine.GetInstance().SendLogMessage("RECEIVE_CHEJAN_DATA_CONCLUSION");
                    if (orderType.Contains(ConstName.RECEIVE_CHEJAN_DATA_BUY))
                    {
                        CoreEngine.GetInstance().SendLogMessage("RECEIVE_CHEJAN_DATA_BUY");
                        if (tradingStrategy == null)
                        {
                            return;
                        }
                        CoreEngine.GetInstance().SendLogWarningMessage("RECEIVE_CHEJAN_DATA_BUY ORDER NUM : " + ordernum);
                        CoreEngine.GetInstance().SendLogWarningMessage("conclusionQuantity : " + conclusionQuantity);

                        TradingItem tradeItem = tradingStrategy.tradingItemList.Find(o => o.buyOrderNum.Equals(ordernum));

                        if (tradeItem != null && string.IsNullOrEmpty(conclusionQuantity) == false)
                        {
                            if (Item != null)
                            {
                                CoreEngine.GetInstance().SendLogMessage(Item.curQnt + "/" + Item.buyQnt);

                                Item.curQnt      = long.Parse(conclusionQuantity);
                                Item.buyPrice    = tradeItem.buyingPrice;
                                Item.buyOrderNum = tradeItem.buyOrderNum;
                                if (Item.curQnt == Item.buyQnt)
                                {
                                    PushMartinGailItem(itemCode);
                                }
                            }
                        }
                        else
                        {
                            CoreEngine.GetInstance().SendLogWarningMessage("tradeItem is null ");
                        }
                    }
                    else if (orderType.Contains(ConstName.RECEIVE_CHEJAN_DATA_SELL))
                    {
                        if (tradingStrategy == null)
                        {
                            return;
                        }

                        TradingItem tradeItem = tradingStrategy.tradingItemList.Find(o => o.sellOrderNum.Equals(ordernum));
                        if (tradeItem != null && string.IsNullOrEmpty(outstanding) == false && string.IsNullOrEmpty(conclusionPrice) == false)
                        {
                            long buyingPrice = tradeItem.buyingPrice;
                            long sellPrice   = long.Parse(conclusionPrice.Replace("+", ""));

                            if (long.Parse(outstanding) == 0)
                            {
                                CoreEngine.GetInstance().SendLogMessage("Outstanding 0 : Profit : " + (sellPrice - buyingPrice) * tradeItem.buyingQnt);
                                TodayAllProfitAmount += (sellPrice - buyingPrice) * tradeItem.buyingQnt;
                                PopMartinGailItem((sellPrice - buyingPrice));
                            }
                            else
                            {
                                if (Item != null)
                                {
                                    Item.curQnt       = long.Parse(outstanding);
                                    Item.sellOrderNum = tradeItem.sellOrderNum;
                                }
                            }
                        }
                    }
                }
                else if (orderState.Equals(ConstName.RECEIVE_CHEJAN_DATA_OK))
                {
                    CoreEngine.GetInstance().SendLogMessage("RECEIVE_CHEJAN_DATA_OK");
                    if (orderType.Contains(ConstName.RECEIVE_CHEJAN_CANCEL_BUY_ORDER))
                    {
                        CoreEngine.GetInstance().SendLogMessage("RECEIVE_CHEJAN_CANCEL_BUY_ORDER");
                        if (int.Parse(outstanding) == 0)
                        {
                            if (Item != null)
                            {
                                PopMartinGailItem(0);
                            }
                        }
                    }
                    else if (orderType.Contains(ConstName.RECEIVE_CHEJAN_CANCEL_SELL_ORDER))
                    {
                        CoreEngine.GetInstance().SendLogMessage("RECEIVE_CHEJAN_CANCEL_SELL_ORDER");
                        if (int.Parse(outstanding) == 0)
                        {
                            if (Item != null)
                            {
                                PopMartinGailItem(0);
                            }
                        }
                    }
                }
            }
            else if (e.sGubun.Equals(ConstName.RECEIVE_CHEJAN_DATA_BALANCE))
            {
            }
        }
Ejemplo n.º 15
0
 public OnReceivedTrBuyCancel(TradingStrategyItemCancelByTime tsItem, TradingItem item, double checkValue)
 {
     this.strategyItem = tsItem;
     this.tradingItem  = item;
     this.checkNum     = checkValue;
 }
Ejemplo n.º 16
0
 public OnReceivedTrEventArgs(TradingItem item, double checkValue)
 {
     this.tradingItem = item;
     this.checkNum    = checkValue;
 }
Ejemplo n.º 17
0
        public override void CheckUpdate(TradingItem item, double value)
        {
            if (strategyItemName == StrategyItemName.STOPLOSS_DIVIDE_SELL)
            {
                Console.WriteLine(StrategyItemName.STOPLOSS_DIVIDE_SELL);
            }

            if (!usingStrategy)
            {
                return;
            }

            switch (checkType)
            {
            case IS_TRUE_OR_FALE_TYPE.DOWN:
                if (value < d_conditionValue)
                {
                    if (OnReceivedTrData != null)
                    {
                        OnReceivedTrData.Invoke(this, new OnReceivedTrEventArgs(item, value));
                    }
                }
                return;

            case IS_TRUE_OR_FALE_TYPE.DOWN_OR_SAME:
                if (value <= d_conditionValue)
                {
                    if (OnReceivedTrData != null)
                    {
                        OnReceivedTrData.Invoke(this, new OnReceivedTrEventArgs(item, value));
                    }
                }
                return;

            case IS_TRUE_OR_FALE_TYPE.SAME:
                if (value == d_conditionValue)
                {
                    if (OnReceivedTrData != null)
                    {
                        OnReceivedTrData.Invoke(this, new OnReceivedTrEventArgs(item, value));
                    }
                }
                return;

            case IS_TRUE_OR_FALE_TYPE.UPPER:
                if (value > d_conditionValue)
                {
                    if (OnReceivedTrData != null)
                    {
                        OnReceivedTrData.Invoke(this, new OnReceivedTrEventArgs(item, value));
                    }
                }
                return;

            case IS_TRUE_OR_FALE_TYPE.UPPER_OR_SAME:
                if (value >= d_conditionValue)
                {
                    if (OnReceivedTrData != null)
                    {
                        OnReceivedTrData.Invoke(this, new OnReceivedTrEventArgs(item, value));
                    }
                }
                return;
            }
        }
Ejemplo n.º 18
0
 public override void CheckUpdate(TradingItem item, double value)
 {
 }
Ejemplo n.º 19
0
 public virtual void CheckUpdate(TradingItem item, double value)
 {
 }