87 lines
2.9 KiB
C#
87 lines
2.9 KiB
C#
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
using System;
|
|
using System.Linq;
|
|
using YLErp.Abstract.DataProviders;
|
|
using YLErp.BLL.Eod;
|
|
using YLErp.BLL.EodSettlement;
|
|
using YLErp.DBModels;
|
|
using YLErp.Models;
|
|
using YLErp.Modules.EodModule.SettlementModule;
|
|
using YLErp.Modules.TradeModule;
|
|
using YLErp.QdpModule;
|
|
|
|
namespace YLErp.Modules.EodModule
|
|
{
|
|
[TestClass]
|
|
public class EodSettlementServiceTest : YLUnitTestBase
|
|
{
|
|
[TestMethod("TestGetEodTradePosition")]
|
|
public void TestGetEodTradePosition()
|
|
{
|
|
var datas = new EodSettlementService(this).GetEodTradePosition<eod_trade_position_hedgevol>(new DateTime(2020, 8, 20));
|
|
|
|
Console.WriteLine(datas.Count());
|
|
}
|
|
|
|
[TestMethod("测试收盘任务")]
|
|
public void TestEodTask()
|
|
{
|
|
DbContext.Database.ExecuteSqlCommand("UPDATE eod_task set TaskState=101 where TaskState<100;");
|
|
|
|
var eodTask = new EodTaskSaveService(UserInfo).SaveData(new EodTaskSaveReq
|
|
{
|
|
StartDate = new DateTime(2020, 11, 23),
|
|
//EndDate = new DateTime(2020, 11, 23),
|
|
EndDate = new DateTime(2020, 11, 23),
|
|
PriceType = EodSettlePriceType.ClosePrice,
|
|
VolTypes = "持仓", //"对冲", "持仓", "开仓"
|
|
PartFlag = "场外", // 全部,场内
|
|
}, false);
|
|
|
|
EodTaskRunner.Execute();
|
|
|
|
var db = DbContextFactory.GetYLDbContext();
|
|
|
|
var eodTask2 = db.EodTask.Find(eodTask.id);
|
|
|
|
Console.WriteLine(eodTask2.TaskResult);
|
|
|
|
Assert.IsTrue(eodTask2.TaskState == EodTaskState.completed);
|
|
}
|
|
|
|
[TestMethod("测试凤凰票息")]
|
|
public void TestAutoCall()
|
|
{
|
|
new TradeAutocallBLL(OptUser).CheckStatus(new DateTime(2021, 03, 22), new AutocallPriceProvider(), new DateTime(2020, 03, 22), null);
|
|
}
|
|
|
|
class AutocallPriceProvider : IEodPriceProvider
|
|
{
|
|
public bool TryGetEodPrice(int underlyingId, out EodPrice eodPrice)
|
|
{
|
|
eodPrice = null;
|
|
return false;
|
|
}
|
|
|
|
public bool TryGetEodPrice(string underlyingCode, out EodPrice eodPrice)
|
|
{
|
|
using (var db = DbContextFactory.GetYLDbContext())
|
|
{
|
|
eodPrice = db.eod_stock_price.Where(n => n.UnderlyingCode == underlyingCode).Select(n => new EodPrice
|
|
{
|
|
ClosePrice = n.ClosePrice,
|
|
HighPrice = n.HighPrice,
|
|
IsStock = true,
|
|
LowPrice = n.LowPrice,
|
|
SettlePrice = n.ClosePrice,
|
|
UnderlyingCode = n.UnderlyingCode,
|
|
ValueDate = n.ValueDate
|
|
}).FirstOrDefault();
|
|
|
|
return eodPrice != null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|