예제 #1
0
    def test_catalog_generic_data_not_overwritten(self):
        # Arrange
        TestPersistenceStubs.setup_news_event_persistence()
        process_files(
            glob_path=f"{TEST_DATA_DIR}/news_events.csv",
            reader=CSVReader(block_parser=TestPersistenceStubs.news_event_parser),
            catalog=self.catalog,
        )
        objs = self.catalog.generic_data(
            cls=NewsEventData, filter_expr=ds.field("currency") == "USD", as_nautilus=True
        )

        # Clear the catalog again
        data_catalog_setup()
        self.catalog = DataCatalog.from_env()

        assert (
            len(self.catalog.generic_data(NewsEventData, raise_on_empty=False, as_nautilus=True))
            == 0
        )

        chunk1, chunk2 = objs[:10], objs[5:15]

        # Act, Assert
        write_objects(catalog=self.catalog, chunk=chunk1)
        assert len(self.catalog.generic_data(NewsEventData)) == 10

        write_objects(catalog=self.catalog, chunk=chunk2)
        assert len(self.catalog.generic_data(NewsEventData)) == 15
 def setup(self):
     data_catalog_setup()
     dask.config.set(scheduler="single-threaded")
     aud_usd_data_loader()
     self.catalog = DataCatalog.from_env()
     self.backtest_config = BacktestRunConfig(
         engine=BacktestEngineConfig(),
         venues=[
             BacktestVenueConfig(
                 name="SIM",
                 oms_type="HEDGING",
                 account_type="MARGIN",
                 base_currency="USD",
                 starting_balances=["1000000 USD"],
                 # fill_model=fill_model,  # TODO(cs): Implement next iteration
             )
         ],
         data=[
             BacktestDataConfig(
                 catalog_path="/root",
                 catalog_fs_protocol="memory",
                 data_cls=QuoteTick,
                 instrument_id="AUD/USD.SIM",
                 start_time=1580398089820000000,
                 end_time=1580504394501000000,
             )
         ],
     )
 def setup(self):
     dask.config.set(scheduler="single-threaded")
     data_catalog_setup()
     self.catalog = DataCatalog.from_env()
     self.venue_config = BacktestVenueConfig(
         name="SIM",
         oms_type="HEDGING",
         account_type="MARGIN",
         base_currency="USD",
         starting_balances=["1000000 USD"],
         # fill_model=fill_model,  # TODO(cs): Implement next iteration
     )
     self.data_config = BacktestDataConfig(
         catalog_path="/root",
         catalog_fs_protocol="memory",
         data_cls=QuoteTick,
         instrument_id="AUD/USD.SIM",
         start_time=1580398089820000000,
         end_time=1580504394501000000,
     )
     self.backtest_configs = [
         BacktestRunConfig(
             engine=BacktestEngineConfig(),
             venues=[self.venue_config],
             data=[self.data_config],
         )
     ]
     self.strategies = [
         ImportableStrategyConfig(
             path="nautilus_trader.examples.strategies.ema_cross:EMACross",
             config=EMACrossConfig(
                 instrument_id="AUD/USD.SIM",
                 bar_type="AUD/USD.SIM-100-TICK-MID-INTERNAL",
                 fast_ema_period=10,
                 slow_ema_period=20,
                 trade_size=Decimal(1_000_000),
                 order_id_tag="001",
             ),
         )
     ]
예제 #4
0
    def setup(self):
        # Fixture Setup
        data_catalog_setup()

        config = BacktestEngineConfig(
            bypass_logging=True,
            run_analysis=False,
        )
        self.engine = BacktestEngine(config=config)

        self.venue = Venue("BETFAIR")

        data = BetfairDataProvider.betfair_feed_parsed(
            market_id="1.166811431.bz2", folder="data/betfair")
        instruments = [d for d in data if isinstance(d, BettingInstrument)]

        for instrument in instruments[:1]:
            trade_ticks = [
                d for d in data if isinstance(d, TradeTick)
                and d.instrument_id == instrument.id
            ]
            order_book_deltas = [
                d for d in data if isinstance(d, OrderBookData)
                and d.instrument_id == instrument.id
            ]
            self.engine.add_instrument(instrument)
            self.engine.add_ticks(trade_ticks)
            self.engine.add_order_book_data(order_book_deltas)
            self.instrument = instrument
        self.engine.add_venue(
            venue=self.venue,
            account_type=AccountType.MARGIN,
            base_currency=None,
            oms_type=OMSType.NETTING,
            starting_balances=[Money(10_000, GBP)],
            book_type=BookType.L2_MBP,
        )
 def setup(self):
     data_catalog_setup()
     self.catalog = DataCatalog.from_env()
     self.fs: fsspec.AbstractFileSystem = self.catalog.fs
     self._loaded_data_into_catalog()
 def setup(self):
     data_catalog_setup()
     self.catalog = DataCatalog.from_env()
     self.fs = self.catalog.fs
     self.reader = BetfairTestStubs.betfair_reader()
 def setup(self):
     data_catalog_setup()
     self.catalog = DataCatalog.from_env()
     self.reader = MockReader()
     self.line_preprocessor = TestLineProcessor()
예제 #8
0
 def setup(self):
     data_catalog_setup()
     self.catalog = DataCatalog.from_env()
     self.fs = self.catalog.fs
     self._loaded_data_into_catalog()
예제 #9
0
 def setup(self):
     data_catalog_setup()
     self.catalog = DataCatalog.from_env()
     self.fs = self.catalog.fs
     self.reader = MockReader()