Beispiel #1
0
        public void AggPnL_Equation()
        {
            FXMarketHistory fxmh = MarketTestTools.CreateMktHistory(true, true);
            SortedList <DateTime, Transaction> txL = AllocationsTools.GetTransactionList();
            AggregatedPnL pnl = new AggregatedPnL(Currency.USD);

            pnl.AddTransactions(txL, fxmh);
            PnLElement elmt = pnl.ToTable(fxmh)["Total"];

            Assert.IsTrue(elmt.Position - elmt.Deposit + elmt.Withdrawal == elmt.TotalPnLWithFees);
        }
Beispiel #2
0
        public void AggPnL_AddTransaction()
        {
            FXMarketHistory fxmh = MarketTestTools.CreateMktHistory(true, true);
            SortedList <DateTime, Transaction> txL = AllocationsTools.GetTransactionList();
            AggregatedPnL pnl = new AggregatedPnL(Currency.USD);

            pnl.AddTransactions(txL, fxmh);
            Dictionary <string, PnLElement> table = pnl.ToTable(fxmh);

            TestTools <PnLElement> .DictionaryTest(pnlref, table);
        }
Beispiel #3
0
        public void AggPnL_EquationXCCY()
        {
            FXMarketHistory fxmh = MarketTestTools.CreateMktHistory(true, true);

            fxmh.ConstructQuotes(new CurrencyPair(Currency.EUR, Currency.USD));
            SortedList <DateTime, Transaction> txL = AllocationsTools.GetTransactionList();
            AggregatedPnL pnl = new AggregatedPnL(Currency.EUR);

            pnl.AddTransactions(txL, fxmh);
            PnLElement elmt = pnl.ToTable(fxmh)["Total"];

            Assert.IsTrue(Math.Abs(elmt.Position - elmt.Deposit + elmt.Withdrawal - elmt.TotalPnLWithFees) < 0.00001);
        }
        public TimeSeriesManager(Currency fiat, Frequency freq = Frequency.Hour4,
                                 bool useKraken = false, bool useInternet = true,
                                 string path    = null, IView view        = null)
        {
            if (view != null)
            {
                AddLoggingLink(view.PublishLogMessage);
            }
            Fiat = fiat;
            if (path != null)
            {
                BasePath = path;
            }
            DataProvider = new DataProvider(BasePath, view, useInternet: useInternet);
            SortedList <DateTime, Transaction> txList = DataProvider.GetTransactionList(useKraken: useKraken);

            StartDate = txList.First().Key;
            FXMH      = DataProvider.GetFXMarketHistory(Fiat, DataProvider.GetCurrencyPairs(txList), StartDate, freq);
            AH        = new AllocationHistory(view);
            APnL      = new AggregatedPnL(fiat);
            APnL.AddTransactions(txList, FXMH);
        }
        public void Update(Currency fiat, Frequency freq, List <ITimeSeriesKey> tskl, bool useLowerFrequencies)
        {
            TimeSeriesKeyList = tskl;
            DataProvider.LoadPrices(TimeSeriesKeyList, useLowerFrequencies: useLowerFrequencies);
            Fiat = fiat;
            if (FXMH.Freq != freq || ChangeLedger)
            {
                SetUpAllHistory(freq);
            }
            DataProvider.UpdateFXMarketHistory(FXMH, Fiat, StartDate, freq);
            APnL.ChangeCcyRef(fiat, FXMH);
            bool ReloadAllocationHistory = tskl.Where(x => x.GetKeyType() == TimeSeriesKeyType.AllocationHistory).Count() > 0;

            if (ChangeLedger || ReloadAllocationHistory)
            {
                ChangeLedger = false;
                APnL.AddTransactions(DataProvider.GetTransactionList(), FXMH, fullReload: true);
            }
            if (ReloadAllocationHistory)
            {
                AH.AddTransactions(fiat, DataProvider.GetTransactionList(), FXMH);
                AH.UpdateHistory(fiat, FXMH);
            }
        }