Exemplo n.º 1
0
        /// <summary>
        /// Simulates a given scenario and calculates profit / loss that would be made if scenario happened on each second in history of captured market order books.
        /// Profit/losses are output to a file given in scenario description.
        /// </summary>
        /// <param name="scenario">Scenario to simulate.</param>
        /// <param name="historyLoader">Loader to be used to access history of market order books.</param>
        public ProfitSimulator(SimulationScenario scenario, BitstampHistoryLoader historyLoader)
        {
            _historyEnumerator = new HistoryEnumerator(historyLoader);
            var firstEntry = _historyEnumerator.PeekNext();

            if (firstEntry == null)
            {
                return;
            }

            _engine = new SimulationEngine(firstEntry.AcqTime);
            _engine.AfterEventSimulation += LoadOrderBookHistoryEventsIntoEngine;


            _dependencyFactory = new SimulationDependencyFactory(_engine);

            _scenario = scenario;
            _dependencyFactory.HedgingEngine.WhenStrategy.Delay         = _scenario.HedgingDelay * 1000;
            _dependencyFactory.PricingEngine.PricingStrategy.SellSpread = _scenario.SellSpread / 100;
            _dependencyFactory.PricingEngine.PricingStrategy.BuySpread  = _scenario.BuySpread / 100;
            _dependencyFactory.SolarisBank.InfiniteBalance = true;
            _dependencyFactory.SolarisBank.TransferDelay   = 10;

            _resultWriter = new CsvProfitSimulationWriter(_scenario.OutputFilename);
            _resultWriter.Initialize();

            _isSimulationDone = false;

            _liquidityEngine = new SimulationLiquidityEngineMoq(_dependencyFactory);
        }
Exemplo n.º 2
0
        public MarketAnalyzer(BitstampHistoryLoader historyLoader)
        {
            MinTimespan = TimeSpan.FromMinutes(1);

            _bidStat = new Lazy <Statistic>(() => new Statistic(_priceHistory.Select(entry => entry.BidPrice)));
            _askStat = new Lazy <Statistic>(() => new Statistic(_priceHistory.Select(entry => entry.AskPrice)));

            _priceHistory = new LinkedList <Entry>();
            _history      = new HistoryQueue(historyLoader);
        }
 /// <summary>
 /// Iterates over order book history and loads new data using given history loader when needed.
 /// </summary>
 /// <param name="loader">Order book history loader which is then used to load historical data.</param>
 public HistoryEnumerator(BitstampHistoryLoader loader)
 {
     _loader = loader;
     _loader.RegisterHistoryProvider(this);
 }
Exemplo n.º 4
0
 public HistoryQueue(BitstampHistoryLoader loader)
 {
     _loader = loader;
     _loader.RegisterHistoryProvider(this);
 }