Exemplo n.º 1
0
def main():
    trading_pair = TradingPair(USD, BTC)
    action = DynamicOrders(trading_pair)
    exchange = CCXTExchange('bitmex', observation_pairs=[trading_pair],
                            timeframe='1m')
    wallet = Wallet(exchange, .01 * BTC)
    portfolio = Portfolio(USD, wallets=[wallet])
    env = TradingEnvironment(portfolio, exchange, action, 'simple')
    while True:
        env.step(0)
        env.render('human')
        time.sleep(.02)
Exemplo n.º 2
0
def main():
    df = load_dataframe()

    exchange = SimulatedExchange(df)
    wallet_usd = Wallet(exchange, 0 * USD)
    wallet_btc = Wallet(exchange, .01 * BTC)
    portfolio = Portfolio(BTC, wallets=[wallet_usd, wallet_btc])
    trading_pair = TradingPair(USD, BTC)
    action = DynamicOrders(trading_pair)
    env = TradingEnvironment(portfolio, exchange, action, 'simple',
                             window_size=20)

    times = []
    for _ in range(300):
        action = 0
        if random.random() > .9:
            action = int(random.uniform(1, 20))
        env.step(action)
        t1 = time.time()
        env.render('human')
        times.append(time.time() - t1)
        if len(times) > 120:
            times.pop(0)
        print(f'FPS: {1 / np.mean(times):.1f}', end='\r')