コード例 #1
0
ファイル: DealsInfo.cs プロジェクト: vseledkin/MLEA
 private void CalculateDealCloseTimeOnly(DealInfo i)
 {
     if (m_nowPrice.low == 0 || m_nowPrice.high == 0)
     {
         throw new AssertException("nowPrice low or high is not set.");
     }
     if (i.DealType == 'B')
     {
         if (m_nowPrice.low <= i.ClosePriceSl + spread)
         {
             float cost = (i.ClosePriceSl - i.OpenPrice - spread) * GetPointInv(m_nowPrice.close);
             i.CloseTime = m_nowTime;
             i.Cost      = -cost;
         }
         else if (m_nowPrice.high >= i.ClosePriceTp - spread)
         {
             float cost = (i.ClosePriceTp - i.OpenPrice - spread) * GetPointInv(m_nowPrice.close);
             i.CloseTime = m_nowTime;
             i.Cost      = -cost;
         }
         else
         {
         }
     }
     else
     {
         if (m_nowPrice.high + spread > i.ClosePriceSl)
         {
             float cost = ((i.OpenPrice - i.ClosePriceSl) - spread) * GetPointInv(m_nowPrice.close);
             i.CloseTime = m_nowTime;
             i.Cost      = -cost;
         }
         else if (m_nowPrice.low + spread < i.ClosePriceTp)
         {
             float cost = ((i.OpenPrice - i.ClosePriceTp) - spread) * GetPointInv(m_nowPrice.close);
             i.CloseTime = m_nowTime;
             i.Cost      = -cost;
         }
         else
         {
         }
     }
 }
コード例 #2
0
ファイル: DealsInfo.cs プロジェクト: wushian/MLEA
 public void AddDeal(DealInfo dealInfo)
 {
     m_deals.Add(dealInfo);
 }
コード例 #3
0
ファイル: DealsInfo.cs プロジェクト: vseledkin/MLEA
 public void AddDeal(DealInfo dealInfo)
 {
     m_deals.Add(dealInfo);
 }
コード例 #4
0
ファイル: DealsInfo.cs プロジェクト: wushian/MLEA
 private void CalculateDealCloseTimeOnly(DealInfo i)
 {
     if (m_nowPrice.low == 0 || m_nowPrice.high == 0)
     {
         throw new AssertException("nowPrice low or high is not set.");
     }
     if (i.DealType == 'B')
     {
         if (m_nowPrice.low <= i.ClosePriceSl + spread)
         {
             float cost = (i.ClosePriceSl - i.OpenPrice - spread) * GetPointInv(m_nowPrice.close);
             i.CloseTime = m_nowTime;
             i.Cost = -cost;
         }
         else if (m_nowPrice.high >= i.ClosePriceTp - spread)
         {
             float cost = (i.ClosePriceTp - i.OpenPrice - spread) * GetPointInv(m_nowPrice.close);
             i.CloseTime = m_nowTime;
             i.Cost = -cost;
         }
         else
         {
         }
     }
     else
     {
         if (m_nowPrice.high + spread > i.ClosePriceSl)
         {
             float cost = ((i.OpenPrice - i.ClosePriceSl) - spread) * GetPointInv(m_nowPrice.close);
             i.CloseTime = m_nowTime;
             i.Cost = -cost;
         }
         else if (m_nowPrice.low + spread < i.ClosePriceTp)
         {
             float cost = ((i.OpenPrice - i.ClosePriceTp) - spread) * GetPointInv(m_nowPrice.close);
             i.CloseTime = m_nowTime;
             i.Cost = -cost;
         }
         else
         {
         }
     }
 }