Skip to content
All library documents

Automating Hourly Crypto Bars and Starting a Trading Strategy

Code Quant course library

Summary

This application example connects a trading engine to a crypto exchange, loads a channel-based CTA strategy, and starts it. Separately, it requests recent hourly bars for a symbol through a market-data endpoint, converts the response to a tabular format, adjusts timestamps, sorts the records, and publishes completed data through an event engine. A background scheduler triggers hourly retrieval, with an initial request made at startup.

The retrieval routine retries requests, checks rate-limit headers, and pauses between attempts or when limits are low. It also compares the latest bar timestamps with the current time and may discard the newest bar when it appears incomplete. These details illustrate data collection and event-driven strategy wiring, not a validated trading method. The example gives no backtest or evidence of returns, and its timestamp assumptions, error handling, retry behavior, and data completeness need evaluation before reuse. It does not explain how collected bars are reconciled with live exchange data.

Key ideas

  • The example starts an exchange gateway, registers logging, and launches a CTA strategy.
  • It retrieves hourly bars and publishes the resulting data through an event engine.
  • A background scheduler requests data each hour, with an additional request at startup.
  • Rate-limit headers and retry delays influence how failed or constrained requests are handled.
  • The code attempts to exclude a potentially incomplete latest bar but offers no validation results.

Tags

From a private course collection; the original is not published.