Exemplo n.º 1
0
        private int updateCurrentInfoGrid()
        {
            int result = 0;

            try
            {
                this.CurrentInfoGrid.Rows.Clear();

                if (m_boxer == null)
                {
                    result = 1;
                    return(result);
                }

                CandleBuffer candleBuf = m_boxer.getCandleBuffer();
                if (candleBuf == null)
                {
                    result = 1;
                    return(result);
                }

                Candlestick curCandle = candleBuf.getLastCandle();
                if (curCandle == null)
                {
                    result = 1;
                    return(result);
                }

                Position pos = m_boxer.getPosition();
                if (pos == null)
                {
                    result = 1;
                    return(result);
                }

                {
                    // ポジション
                    int idx = this.CurrentInfoGrid.Rows.Add();
                    this.CurrentInfoGrid.Rows[idx].Cells[0].Value = "POS";
                    this.CurrentInfoGrid.Rows[idx].Cells[1].Value = m_boxer.getPositionName();
                }

                {
                    // Entry値
                    int idx = this.CurrentInfoGrid.Rows.Add();
                    this.CurrentInfoGrid.Rows[idx].Cells[0].Value = "ENTRY";
                    this.CurrentInfoGrid.Rows[idx].Cells[1].Value = string.Format("{0:0}", m_boxer.getEntryPrice());
                }

                {
                    // 利益
                    int idx = this.CurrentInfoGrid.Rows.Add();
                    this.CurrentInfoGrid.Rows[idx].Cells[0].Value = "PROFIT_SUM";
                    this.CurrentInfoGrid.Rows[idx].Cells[1].Value = string.Format("{0:0}", m_boxer.m_profitSum);
                }

                {
                    // 終値(現在値)
                    int idx = this.CurrentInfoGrid.Rows.Add();
                    this.CurrentInfoGrid.Rows[idx].Cells[0].Value = "LAST";

                    this.CurrentInfoGrid.Rows[idx].Cells[1].Value = string.Format("{0:0}", curCandle.last);
                }

                //{
                //    // EMA
                //    int idx = this.CurrentInfoGrid.Rows.Add();
                //    this.CurrentInfoGrid.Rows[idx].Cells[0].Value = "EMA";
                //    this.CurrentInfoGrid.Rows[idx].Cells[1].Value = string.Format("{0:0}", curCandle.ema);
                //}

                //{
                //    // BOLL_H
                //    int idx = this.CurrentInfoGrid.Rows.Add();
                //    this.CurrentInfoGrid.Rows[idx].Cells[0].Value = "BOLL_H";
                //    this.CurrentInfoGrid.Rows[idx].Cells[1].Value = string.Format("{0:0}", curCandle.boll_high);
                //}

                //{
                //    // BOLL_L
                //    int idx = this.CurrentInfoGrid.Rows.Add();
                //    this.CurrentInfoGrid.Rows[idx].Cells[0].Value = "BOLL_L";
                //    this.CurrentInfoGrid.Rows[idx].Cells[1].Value = string.Format("{0:0}", curCandle.boll_low);
                //}

                {
                    // LASTとEMAとの差
                    int idx = this.CurrentInfoGrid.Rows.Add();
                    this.CurrentInfoGrid.Rows[idx].Cells[0].Value = "EMA_DIFF";
                    this.CurrentInfoGrid.Rows[idx].Cells[1].Value = string.Format("{0:0}", curCandle.last - curCandle.ema);
                }

                {
                    // EMAの角度
                    int idx = this.CurrentInfoGrid.Rows.Add();
                    this.CurrentInfoGrid.Rows[idx].Cells[0].Value = "EMA_ANGLE";
                    this.CurrentInfoGrid.Rows[idx].Cells[1].Value = string.Format("{0:0.0}", curCandle.ema_angle);
                }

                {
                    int idx = this.CurrentInfoGrid.Rows.Add();
                    this.CurrentInfoGrid.Rows[idx].Cells[0].Value = "CUR_BB";

                    if (curCandle == null)
                    {
                        this.CurrentInfoGrid.Rows[idx].Cells[1].Value = "NONE";
                    }
                    else
                    {
                        if (curCandle.isTouchBollHighLow())
                        {
                            this.CurrentInfoGrid.Rows[idx].Cells[1].Value = "TOUCH";
                        }
                        else
                        {
                            this.CurrentInfoGrid.Rows[idx].Cells[1].Value = "NONE";
                        }
                    }
                }

                {
                    int idx = this.CurrentInfoGrid.Rows.Add();
                    this.CurrentInfoGrid.Rows[idx].Cells[0].Value = "PREV_BB";

                    int curIndex = candleBuf.getCandleCount() - 1;

                    Candlestick prevCandle = candleBuf.getCandle(curIndex - 1);
                    Candlestick pastCandle = candleBuf.getCandle(curIndex - 2);
                    if (prevCandle == null && pastCandle == null)
                    {
                        this.CurrentInfoGrid.Rows[idx].Cells[1].Value = "NONE";
                    }
                    else
                    {
                        if (prevCandle.isTouchBollHighLow())
                        {
                            this.CurrentInfoGrid.Rows[idx].Cells[1].Value = "PREV_TOUCH";
                        }
                        else if (pastCandle.isTouchBollHighLow())
                        {
                            this.CurrentInfoGrid.Rows[idx].Cells[1].Value = "PAST_TOUCH";
                        }
                        else
                        {
                            this.CurrentInfoGrid.Rows[idx].Cells[1].Value = "NONE";
                        }
                    }
                }


                {
                    int idx = this.CurrentInfoGrid.Rows.Add();
                    this.CurrentInfoGrid.Rows[idx].Cells[0].Value = "PRE_LONG_LV";
                    this.CurrentInfoGrid.Rows[idx].Cells[1].Value = m_boxer.m_preLongBollLv;
                }
                {
                    int idx = this.CurrentInfoGrid.Rows.Add();
                    this.CurrentInfoGrid.Rows[idx].Cells[0].Value = "CUR_LONG_LV";
                    this.CurrentInfoGrid.Rows[idx].Cells[1].Value = m_boxer.m_curLongBollLv;
                }
                {
                    int idx = this.CurrentInfoGrid.Rows.Add();
                    this.CurrentInfoGrid.Rows[idx].Cells[0].Value = "PRE_SHORT_LV";
                    this.CurrentInfoGrid.Rows[idx].Cells[1].Value = m_boxer.m_preShortBollLv;
                }
                {
                    int idx = this.CurrentInfoGrid.Rows.Add();
                    this.CurrentInfoGrid.Rows[idx].Cells[0].Value = "CUR_SHORT_LV";
                    this.CurrentInfoGrid.Rows[idx].Cells[1].Value = m_boxer.m_curShortBollLv;
                }
                {
                    double vola = curCandle.getVolatility();
                    int    idx  = this.CurrentInfoGrid.Rows.Add();
                    this.CurrentInfoGrid.Rows[idx].Cells[0].Value = "VOLA";
                    this.CurrentInfoGrid.Rows[idx].Cells[1].Value = string.Format("{0:0}", vola);
                }

                {
                    int idx = this.CurrentInfoGrid.Rows.Add();
                    this.CurrentInfoGrid.Rows[idx].Cells[0].Value = "VOLA_MA";
                    this.CurrentInfoGrid.Rows[idx].Cells[1].Value = string.Format("{0:0}", curCandle.vola_ma);
                }

                {
                    double vola_rate = curCandle.getVolatilityRate();
                    int    idx       = this.CurrentInfoGrid.Rows.Add();
                    this.CurrentInfoGrid.Rows[idx].Cells[0].Value = "VOLA_RATE";
                    this.CurrentInfoGrid.Rows[idx].Cells[1].Value = string.Format("{0:0}%", vola_rate);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                result = -1;
            }
            finally
            {
            }
            return(result);
        }