|
|
@@ -1,6 +1,9 @@
|
|
|
package cn.muchinfo.rma.view.base.chart.old.timeCharts;
|
|
|
|
|
|
import android.content.Context;
|
|
|
+import android.graphics.Color;
|
|
|
+import android.text.Html;
|
|
|
+import android.widget.TextView;
|
|
|
|
|
|
import com.desfate.chart.MinusStickChart;
|
|
|
import com.desfate.chart.data.BidChartTotalDatas;
|
|
|
@@ -15,7 +18,9 @@ import com.desfate.chart.entity.LineEntity;
|
|
|
import com.desfate.chart.entity.OHLCEntity;
|
|
|
import com.desfate.chart.entity.StickEntity;
|
|
|
import com.desfate.chart.ui.old.OTC.controls.TargetControl;
|
|
|
+import com.desfate.chart.util.MathUtil;
|
|
|
|
|
|
+import java.text.NumberFormat;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
@@ -495,4 +500,220 @@ public class StickChartTools {
|
|
|
minusstickchart.setDecimalNum(2);
|
|
|
minusstickchart.postInvalidate();
|
|
|
}
|
|
|
+
|
|
|
+ /***********************文本显示*********************************/
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param minusStickChart
|
|
|
+ * @param index
|
|
|
+ */
|
|
|
+ public static void showTotalSum(Context context, MinusStickChart minusStickChart, List<OHLCEntity> mOHLCList, TextView textView, int index) {
|
|
|
+ if (mOHLCList.size() == 0) {
|
|
|
+ textView.setText("");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ String bias = "<font color='%s'> VOL5:%s </font><font color='%s'> VOL10:%s </font><font color='%s'> VOLNUM:%s </font>";
|
|
|
+ String htmlString = "";
|
|
|
+ String total5 = "";
|
|
|
+ String total10 = "";
|
|
|
+ String totalNum = "";
|
|
|
+ try {
|
|
|
+ index = index == 0 ? minusStickChart.getNewLineData().get(0).getLineData().size() - 1 : index;
|
|
|
+ total5 = MathUtil.roundNum(minusStickChart.getNewLineData().get(0).getLineData().get(index), 2);
|
|
|
+ total10 = MathUtil.roundNum(minusStickChart.getNewLineData().get(1).getLineData().get(index), 2);
|
|
|
+ totalNum = "" + (int) minusStickChart.getNewStickData().get(index).getHigh();
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ htmlString = String.format(bias, context.getResources().getColor(com.desfate.chart.R.color.mtp_chart_k_total5), total5,
|
|
|
+ context.getResources().getColor(com.desfate.chart.R.color.mtp_chart_k_total10), total10, Color.RED, totalNum);
|
|
|
+ textView.setText(Html.fromHtml(htmlString));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * BIAS6 BIAS12 BIAS24
|
|
|
+ *
|
|
|
+ * @param minusStickChart
|
|
|
+ * @param index
|
|
|
+ */
|
|
|
+ public static void showBIASSum(Context context, MinusStickChart minusStickChart, List<OHLCEntity> mOHLCList, TextView textView, int index) {
|
|
|
+ if (mOHLCList.size() == 0) {
|
|
|
+ textView.setText("");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ String bias = "<font color='%s'> BIAS6:%s </font><font color='%s'> BIAS12:%s </font><font color='%s'> BIAS24:%s</font>";
|
|
|
+ String htmlString = "";
|
|
|
+ String bias6String = "0.0";
|
|
|
+ String bias12String = "0.0";
|
|
|
+ String bias24String = "0.0";
|
|
|
+ try {
|
|
|
+ index = index == 0 ? minusStickChart.getNewLineData().get(0).getLineData().size() - 1 : index;
|
|
|
+ bias6String = MathUtil.roundNum(minusStickChart.getNewLineData().get(0).getLineData().get(index), 2);
|
|
|
+ bias12String = MathUtil.roundNum(minusStickChart.getNewLineData().get(1).getLineData().get(index), 2);
|
|
|
+ bias24String = MathUtil.roundNum(minusStickChart.getNewLineData().get(2).getLineData().get(index), 2);
|
|
|
+ } catch (Exception e) {
|
|
|
+ }
|
|
|
+ htmlString = String.format(bias, context.getResources().getColor(com.desfate.chart.R.color.mtp_chart_k_bias_6), bias6String,
|
|
|
+ context.getResources().getColor(com.desfate.chart.R.color.mtp_chart_k_bias_12), bias12String, context.getResources().getColor(com.desfate.chart.R.color.mtp_chart_k_bias_24), bias24String);
|
|
|
+ textView.setText(Html.fromHtml(htmlString));
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void showKDJSum(Context context, MinusStickChart minusStickChart, List<OHLCEntity> mOHLCList, TextView textView, int index) {
|
|
|
+ if (mOHLCList.size() == 0) {
|
|
|
+ textView.setText("");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ String bias = "<font color='%s'> K:%s </font><font color='%s'> D:%s </font><font color='%s'> J:%s </font>";
|
|
|
+ String htmlString = "";
|
|
|
+ String kString = "0.0";
|
|
|
+ String dString = "0.0";
|
|
|
+ String jString = "0.0";
|
|
|
+ try {
|
|
|
+ index = index == 0 ? minusStickChart.getNewLineData().get(0).getLineData().size() - 1 : index;
|
|
|
+ kString = MathUtil.roundNum(minusStickChart.getNewLineData().get(0).getLineData().get(index), 2);
|
|
|
+ dString = MathUtil.roundNum(minusStickChart.getNewLineData().get(1).getLineData().get(index), 2);
|
|
|
+ jString = MathUtil.roundNum(minusStickChart.getNewLineData().get(2).getLineData().get(index), 2);
|
|
|
+ } catch (Exception e) {
|
|
|
+ }
|
|
|
+
|
|
|
+ htmlString = String.format(bias, context.getResources().getColor(com.desfate.chart.R.color.mtp_chart_k_kdj_k), kString,
|
|
|
+ context.getResources().getColor(com.desfate.chart.R.color.mtp_chart_k_kdj_j), dString, context.getResources().getColor(com.desfate.chart.R.color.mtp_chart_k_kdj_j), jString);
|
|
|
+
|
|
|
+ textView.setText(Html.fromHtml(htmlString));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * DMA AMA
|
|
|
+ *
|
|
|
+ * @param minusStickChart
|
|
|
+ * @param index
|
|
|
+ */
|
|
|
+ public static void showDMASum(Context context, MinusStickChart minusStickChart, List<OHLCEntity> mOHLCList, TextView textView, int index) {
|
|
|
+ if (mOHLCList.size() == 0) {
|
|
|
+ textView.setText("");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ String dma = "<font color='%s'> DMA:%s </font><font color='%s'> AMA:%s</font>";
|
|
|
+ String htmlString = "";
|
|
|
+ String dmaString = "0.0";
|
|
|
+ String amaString = "0.0";
|
|
|
+ try {
|
|
|
+ index = index == 0 ? minusStickChart.getNewLineData().get(0).getLineData().size() - 1 : index;
|
|
|
+ dmaString = MathUtil.roundNum(minusStickChart.getNewLineData().get(0).getLineData().get(index), 2);
|
|
|
+ amaString = MathUtil.roundNum(minusStickChart.getNewLineData().get(1).getLineData().get(index), 2);
|
|
|
+ } catch (Exception e) {
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ htmlString = String.format(dma, context.getResources().getColor(com.desfate.chart.R.color.mtp_chart_k_dma), dmaString,
|
|
|
+ context.getResources().getColor(com.desfate.chart.R.color.mtp_chart_k_dma_ama), amaString);
|
|
|
+
|
|
|
+ textView.setText(Html.fromHtml(htmlString));
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void showCCISum(Context context, MinusStickChart minusStickChart, List<OHLCEntity> mOHLCList, TextView textView, int index) {
|
|
|
+ if (mOHLCList.size() == 0) {
|
|
|
+ textView.setText("");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ String cci = "<font color='%s'> CCI:%s </font>";
|
|
|
+ String htmlString = "";
|
|
|
+ String cciValue = "0.0";
|
|
|
+ try {
|
|
|
+ index = index == 0 ? minusStickChart.getNewLineData().get(0).getLineData().size() - 1 : index;
|
|
|
+ cciValue = MathUtil.roundNum(minusStickChart.getNewLineData().get(0).getLineData().get(index), 2);
|
|
|
+ } catch (Exception e) {
|
|
|
+ }
|
|
|
+ htmlString = String.format(cci, context.getResources().getColor(com.desfate.chart.R.color.mtp_chart_k_cci), cciValue);
|
|
|
+ textView.setText(Html.fromHtml(htmlString));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 显示RSI对应的sum
|
|
|
+ */
|
|
|
+ public static void showRSISum(Context context, MinusStickChart minusStickChart, List<OHLCEntity> mOHLCList, TextView textView, int index) {
|
|
|
+ if (mOHLCList.size() == 0) {
|
|
|
+ textView.setText("");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ String rsi = "<font color='%s'> RSI6:%s </font><font color='%s'> RSI12:%s </font><font color='%s'> RSI24:%s </font>";
|
|
|
+ String strHtml = "";
|
|
|
+ try {
|
|
|
+ index = index == 0 ? minusStickChart.getNewLineData().get(0).getLineData().size() - 1 : index;
|
|
|
+ String value6 = MathUtil.roundNum(minusStickChart.getNewLineData().get(0).getLineData().get(index), 2);
|
|
|
+ String value12 = MathUtil.roundNum(minusStickChart.getNewLineData().get(1).getLineData().get(index), 2);
|
|
|
+ String value24 = MathUtil.roundNum(minusStickChart.getNewLineData().get(2).getLineData().get(index), 2);
|
|
|
+ strHtml = String.format(rsi,
|
|
|
+ context.getResources().getColor(com.desfate.chart.R.color.mtp_chart_k_rsi6), value6,
|
|
|
+ context.getResources().getColor(com.desfate.chart.R.color.mtp_chart_k_rsi12), value12,
|
|
|
+ context.getResources().getColor(com.desfate.chart.R.color.mtp_chart_k_rsi24), value24);
|
|
|
+ } catch (Exception e) {
|
|
|
+ strHtml = "RSI:0.0";
|
|
|
+ }
|
|
|
+ textView.setText(Html.fromHtml(strHtml));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 显示MACD对应的sum
|
|
|
+ */
|
|
|
+ public static void showMACDSum(Context context , List<ChartData> mOHLCList, TextView textView, int index) {
|
|
|
+ if (mOHLCList.size() == 0) {
|
|
|
+ textView.setText("");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ setMinusStickText(context, textView, mOHLCList.get(index == 0 ? mOHLCList.size() - 1 : index));
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private static void setMinusStickText(Context context, TextView minusStickTV, ChartData data) {
|
|
|
+ NumberFormat nf = NumberFormat.getInstance();
|
|
|
+ nf.setGroupingUsed(false);
|
|
|
+ nf.setMaximumFractionDigits(2);
|
|
|
+ nf.setMinimumFractionDigits(2);
|
|
|
+ String macd = nf.format(data.getMACD());
|
|
|
+ String strMACDColor = "#FF0000";
|
|
|
+ if (data.getMACD() < 0) {
|
|
|
+ strMACDColor = "#009900";
|
|
|
+ }
|
|
|
+ String dif = nf.format(data.getDIF());
|
|
|
+ String dea = nf.format(data.getDEA());
|
|
|
+ String source = "<font color='%s'>MACD:%s </font>";
|
|
|
+ source += "<font color='" + context.getResources().getColor(com.desfate.chart.R.color.mtp_chart_k_macd_dif) + "'>DIF:%s </font>";
|
|
|
+ source += "<font color='" + context.getResources().getColor(com.desfate.chart.R.color.mtp_chart_k_macd_dea) + "'>DEA:%s</font>";
|
|
|
+
|
|
|
+ String strHtml = String.format(source, strMACDColor, macd, dif, dea);
|
|
|
+ minusStickTV.setText(Html.fromHtml(strHtml));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * PSY PSYMA
|
|
|
+ *
|
|
|
+ * @param minusStickChart
|
|
|
+ * @param index
|
|
|
+ */
|
|
|
+ public static void showPSYSum(Context context, MinusStickChart minusStickChart, List<OHLCEntity> mOHLCList, TextView textView, int index) {
|
|
|
+ if (mOHLCList.size() == 0) {
|
|
|
+ textView.setText("");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ String psy = "<font color='%s'> PSY:%s </font><font color='%s'> PSYMA:%s </font>";
|
|
|
+ String strHtml = "";
|
|
|
+ String psyValue = "0.0";
|
|
|
+ String psyMAValue = "0.0";
|
|
|
+ try {
|
|
|
+ index = index == 0 ? minusStickChart.getNewLineData().get(0).getLineData().size() - 1 : index;
|
|
|
+ psyValue = MathUtil.roundNum(minusStickChart.getNewLineData().get(0).getLineData().get(index), 2);
|
|
|
+ psyMAValue = MathUtil.roundNum(minusStickChart.getNewLineData().get(1).getLineData().get(index), 2);
|
|
|
+ } catch (Exception e) {
|
|
|
+ }
|
|
|
+
|
|
|
+ strHtml = String.format(psy, context.getResources().getColor(com.desfate.chart.R.color.mtp_chart_k_psy), psyValue,
|
|
|
+ context.getResources().getColor(com.desfate.chart.R.color.mtp_chart_k_psy_ma), psyMAValue);
|
|
|
+
|
|
|
+ textView.setText(Html.fromHtml(strHtml));
|
|
|
+ }
|
|
|
}
|