Ejemplo n.º 1
0
        public void CurPair_Comparisons()
        {
            CurrencyPair cpRef = new CurrencyPair(Currency.USD, Currency.LTC);
            CurrencyPair cp1   = new CurrencyPair(Currency.XBT, Currency.BCH);
            CurrencyPair cp2   = new CurrencyPair(Currency.LTC, Currency.USD);

            Assert.IsTrue(!cpRef.IsEquivalent(cp1) && cpRef.IsEquivalent(cp2));
        }
Ejemplo n.º 2
0
 private bool ContainsCcyPair(CurrencyPair ccyPair)
 {
     foreach (CurrencyPair item in CpList)
     {
         if (ccyPair.IsEquivalent(item))
         {
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 3
0
        public static List <OpenOrder> SortOpenOrders(this List <OpenOrder> list,
                                                      Dictionary <string, PnLElement> pnlInfo,
                                                      CurrencyPair cp)
        {
            Currency   cryptoCcy = cp.GetCryptoFiatPair.Crypto;
            PnLElement pnl       = pnlInfo[cryptoCcy.ToFullName()];

            List <OpenOrder> res = new List <OpenOrder> {
            };

            foreach (OpenOrder item in list)
            {
                if (cp.IsEquivalent(item.CurPair))
                {
                    res.Add(item);
                }
            }
            res.Sort((x, y) => Math.Abs(x.Return).CompareTo(Math.Abs(y.Return)));

            OpenOrder lastBuy  = null;
            OpenOrder lastSell = null;

            foreach (var item in res)
            {
                if (item.Return > 0)
                {
                    item.SetPnLAndCost(pnl, lastSell);
                    lastSell = item;
                }
                else
                {
                    item.SetPnLAndCost(pnl, lastBuy);
                    lastBuy = item;
                }
            }
            return(res);
        }