Launching Our API to Build an Investment Track Record on Chain

Create immutable auditable track records using python

Silvervadim
Covey
4 min readAug 24, 2023

--

TL;DR

Use our Covey Python SDK to post trades on chain, while we track and rank your performance on our website: covey.io.

Introduction

On the journey to break into the field of managing money for clients, a reputable track record is not just priceless, but the only aspect that truly matters. Finance is changing, and long gone are the days of paying thousands of dollars for accountants to audit your track record, all the while having it reside in a PDF that still does not guarantee trust.

Strength, in any individual, rarely compares in efficacy to that of a sizeable community. Covey seeks to focus on the latter, by finding and rewarding the best investment analysts for anyone to co-trade with, through our online trading community.

Analysts use Covey Training Club to build a track record so that they can test a new strategy, further their career, or launch a fund. In real time we track 50 metrics and rank analysts on our open leaderboard. Analysts build mock portfolios by posting their trade ideas on chain through our website. Analysts with a more developed quantitative background have requested a way to post on the (polygon) chain without having to log in to our website.

Today, we are launching a python SDK that allows anyone with a crypto wallet to post ideas directly on chain, building an immutable track record for pennies. All we need is a string of trade data (i.e. AAPL:.25) posted on chain and Covey.io does all the portfolio math and ranks you amongst thousands of analysts.

To achieve full use of the SDK, there is a pricing component that needs to occur to in order to calculate the portfolio. The SDK connects to the free Alpaca API for pricing equities and crypto. This calculation is necessary if you are trying to read the latest positions and their respective market values.

Get Started

  1. Create an account on covey.io and connect MetaMask wallet with the private / public key pair of your choice.
  2. Download the C++ Build Tools (in case not already on your machine — frequently seen with Windows Users) available here.
  3. Create a project folder, /coveyon your machine.
  4. Using the terminal of your choice, create a virtual python environment within covey.
  5. Activate the virtual environment.

windows source env/Scripts/Activate

mac source env/bin/activate

Once the environment is activated, the terminal should have the environment name pop up in front of the username.

6. Download the Covey-SDK in Python via the

pip install covey-sdk

command in your terminal.

7. Make sure to have a .env file that contains these keys, notice the alpaca ones for pricing purposes. It is recommended to use the alpaca paper trading keys generated here, since this is for initial experimental purposes. It is of course possible to use full alpaca broker API but not necessary for interacting with the covey SDK.

APCA_API_KEY_ID=""
APCA_API_SECRET_KEY=""
APCA_API_BASE_URL="https://paper-api.alpaca.markets"
APCA_API_DATA_URL="https://data.alpaca.markets"

WALLET_PUBLIC = ""
WALLET_PRIVATE = ""

8. Create a new file called test.py or whichever name you would prefer and run the following code. (Note that posting_only=True, you can set it to False then be sure to add alpaca API keys because this will automatically price your portfolio.)

import covey.covey_trade as ct

# posting_only=True
t = ct.Trade(address = <public wallet key>,
address_private = <private_wallet_key>,
posting_only = True)

# Our format is {GOOGL:0.1,TLT:0.1}
# Where 10% is the target percent - we always deal in target percents
# To close a position post {TLT:0}
# To go short post {TLT:-0.05}
t.post_trades_polygon('GOOGL:0.1,TLT:0.1')

9. Track record will appear on covey.io

10. Earn CVY to credentialize your strategy.

Checking Portfolio

You can also check your latest positions and market values by running this sample code. Make sure you have the .env file set in your project at the top level.

from datetime import datetime
import time
from covey.covey_portfolio import Portfolio

# start the timer
start_time = time.time()

# initialize an example portfolio
p = Portfolio(address='<WALLET_PUBLIC>')

# calculate the portfolio from inception
p.calculate_portfolio()

# grab current timestamp - this will be used to get 'active positions'
current_time_stamp = datetime.now() + timedelta(days=1)

# get rid of minute, second, and microsecond
current_time_stamp_clean = current_time_stamp.replace(minute=0,
second=0,
microsecond=0)

# blockchain positions
blockchain_positions = p.get_active_positions(current_time_stamp_clean)

print(blockchain_positions)

Supported Tickers

We support US listed Equities, ETFs, ADRs, and large cryptocurrencies. Our limitation is that they have to be large (>$1bn market cap) and liquid (>$1mm average daily volume). While the list is updated in real time, attached here is our current universe.

If you post a ticker that we don’t track it will still be saved on chain, but our portfolio math will ignore that ticker.

Conclusion

The Covey SDK is an ideal lightweight tool for quantitative users on the covey.io trading platform. It allows for quick posting on chain to maintain target positions, along with tracking sizing and performance. The SDK is written in an object-oriented design to help easier manipulate and retrieve portfolio data. Join our discord to provide any feedback.

--

--