def __init__(self, verbose=False):
        self._valuation_time_series = []
        self._verbose = verbose

        # Create temporary directory.
        self.temp_directory = os.path.join(
            Constants.db_path, generate_unique_id(Constants.run_time))
        os.mkdir(self.temp_directory)

        # Create and initiate temporary ATP database. (Could have the option to use current ATP db)
        schema = Constants.configs['tables'][Constants.DB_NAME]
        self.db = initiate_database(self.temp_directory, Constants.APP_NAME,
                                    schema, Constants.environment)

        # Create and initiate temporary market data database. (Probably should copy current market data db)
        schema = Constants.configs['tables'][MarketDataLoader.DB_NAME]
        self.market_data_db = initiate_database(self.temp_directory,
                                                MarketDataLoader.DB_NAME,
                                                schema, Constants.environment)

        self.strategy = None
        self.executor = None
        self.exchange_cash = 300000
        self.run_calendar = [Constants.run_time]
        self.run_days = 0
Ejemplo n.º 2
0
def add_assets(db, portfolio_id, symbol, units=0):
    asset_id = generate_unique_id(symbol)
    db.insert_row('assets', [asset_id, portfolio_id, symbol, units, 0.0])
Ejemplo n.º 3
0
def add_data_source(db, name, config):
    data_source_id = generate_unique_id(name)
    db.insert_row('data_sources', [data_source_id, name, config])
Ejemplo n.º 4
0
def add_portfolio(db, name, allocation, cash=0.0):
    portfolio_id = generate_unique_id(name)
    db.insert_row('portfolios', [portfolio_id, 'alpaca', cash, allocation])
    return portfolio_id
Ejemplo n.º 5
0
def add_strategy(db, name, porfolio_id):
    strategy_id = generate_unique_id(name)
    values = [strategy_id, name.lower(), porfolio_id, None]
    db.insert_row('strategies', values)
    return strategy_id