Closed BlackWingedKing closed 3 years ago
The code which I ran (modified from ccxt-binance_ema_cross.py for coinbasepro, didn't attach the imports)
# The configuration dictionary can come from anywhere such as a JSON or YAML
# file. Here it is hardcoded into the example for clarity.
config = {
"trader": {
"name": "TESTER", # Not sent beyond system boundary
"id_tag": "001", # Used to ensure orders are unique for this trader
},
"system": {
"loop_debug": False, # The event loop debug mode
"connection_timeout": 5.0, # Timeout for successful connections for all engine clients
"disconnection_timeout": 5.0, # Timeout for successful disconnection for all engine clients
"check_residuals_delay": 5.0, # How long to wait after stopping for residual events (secs)
},
"logging": {
"level_stdout": "INF",
},
"exec_database": {
"type": "redis",
"host": "localhost",
"port": 6379,
},
"risk": {},
"strategy": {
"load_state": True, # Strategy state is loaded from the database on start
"save_state": True, # Strategy state is saved to the database on shutdown
},
"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_PASSWORD", # value is the environment variable key
"sandbox_mode": True, # If client uses the testnet
},
},
"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_PASSWORD", # value is the environment variable key
"sandbox_mode": True, # If client uses the testnet
},
},
}
# Instantiate your strategies to pass into the trading node. You could add
# custom options into the configuration file or even use another configuration
# file.
instrument_id = InstrumentId(
symbol=Symbol("ETH/USDT"),
venue=Venue("COINBASEPRO"),
)
strategy = EMACross(
instrument_id=instrument_id,
bar_spec=BarSpecification(1, BarAggregation.MINUTE, PriceType.LAST),
fast_ema_period=10,
slow_ema_period=20,
trade_size=Decimal("0.05"),
order_id_tag="001",
)
# Instantiate the node passing a list of strategies and configuration
node = TradingNode(strategies=[strategy], config=config)
# Register your client factories with the node (can take user defined factories)
node.add_data_client_factory("CCXT", CCXTDataClientFactory)
node.add_exec_client_factory("CCXT", CCXTExecutionClientFactory)
node.build()
# Stop and dispose of the node with SIGINT/CTRL+C
if __name__ == "__main__":
try:
node.start()
finally:
node.dispose()
I'll look into this tomorrow.
In the mean time I've added the capability to cache and persist Currency
objects so we shouldn't run into the issue again where a currency can't be de-serialized.
2021-05-06T12:28:13.344024Z [INF] TESTER-001.ExecCache: Cached 412 currencies from database.
2021-05-06T12:28:13.344489Z [INF] TESTER-001.ExecCache: Cached 1 account from database.
2021-05-06T12:28:13.344690Z [INF] TESTER-001.ExecCache: Cached 0 orders from database.
2021-05-06T12:28:13.344858Z [INF] TESTER-001.ExecCache: Cached 0 positions from database.
2021-05-06T12:28:13.344888Z [INF] TESTER-001.ExecCache: Checking data integrity...
Upon reviewing their docs, it appears that some exchanges do require a password
argument.
https://github.com/ccxt/ccxt/wiki/Manual#authentication
I've added the following into the config parsing
# Build internal configuration
cdef dict internal_config = {
"apiKey": os.getenv(config.get("api_key", ""), ""),
"secret": os.getenv(config.get("api_secret", ""), ""),
"password": os.getenv(config.get("api_password", ""), ""),
Which should sort the current authentication issue.
The change will make it to the develop
branch on my next push.
Thank you!
@cjdsellers I get this authentication error with
CCXT-COINBASEPRO
. Generated testnet keys from hereI think this is because the
COINBASEPRO
api requireskey
,secret
andpassword
. but in theCCXTDataClientFactory
we are only parsingapiKey
andsecret
in internalConfig. So, may be you could add a check for coinbasepro and get thepassword
in that caseccxt's coinbasepro.py which requires
password
fieldfull output