Skip to main content

No project description provided

Project description

Cornell Quant Fund Backtester (cqfbt)

Engine

An Engine is the main component in our backtester. It accepts strategies and simulates them on the price data it is initialized with, and can output a variety of metrics on their performance.

The Engine is initialized with a start date and end date to pull data for, as well as the periodicity of the data. Price data is pulled from Yahoo Finance via the yfinance package. Optionally, the Engine can also be initialized with a list of Yahoo Finance tickers to load price data for.

A feature of the Engine is the ability to set transaction costs. These must be set via the Engine.set_transaction_costs method, which takes either a float representing a uniform transaction cost or a list of floats for each portfolio asset.

The Engine also contains methods that compare portfolio returns to a market benchmark. This market benchmark is set to the SPX, DJI, or NDAQ ticker, depending on which one is included in the list of tickers to load price data for during initialization. If more than one benchmark ticker appears in the ticker list, the market benchmark is set to the benchmark ticker that appears last in the ticker list. If no benchmark ticker is included in the ticker list, the default is the SPY ticker.

Strategy

A Strategy is an abstract class that requires the user of the backtester to implment the method 'execute()'. This function can access memory, and use incoming data to decide which orders the engine should to attempt to close.

A Strategy should inherit the strategy interface defined in the strategy module, and define its 'execute()' function. The execute function should return a list of orders to the engine, which the engine will attempt to execute. An 'InsufficientFundsException' may arise if there is insufficient capital to complete a transaction. In this case, the order list will be cleared, and the 'error' parameter will be set to true, while the same data is passed to 'execute()'. If this error is not addressed, the engine will crash.

Order

An Order is an object that represents an order submitted to the engine. An order has a boolean value representing buy as True and sell as False, an asset number, a quantity, and optionally, a limit price.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cqfbt-1.0.1.tar.gz (13.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cqfbt-1.0.1-py3-none-any.whl (13.6 kB view details)

Uploaded Python 3

File details

Details for the file cqfbt-1.0.1.tar.gz.

File metadata

  • Download URL: cqfbt-1.0.1.tar.gz
  • Upload date:
  • Size: 13.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for cqfbt-1.0.1.tar.gz
Algorithm Hash digest
SHA256 75b1edf1a4fc29063836c5f3048d2117cc6eb50d78ce414a977b018001d8d73d
MD5 310556a8c98b2fbdf90624111a35dc62
BLAKE2b-256 8770ee0549e147dbb70a7cf6757dae744b46a20232e6690847faba64e6a1ce43

See more details on using hashes here.

File details

Details for the file cqfbt-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: cqfbt-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 13.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for cqfbt-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 05852bea1b734eda7f6174ef3f635ee2550c8871ca7471014ef468474c5ac1a6
MD5 3bf4259c726ef659fef6037a696c3520
BLAKE2b-256 2e97945d930bd0cc78869d6aebef14de36d1c0d92202434acf0a966cbff15fc2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page