1
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using MuHua;
|
||||
|
||||
/// <summary>
|
||||
/// 数据采集
|
||||
/// </summary>
|
||||
public class AnalysisCollector : Module<AnalysisCollector> {
|
||||
/// <summary> 接口 :https://api.mairui.club/hszbl/fsjy/股票代码(如000001)/分时级别/licence证书 </summary>
|
||||
public string API => "https://api.mairui.club/hszbl/fsjy/";
|
||||
|
||||
public void GetStock(string code, Action<List<DataAnalysis>> action, bool isCache = true) {
|
||||
string json = SaveTool.LoadText(FileName.Create(code));
|
||||
if (json != null && json != "" && isCache) { StockToAnalysis(json, action); return; }
|
||||
|
||||
//https://api.mairui.club/hszbl/fsjy/000001/60m/b997d4403688d5e66a
|
||||
string url = $"{API}{code}/dn/2E111385-7BF1-473D-9210-8E22AA75375A";
|
||||
Debug.Log($"{code}重新缓存了数据!");
|
||||
|
||||
DataRequestGet request = new DataRequestGet(url);
|
||||
request.OnError = (json) => { Debug.Log(json); };
|
||||
request.OnCallback = (json) => {
|
||||
SaveTool.SaveText(FileName.Create(code), json);
|
||||
StockToAnalysis(json, action);
|
||||
};
|
||||
AsyncWebRequest.Execute(request);
|
||||
}
|
||||
|
||||
public void StockToAnalysis(string json, Action<List<DataAnalysis>> action = null) {
|
||||
List<DataStock> stocks = JsonTool.FromJson<List<DataStock>>(json);
|
||||
List<DataAnalysis> analyses = new List<DataAnalysis>();
|
||||
for (int i = 0; i < stocks.Count; i++) { analyses.Add(stocks[i].To()); }
|
||||
action?.Invoke(analyses);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 06f3d6e55c2a1584ba20c9262c06704d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,16 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using MuHua;
|
||||
|
||||
/// <summary>
|
||||
/// 分析模块
|
||||
/// </summary>
|
||||
public class ModuleAnalysis : MonoBehaviour {
|
||||
public List<DataAnalysis> analyses;
|
||||
private void Start() {
|
||||
AnalysisCollector.I.GetStock("601658", (analyses) => { this.analyses = analyses; });
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 690f28715cec9bc41a56277db51f79fc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,11 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 交易模块
|
||||
/// </summary>
|
||||
public abstract class ModuleTrading {
|
||||
/// <summary> 执行交易 </summary>
|
||||
public abstract void Execute();
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 11336b15ef40f45488427630359ab3ba
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user