50 lines
1.7 KiB
C#
50 lines
1.7 KiB
C#
using DocumentFormat.OpenXml.Spreadsheet;
|
|
using Org.BouncyCastle.Ocsp;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Net.Http;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using YLErp.Helpers;
|
|
using YLErp.Modules.TradeRiskCalcModule;
|
|
|
|
namespace YLErp.Modules.ApiModule
|
|
{
|
|
public class YLErpWebApiHelper
|
|
{
|
|
private string baseUrl;
|
|
private Func<string> tokenFunc;
|
|
private HttpHelper httpHelper;
|
|
public YLErpWebApiHelper(Func<string> tokenFunc)
|
|
{
|
|
this.tokenFunc = tokenFunc;
|
|
string ylErpWebUrl = Environment.GetEnvironmentVariable("AppSettings:YLErpWebUrl") ?? PS.Config.ErpElement.YLErpWebUrl;
|
|
httpHelper = new HttpHelper(ylErpWebUrl, tokenFunc);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 查询实时风险
|
|
/// </summary>
|
|
/// <param name="request"></param>
|
|
/// <returns></returns>
|
|
public async Task<TradingRiskResult> GetTradingRisk(TradingRiskReqModel request)
|
|
{
|
|
// http 请求 Web项目接口
|
|
var result = await httpHelper.PostRequest<TradingRiskReqModel, TradingRiskResult>("/m/api/v1/realtimeRiskCalc", request);
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 查询实时持仓
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public async Task<IEnumerable<ExchangePositionItem>> GetExchangePositions()
|
|
{
|
|
// http 请求 Web项目接口
|
|
var result = await httpHelper.PostRequest<TradingRiskReqModel, IEnumerable<ExchangePositionItem>>("/m/api/v1/realtimeExchangePositions", null);
|
|
return result;
|
|
}
|
|
}
|
|
}
|