Skip to content
All library documents

Python Modules, Imports, and a Simple Crypto Market-Making Strategy

PDF Quant course library

Summary

This introduction explains Python modules as reusable files, distinguishes modules from packages and libraries, and shows how to import whole modules, selected names, or aliases. It also covers installing third-party packages and using the main-module guard to prevent example code from running on import. These practices help organize reusable strategy components and separate testing or demonstration code from an execution entry point.

The trading example sketches a maker-style limit order for a crypto pair. It calculates a quote from the first and fifth bid levels, places an order when none is open, and cancels and replaces it if its price leaves that range. It also tracks order and asset updates. The example illustrates basic organization and order handling, but gives no performance evidence, risk controls, or robust treatment of exchange errors and changing market conditions.

Key ideas

  • Python modules group reusable functions, classes, variables, and executable statements.
  • Imports can expose an entire module, selected names, or a shorter alias.
  • A main-module guard keeps demonstration or startup code from running during import.
  • The example quotes between two bid levels and replaces orders that move outside the range.
  • Order and asset update handlers can support basic state tracking.

Tags

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