def main(): arg_parser = data_faker_args() args = arg_parser.parse_args() faker = DataFaker(args) rest_api = RestAPI(faker.fake_kraken) server = APIServer(rest_api) print('SERVER IS NOW RUNNING') # For some reason debug=True throws an exception: # ModuleNotFoundError: No module named 'data_faker # server.run(debug=True) server.run() print('SERVER IS NOW SHUTTING DOWN')
def __init__(self, args: argparse.Namespace) -> None: args.logfile = 'data_faker.log' self.rotki = Rotkehlchen(args) random_seed = datetime.datetime.now() logger.info(f'Random seed used: {random_seed}') random.seed(random_seed) self.create_new_user(args.user_name, args.user_password) # Start the fake exchanges API for the duration of the fake # history creation. We need it up so that we can emulate responses # from the exchanges self.fake_kraken = FakeKraken() self.fake_binance = FakeBinance() mock_api = RestAPI(fake_kraken=self.fake_kraken, fake_binance=self.fake_binance) self.mock_server = APIServer(rest_api=mock_api) self.mock_server.start() self.rotki.setup_exchange( name='kraken', location=Location.KRAKEN, api_key=ApiKey(str(make_random_b64bytes(128))), api_secret=ApiSecret(make_random_b64bytes(128)), ) self.rotki.setup_exchange( name='binance', location=Location.BINANCE, api_key=ApiKey(str(make_random_b64bytes(128))), api_secret=ApiSecret(make_random_b64bytes(128)), ) self.writer = ActionWriter( trades_number=args.trades_number, seconds_between_trades=args.seconds_between_trades, seconds_between_balance_save=args.seconds_between_balance_save, rotkehlchen=self.rotki, fake_kraken=self.fake_kraken, fake_binance=self.fake_binance, ) self.writer.generate_history() # stop the fake exchange API. Will be started again once we are finished, # ready to serve the Rotkehlchen client self.mock_server.stop()
def main() -> None: arg_parser = data_faker_args() args = arg_parser.parse_args() if args.command == 'mockall': faker = DataFaker(args) rest_api = RestAPI( fake_kraken=faker.fake_kraken, fake_binance=faker.fake_binance, ) server = APIServer(rest_api) print('SERVER IS NOW RUNNING') # For some reason debug=True throws an exception: # ModuleNotFoundError: No module named 'data_faker # server.run(debug=True) server.run() print('SERVER IS NOW SHUTTING DOWN') elif args.command == 'statistics': stats_faker = StatisticsFaker(args) stats_faker.create_fake_data(args) else: raise AssertionError( f'Should not happen. Unexpected command {args.command} given')