Maintained

Basana guide

Basana modernizes the PyAlgoTrade design with asyncio and a cleaner event model.

Last reviewed

Quick answer

Basana is an asyncio-based, event-driven Python framework for algorithmic trading, focused on crypto. It supports backtesting with a simulated exchange and live trading on Binance and Bitstamp. Its author, Gabriel Becedillas, also wrote PyAlgoTrade, which points users to Basana after being archived.

Basana at a glance

Category
Backtest + live trading engines
Language
Python
License
Apache-2.0
Does
Backtesting, Live trading
Markets
Crypto
Best for
Crypto traders who liked PyAlgoTrade and want an async, maintained replacement.
In AlgoGP
Use the exported strategy object from your own code

Pick it if

Crypto traders who liked PyAlgoTrade and want an async, maintained replacement.

Watch out for

Few exchanges (Binance, Bitstamp).

Basana strengths and limitations

Strengths

  • Async event-driven design.
  • Same strategy for backtest and live.
  • Small, readable codebase.

Limitations

  • Few exchanges (Binance, Bitstamp).
  • Smaller community than Freqtrade or Hummingbot.

Basana example

pip install basana
Install
import asyncio
import basana as bs
import basana.backtesting.exchange as backtesting_exchange

async def main():
    event_dispatcher = bs.backtesting_dispatcher()
    exchange = backtesting_exchange.Exchange(event_dispatcher, initial_balances={"USDT": 1000})
    # add bars from CSV, subscribe a strategy to bar events, then:
    await event_dispatcher.run()

asyncio.run(main())
Backtest skeleton (see the Basana docs for full examples).

Use Basana with AlgoGP

AlgoGP does not add Basana to projects automatically yet, but nothing stops you using them together. Every AlgoGP project exports plain Python with a framework-neutral strategy object, so you can call it from Basana yourself.

  1. 1

    Design and backtest in AlgoGP

    Describe the idea to the copilot and backtest it on AlgoGP’s normalized history.

  2. 2

    Add any bridge to get the adapter core

    Adding a bridged framework (for example Backtrader) writes frameworks/algogp_bridge.py, whose StrategyBridge.on_bar() returns the orders the strategy wants.

  3. 3

    Call it from Basana

    Feed Basana’s bars to StrategyBridge, place the returned orders with Basana, and report fills back with sync().

Basana connects to Binance, Bitstamp. Each guide shows how to create the API key, which you can store in the project’s Keys & secrets.

Basana: frequently asked questions

Is Basana the successor to PyAlgoTrade?

PyAlgoTrade’s repository recommends Basana; both come from the same author.

Basana alternatives

Independent guide. AlgoGP is not affiliated with Basana. Features, licenses and maintenance change; check the official documentation. Nothing here is investment advice.

Build a strategy