Explorar o código

yu.jie 图表相关 分时图

yu jie %!s(int64=4) %!d(string=hai) anos
pai
achega
e47705b8f7

+ 21 - 5
RMA/app/src/main/java/cn/muchinfo/rma/view/base/chart/old/timeCharts/KChartView.java

@@ -30,6 +30,7 @@ public class KChartView extends FrameLayout {
     MACandleStickChart candle_chart;
     MinusStickChart minusStickChart;
     TextView info_text;
+    String state = ChartConstant.BIAS;
 
     public KChartView(@NonNull Context context) {
         super(context);
@@ -53,6 +54,9 @@ public class KChartView extends FrameLayout {
         setMinusStickChartConfig();
     }
 
+    /**
+     * 蜡烛图配置
+     */
     private void setCandleChartConfig(){
         int fontSize = getResources().getDimensionPixelSize(R.dimen.chart_font_size);
         candle_chart.setLongitudeFontSize(fontSize);
@@ -83,6 +87,9 @@ public class KChartView extends FrameLayout {
         candle_chart.setDisplayCrossYOnTouch(true);
     }
 
+    /**
+     * 指标配置
+     */
     private void setMinusStickChartConfig(){
         minusStickChart.setMaxSticksNum(ChartConstant.MAXSTICKNUM);
         minusStickChart.setAxisMarginRight(1);
@@ -137,10 +144,19 @@ public class KChartView extends FrameLayout {
         M15Line.setLineColor(getResources().getColor(com.desfate.chart.R.color.mtp_chart_k_ma5));
         M15Line.setLineData(new KChartTools().getMDatesAdapter(15, history));
         lines.add(M15Line);
-        minusStickChart.setTasLastPrice(String.valueOf(new ChartDataAdapter().getGoodsInfoMarket(goodsCode).getQuoteDayData().getLast()));
-        minusStickChart.setNewPriceColor(getResources().getColor(R.color.p_up_color));
-        minusStickChart.setLineData(lines);
-        minusStickChart.setDecimalNum(new ChartDataAdapter().getGoodsInfoMarket(goodsCode).getGoodsInfo().getDecimalplace());
-        minusStickChart.postInvalidate();
+        candle_chart.setTasLastPrice(String.valueOf(new ChartDataAdapter().getGoodsInfoMarket(goodsCode).getQuoteDayData().getLast()));
+        candle_chart.setNewPriceColor(getResources().getColor(R.color.p_up_color));
+        candle_chart.setLineData(lines);
+        candle_chart.setDecimalNum(new ChartDataAdapter().getGoodsInfoMarket(goodsCode).getGoodsInfo().getDecimalplace());
+        candle_chart.postInvalidate();
     }
+
+
+
+
+
+
+
+
+
 }

+ 120 - 0
RMA/app/src/main/java/cn/muchinfo/rma/view/base/chart/old/timeCharts/StickChartTools.java

@@ -0,0 +1,120 @@
+package cn.muchinfo.rma.view.base.chart.old.timeCharts;
+
+import android.content.Context;
+
+import com.desfate.chart.MinusStickChart;
+import com.desfate.chart.data.ChartDataContainer;
+import com.desfate.chart.data.ChartPSYDatas;
+import com.desfate.chart.data.ChartRSIDatas;
+import com.desfate.chart.entity.LineEntity;
+import com.desfate.chart.entity.StickEntity;
+import com.desfate.chart.ui.old.OTC.controls.TargetControl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import cn.muchinfo.rma.view.base.chart.old.OTCChartActivity;
+
+/**
+ * 指标工具
+ */
+public class StickChartTools {
+
+    /**
+     * RSI 周期为6
+     *
+     * @param minusstickchart
+     * @param dataContainer
+     */
+    private void setRSILine(Context context, MinusStickChart minusstickchart, ChartDataContainer dataContainer) {
+        if (dataContainer.mSize == 0) {
+            minusstickchart.postInvalidate();
+            return;
+        }
+
+        /**
+         * RSI 5
+         */
+        List<LineEntity> lines = new ArrayList<LineEntity>();
+        ChartRSIDatas rsiData = new TargetControl().getRSI(dataContainer);
+
+        LineEntity rsi = new LineEntity();
+        rsi.setLineData(rsiData.getRsi6());
+        rsi.setLineColor(context.getResources().getColor(com.desfate.chart.R.color.mtp_chart_k_rsi6));
+        rsi.setStartIndex(5);
+        lines.add(rsi);
+
+        LineEntity rsi12 = new LineEntity();
+        rsi12.setLineData(rsiData.getRsi12());
+        rsi12.setLineColor(context.getResources().getColor(com.desfate.chart.R.color.mtp_chart_k_rsi12));
+        rsi12.setStartIndex(11);
+        lines.add(rsi12);
+
+
+        LineEntity rsi24 = new LineEntity();
+        rsi24.setLineData(rsiData.getRsi24());
+        rsi24.setLineColor(context.getResources().getColor(com.desfate.chart.R.color.mtp_chart_k_rsi24));
+        rsi24.setStartIndex(23);
+        lines.add(rsi24);
+
+        minusstickchart.setLineData(lines);
+
+        List<StickEntity> entities = new ArrayList<StickEntity>();
+        StickEntity entity = null;
+        for (int i = 0; i < dataContainer.mStickList.subList(0, dataContainer.mSize).size(); i++) {
+            entity = new StickEntity();
+            entity.setHigh(100.0);
+            entity.setLow(0.0);
+            entities.add(entity);
+        }
+
+        minusstickchart.setShowStick(false);
+        minusstickchart.setStickData(entities);
+//        minusstickchart.setDecimalNum(mDecimalNum);
+        minusstickchart.postInvalidate();
+    }
+
+    /**
+     * 26 6 PSY
+     *
+     * @param minusstickchart
+     * @param dataContainer
+     */
+    private void setPSYLine(MinusStickChart minusstickchart, ChartDataContainer dataContainer) {
+        if (dataContainer.mSize == 0) {
+            return;
+        }
+        ChartPSYDatas chartPSYDatas = new TargetControl().getPSYs(dataContainer);
+        List<LineEntity> lines = new ArrayList<LineEntity>();
+
+        /**
+         * psy
+         */
+        LineEntity psy = new LineEntity();
+        psy.setLineData(chartPSYDatas.getPsy());
+
+//        psy.setLineColor(((OTCChartActivity) getActivity()).getMtpChartControl().getPSYColor());
+
+        psy.setStartIndex(25);
+        lines.add(psy);
+
+        /**
+         * psyMa
+         */
+        LineEntity psyMa = new LineEntity();
+        psyMa.setLineData(chartPSYDatas.getPsyMa());
+
+//        psyMa.setLineColor(((OTCChartActivity) getActivity()).getMtpChartControl().getPSYMAColor());
+
+        psyMa.setStartIndex(25);
+        lines.add(psyMa);
+
+        minusstickchart.setLineData(lines);
+
+        minusstickchart.setShowStick(false);
+        minusstickchart.setStickData(dataContainer.mStickList.subList(0, dataContainer.mSize));
+
+//        minusstickchart.setDecimalNum(mDecimalNum);
+        minusstickchart.postInvalidate();
+    }
+}

+ 20 - 0
RMA/chart/src/main/java/com/desfate/chart/ChartConstant.java

@@ -63,5 +63,25 @@ public class ChartConstant {
      */
     public final static int K_QUARTER = 3 * 30 * 1440;
 
+    /**
+     * 指标数据
+     */
+    public final static String RSI = "RSI";
+
+    public final static String MACD = "MACD";
+
+    public final static String PSY = "PSY";
+
+    public final static String CCI = "CCI";
+
+    public final static String DMA = "DMA";
+
+    public final static String KDJ = "KDJ";
+
+    public final static String BIAS = "BIAS";
+
+    public final static String VOL = "VOL";
+
+
 
 }