| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using Muchinfo.MTPClient.Adapter.Abstract;
- using Muchinfo.MTPClient.Data;
- using Muchinfo.MTPClient.Data.Enums;
- using Muchinfo.MTPClient.Data.Model.Account;
- using Muchinfo.MTPClient.Data.Model.Report;
- using Muchinfo.MTPClient.Infrastructure.LinkProxy;
- using Muchinfo.MTPClient.Infrastructure.Utilities;
- using Muchinfo.MTPClient.IService;
- using Muchinfo.MTPClient.Resources;
- using Muchinfo.MTPClient.Service.Utilities;
- using Muchinfo.MTPClient.Data.Model;
- using Muchinfo.MTPClient.Infrastructure.Cache;
- namespace Muchinfo.MTPClient.Service
- {
- /// <summary>
- /// 通用查询服务
- /// </summary>
- public class CommonQueryService : ICommonQueryService
- {
- #region Public Methods
- /// <summary>
- /// 查询市场运行状态
- /// </summary>
- /// <param name="marketId">The market identifier.</param>
- /// <param name="successAction">The success action.</param>
- /// <param name="errorAction">The error action.</param>
- public void QueryMarketRun(int marketId, Action<List<MarketRunModelNew>> successAction, Action<ErrorEntity> errorAction)
- {
- var statement = QueryStatement.ClientSearchMarketRun;
- var queryParams = new List<QueryCommonParam>()
- {
- new QueryCommonParam() { ParamKey = "marketId", ParamValue = marketId.ToString()},
- };
- QueryCommonHelper.QueryCommon(statement, queryParams, successAction, errorAction, "查询市场运行状态");
- }
- /// <summary>
- /// 查询结算单-资金账户信息
- /// </summary>
- /// <param name="cycleType">Type of the cycle.</param>
- /// <param name="cycleTime">The cycle time.</param>
- /// <param name="successAction">The success action.</param>
- /// <param name="errorAction">The error action.</param>
- /// <exception cref="System.NotImplementedException"></exception>
- public void QueryTaAccount(ReckonReportQueryType cycleType, string cycleTime, Action<List<ReckonAccountModel>> successAction, Action<ErrorEntity> errorAction)
- {
- var statement = QueryStatement.ClientDayRetortTaaccount;
- var queryParams = new List<QueryCommonParam>()
- {
- new QueryCommonParam() { ParamKey = "accountId", ParamValue = UserManager.CurrentTradeAccount.FundsAccountId.ToString()},
- new QueryCommonParam() { ParamKey = "cycleTime", ParamValue = cycleTime },
- };
- if (cycleType != ReckonReportQueryType.DayReckon)
- {
- //周期报表
- statement = QueryStatement.ClientRetortTaaccount;
- queryParams.Add(new QueryCommonParam() { ParamKey = "cycleType", ParamValue = ((int)cycleType).ToString() });
- }
- QueryCommonHelper.QueryCommon(statement, queryParams, successAction, errorAction, "查询结算单-账号资金信息");
- }
- /// <summary>
- /// 查询结算单-资金账户币种信息
- /// </summary>
- /// <param name="cycleType">Type of the cycle.</param>
- /// <param name="cycleTime">The cycle time.</param>
- /// <param name="successAction">The success action.</param>
- /// <param name="errorAction">The error action.</param>
- public void QueryTaAccountCur(ReckonReportQueryType cycleType, string cycleTime, Action<List<ReckonReportModel>> successAction, Action<ErrorEntity> errorAction)
- {
- var statement = QueryStatement.ClientReportDayTaAccountCur;
- var queryParams = new List<QueryCommonParam>()
- {
- new QueryCommonParam() { ParamKey = "accountId", ParamValue = UserManager.CurrentTradeAccount.FundsAccountId.ToString()},
- new QueryCommonParam() { ParamKey = "cycleTime", ParamValue = cycleTime },
- };
- if (cycleType != ReckonReportQueryType.DayReckon)
- {
- //周期报表
- statement = QueryStatement.ClientReportTaAccountCur;
- queryParams.Add(new QueryCommonParam() { ParamKey = "cycleType", ParamValue = ((int)cycleType).ToString() });
- }
- QueryCommonHelper.QueryCommon(statement, queryParams, successAction, errorAction, "查询结算单-资金账户币种信息");
- }
- /// <summary>
- /// 查询账户止盈止损单
- /// </summary>
- /// <param name="accountId">The account identifier.</param>
- /// <param name="successAction">The success action.</param>
- /// <param name="errorAction">The error action.</param>
- /// <exception cref="System.NotImplementedException"></exception>
- public void QuerySPSLOrder(ulong accountId, Action<List<SPSLOrderModel>> successAction, Action<ErrorEntity> errorAction)
- {
- var queryParams = new List<QueryCommonParam>()
- {
- new QueryCommonParam() { ParamKey = "accountid", ParamValue = accountId.ToString()},
- };
- QueryCommonHelper.QueryCommon(QueryStatement.ClientQuerySpslOrderdetail, queryParams, successAction, errorAction, "查询账户止盈止损单");
- }
- /// <summary>
- /// 查询资管内部委托单
- /// </summary>
- /// <param name="queryParams">The query parameters.</param>
- /// <param name="successAction">The success action.</param>
- /// <param name="errorAction">The error action.</param>
- public void QueryInnerHisOrderDetails(List<QueryCommonParam> queryParams, Action<List<Data.Model.Account.OrderDetail>> successAction, Action<ErrorEntity> errorAction)
- {
- QueryCommonHelper.QueryCommon(QueryStatement.ClientInforHisInnerOrderDetail, queryParams, successAction, errorAction, "查询资管内部委托单");
- }
- /// <summary>
- /// 查询资管内部成交单
- /// </summary>
- /// <param name="queryParams">The query parameters.</param>
- /// <param name="successAction">The success action.</param>
- /// <param name="errorAction">The error action.</param>
- public void QueryInnerHisTradeDetails(List<QueryCommonParam> queryParams, Action<List<CompleteOrder>> successAction, Action<ErrorEntity> errorAction)
- {
- QueryCommonHelper.QueryCommon(QueryStatement.ClientInforHisInnerTradeDetail, queryParams, successAction, errorAction, "查询资管内部成交单");
- }
- /// <summary>
- /// 查询资管内部平仓明细
- /// </summary>
- /// <param name="queryParams">The query parameters.</param>
- /// <param name="successAction">The success action.</param>
- /// <param name="errorAction">The error action.</param>
- /// <exception cref="System.NotImplementedException"></exception>
- public void QueryInnerHisCloseDetails(List<QueryCommonParam> queryParams, Action<List<Data.Model.Account.CloseDetail>> successAction, Action<ErrorEntity> errorAction)
- {
- QueryCommonHelper.QueryCommon(QueryStatement.ClientInforHisInnerCloseDetail, queryParams, successAction, errorAction, "查询资管内部平仓明细");
- }
- /// <summary>
- /// 查询资管内部持仓单
- /// </summary>
- /// <param name="queryParams">The query parameters.</param>
- /// <param name="successAction">The success action.</param>
- /// <param name="errorAction">The error action.</param>
- public void QueryInnerHisHoldDetails(List<QueryCommonParam> queryParams, Action<List<HoldDetail>> successAction, Action<ErrorEntity> errorAction)
- {
- QueryCommonHelper.QueryCommon(QueryStatement.ClientInforHisInnerHolderDetail, queryParams, successAction, errorAction, "查询资管内部持仓单");
- }
- /// <summary>
- /// 查询账户持仓汇总
- /// </summary>
- /// <param name="cycleType">Type of the cycle.</param>
- /// <param name="cycleTime">The cycle time.</param>
- /// <param name="successAction">The success action.</param>
- /// <param name="errorAction">The error action.</param>
- /// <exception cref="System.NotImplementedException"></exception>
- public void QueryTradePostion(ReckonReportQueryType cycleType, string cycleTime, Action<List<TradePosition>> successAction, Action<ErrorEntity> errorAction)
- {
- var statement = QueryStatement.ClientDayRetortTradePosition;
- var queryParams = new List<QueryCommonParam>()
- {
- new QueryCommonParam() { ParamKey = "accountId", ParamValue = UserManager.CurrentTradeAccount.FundsAccountId.ToString()},
- new QueryCommonParam() { ParamKey = "cycleTime", ParamValue = cycleTime },
- };
- if (cycleType != ReckonReportQueryType.DayReckon)
- {
- //周期报表
- statement = QueryStatement.ClientRetortTradePosition;
- queryParams.Add(new QueryCommonParam() { ParamKey = "cycleType", ParamValue = ((int)cycleType).ToString() });
- }
- QueryCommonHelper.QueryCommon(statement, queryParams, successAction, errorAction, "查询账户持仓汇总");
- }
- #endregion
- /// <summary>
- /// 查询账户汇率模板
- /// </summary>
- /// <param name="taAccountIdList">The ta account identifier list.</param>
- /// <param name="successAction">The success action.</param>
- /// <param name="errorAction">The error action.</param>
- public void QueryTradeRateTmpConfig(string taAccountIdList, Action<List<TradeRateTmpConfig>> successAction, Action<ErrorEntity> errorAction)
- {
- var statement = QueryStatement.ClientInforTradeRateTmpConfig;
- var queryParams = new List<QueryCommonParam>()
- {
- new QueryCommonParam() { ParamKey = "taAccountIdList", ParamValue = taAccountIdList},
- };
- QueryCommonHelper.QueryCommon(statement, queryParams, new Action<List<TradeRateTmpConfig>>((configs) =>
- {
- UserManager.TradeRateTmpConfigs = configs;
- if (successAction != null ) successAction(configs);
- }), errorAction, "查询账户汇率模板");
- }
- /// <summary>
- /// 查询外部汇率模版配置表
- /// </summary>
- /// <param name="taAccountIdList">The ta account identifier list.</param>
- /// <param name="tradeDate">交易日</param>
- /// <param name="successAction">The success action.</param>
- /// <param name="errorAction">The error action.</param>
- public void QueryExtenalTradeRateTmpConfig(string taAccountIdList, string tradeDate, Action<List<TradeRateTmpConfig>> successAction, Action<ErrorEntity> errorAction)
- {
- var statement = QueryStatement.ClientExtenalExchangeRate;
- var queryParams = new List<QueryCommonParam>()
- {
- new QueryCommonParam() { ParamKey = "taAccountIdList", ParamValue = taAccountIdList},
- new QueryCommonParam() { ParamKey = "tradeDate", ParamValue = tradeDate},
- };
- QueryCommonHelper.QueryCommon(statement, queryParams, new Action<List<TradeRateTmpConfig>>((configs) =>
- {
- UserManager.ExtenalTradeRateTmpConfigs = configs;
- if (successAction != null) successAction(configs);
- }), errorAction, "查询外部汇率模版配置表");
- }
- /// <summary>
- /// 查询资金账户汇率
- /// </summary>
- /// <param name="taAccountIdList">The ta account identifier list.</param>
- /// <param name="successAction">The success action.</param>
- /// <param name="errorAction">The error action.</param>
- public void QueryTaAccountExchangeRate(string taAccountIdList, Action<List<TradeRateTmpConfig>> successAction, Action<ErrorEntity> errorAction)
- {
- var statement = QueryStatement.TaAccountExchangeRate;
- var queryParams = new List<QueryCommonParam>()
- {
- new QueryCommonParam() { ParamKey = "taAccountIdList", ParamValue = taAccountIdList},
- };
- QueryCommonHelper.QueryCommon(statement, queryParams, new Action<List<TradeRateTmpConfig>>((configs) =>
- {
- UserManager.TaAccountExchangeRateConfigs = configs;
- if (successAction != null) successAction(configs);
- }), errorAction, "查询资金账户汇率");
- }
- /// <summary>
- /// 获取行情交易日
- /// </summary>
- /// <param name="successAction"></param>
- /// <param name="errorAction"></param>
- public void QuoteSourceGroupMarketDate(Action<List<QuoteSourceGroupMarketData>> successAction, Action<ErrorEntity> errorAction)
- {
- var statement = QueryStatement.QuoteSourceGroupMarketDate;
- var queryParams = new List<QueryCommonParam>()
- {
-
- };
- QueryCommonHelper.QueryCommon(statement, queryParams, new Action<List<QuoteSourceGroupMarketData>>((configs) =>
- {
- CacheManager.QuoteSourceGroupMarketDatas = configs;
- if (successAction != null) successAction(configs);
- }), errorAction, "获取行情交易日失败");
- }
- }
- }
|