Skip to main content

This client is a wrapper for the official Zorro API

Project description

Zorro Client

zorro-client is a library written for use with Zorro, an algorithmic trading platform. This library includes a full API client with access to user-written indicators and strategies. In addition, it includes the backtesting framework and scripting language used by Zorro, so you can test out your strategies on your own data as well.

Install

$ pip3 install zorro-client

Example

import zorro

theAPI = zorro.Api(
    api_key="your-api-key",
    secret_key="your-secret-key")

my_indicator = theAPI.indicators['indicator-id']
my_strategy = theAPI.strategies['strategy-id']

stock_data = zorro.StockData.create(
	["AAPL",  "AMZN"],
	"2020-01-03",
	"2020-07-11",
	"1d")

# backtest the strategy
backtest = my_strategy.create_backtest(stock_data)
backtest.simulate()

# find important details
backtest_results = backtest.analyze()
sharpe_ratio = backtest_results['sharpe_ratio']
alpha = backtest_results['alpha']
beta = backtest_results['beta']
profit_pct = backtest_results['profit_percent']
profit = backtest_results['profit']
trade_history = backtest.trade_history

print(backtest_results)

Usage

Import

import zorro

Create a strategy

my_strategy = zorro.Strategy(
	{
		"type": "order",
		"stock": "AAPL",
		"qty": "10"
	}
)

Execute the strategy on a paper API

No setup required.

paper_broker = zorro.PaperBroker()
my_strategy.execute(handler=paper_broker)

Execute the strategy on a live API

To do this, you will need an Alpaca account. You can create one here.

live_broker = zorro.LiveBroker(
	alpaca_api_key_id="<Your API key>",
	alpaca_api_secret="<Your API secret")

my_strategy.execute(handler=live_broker)

Thank you for using Zorro!

If you have any questions, reach out to us at our email.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

zorroclient-0.0.1a0-py3-none-any.whl (8.7 kB view hashes)

Uploaded Python 3

Supported by

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