nautechsystems / nautilus_trader

A high-performance algorithmic trading platform and event-driven backtester
https://nautilustrader.io
GNU Lesser General Public License v3.0
2.07k stars 469 forks source link

ccxt-coinbasepro example? #300

Closed BlackWingedKing closed 3 years ago

BlackWingedKing commented 3 years ago

Hello, @cjdsellers

Thank you for this wonderful package. I would like to test live trading on coinbasepro (sandbox). I was wondering if you have an example for this.

I have made the following modifications to the ccxt_binance_ema_cross example file

I have changed the config to

    "data_clients": {
        "CCXT-COINBASEPRO": {
            "account_id": "CB_ACCOUNT_ID",  # value is the environment variable key
            "api_key": "CB_API_KEY",  # value is the environment variable key
            "api_secret": "CB_API_SECRET",  # value is the environment variable key
            "api_password": "CB_API_PASSPHRASE"
        },
    },
    "exec_clients": {
        "CCXT-COINBASEPRO": {
            "account_id": "CB_ACCOUNT_ID",  # value is the environment variable key
            "api_key": "CB_API_KEY",  # value is the environment variable key
            "api_secret": "CB_API_SECRET",  # value is the environment variable key
            "api_password": "CB_API_PASSPHRASE", 
            "sandbox_mode": True,  # If clients use the testnet
        },
    },

I'm not sure if the password is parsed from this config object (I just added a field as coinbase requires passphrase too)

and on running this I get the following error

RuntimeError: CCXT `watch_ohlcv` not available for Coinbase Pro

how should the config object look like for coinbasepro?

Thank you.

cjdsellers commented 3 years ago

That runtime error is raised in the CCXTDataClientFactory if the method is not available.

I've now moved those checks and exceptions into the method calls themselves for that data type. So for example if you wanted to subscribe to the order book or trade ticks then it won't matter if watch_ohlcv is not available.

Even if that method is not available, the platform is capable of aggregating bars itself from quote or trade ticks. In this case ensure internal_aggregation=True in your BarType (which is the default value for that arg).

I also had to fix some things after a major refactoring yesterday.

So the latest develop branch should work with CCXT-COINBASEPRO now.