Example #1
0
        public void SerializeTrailing(List <TrailingItem> trailingList)
        {
            List <TrailingPercentageItemForSave> trailingSaveList = new List <TrailingPercentageItemForSave>();

            foreach (var item in trailingList)
            {
                TrailingPercentageItemForSave saveItem = new TrailingPercentageItemForSave(item, item.strategy);
                trailingSaveList.Add(saveItem);
            }

            try
            {
                BinaryFormatter binFmt = new BinaryFormatter();

                using (FileStream fs = new FileStream(DateTime.Now.ToString("yyyy_MM_dd") + DATA_TRAIL_FILE_NAME, FileMode.Create))
                {
                    binFmt.Serialize(fs, trailingSaveList);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(1);
                Console.WriteLine(e);
            }
        }
Example #2
0
        private void AddTrailing(TrailingPercentageItemForSave saved)
        {
            Task requestItemInfoTask = new Task(() =>
            {
                TrailingItem itemAdd = saved.ReloadTrailingItem();

                foreach (var strategyItem in form.tradingStrategyList)
                {
                    if (saved.strategySave.buyCondition.Name == strategyItem.buyCondition.Name)
                    {
                        itemAdd.strategy = strategyItem;
                    }
                }

                axKHOpenAPI1.SetInputValue("종목코드", itemAdd.itemCode);
                int result = axKHOpenAPI1.CommRqData(ConstName.RECEIVE_REAL_DATA_HOGA, "opt10004", 0, Form1.GetScreenNum().ToString());

                form.SetTrailingItem(itemAdd);
            });

            RequestTrDataManager.GetInstance().RequestTrData(requestItemInfoTask);
        }