Investfly SDK
Project description
About
Python-SDK to work with Investfly API. Investfly
Investfly offers a platform for developing automated stock trading strategies. Users can create trading strategies through an intuitive drag-and-drop interface or by coding in Python.
The Investfly SDK contains the API and tools needed to build and deploy Python-based trading strategies on the Investfly platform.
Although you can edit Python code in our browser-based editor, writing code in a familiar IDE (Pycharm, VSCode) is recommended due to all the benefits that rich IDE offers. This SDK and CLI that comes with it makes it possible to develop trading strategy locally using your favorite IDE and upload it your Investfly account.
Quickstart
SDK Installation and Setup
Investfly-SDK comes with all required Python classes used for strategy development as well as a command line tool (CLI) called investfly-cli
Using a terminal app, run the following commands.
Setup Project and Virtual Environment
mkdir investfly
cd investfly
python3 -m venv venv
source venv/bin/activate
Install investfly-sdk
pip install investfly-sdk
Launch investfly-cli
Investfly SDK comes with a command line tool (CLI) called investfly-cli.
investfly-cli
investfly-cli$ -h
usage: investfly-cli [-h] {login,logout,listStrategies,copySamples,exit} ...
positional arguments:
{login,logout,listStrategies,copySamples,exit}
Available Commands
login Login to Investfly
logout Logout from Investfly
listStrategies List Python Strategies
copySamples Copy Samples from SDK
....
....
exit Stop and Exit CLI
Test Installation
You can test the installation by using the CLI to login and logout of Investfly.
investfly-cli$ login -u <YOUR_USERNAME> -p <YOUR_PASSWORD>
Session(username='xxxxxx', clientId='xxxxx-kaj1p3lv', clientToken='b29c9acc-330a-4821-9187-282d827e3e91')
investfly-cli$ logout
Trading Strategy Development
Investfly-SDK comes with a starter strategy template and many sample strategies to help you get started quickly.
Copy Samples
investfly-cli$ copySamples
Samples copied to ./samples directory
Create New Strategy
You can use one of the samples to create a new strategy. Normally, you would make a copy of the sample strategy, edit the copy using your favorite IDE to create a new strategy. But for now, we'll use the unmodified sample
investfly-cli$ login -u <YOUR_USERNAME> -p <YOUR_PASSWORD>
Session(username='xxxxx', clientId='xxxxxx-krfs61aa', clientToken='766fad47-3e1e-4f43-a77a-72a95a395fec')
investfly-cli$ createStrategy -n MySmaCrossOverStrategy -f ./samples/strategies/SmaCrossOverStrategy.py
Created strategy 83
investfly-cli$ listStrategies
{'strategyId': 83, 'strategyName': 'MySmaCrossOverStrategy'}
Edit and Update Code
Edit and update ./samples/strategies/SmaCrossOverStrategy.py as you like. For testing, change the StandardSymbolsList.SP_100
to StandardSymbolsList.SP_500
inside getSecurityUniverseSelector
function.
investfly-cli$ updateStrategyCode --id 83 -f ./samples/strategies/SmaCrossOverStrategy.py
Code Updated
After the code is updated, next step is to backtest the strategy and deploy it live. You can do them by logging into Investfly with a web browser, navigating to the strategy page and invoking corresponding actions.
IDE Editor
The primary reason for publishing this SDK is so that you can use your favorite IDE Editor to write and update Python Code. We recommend using PyCharm community edition: https://www.jetbrains.com/pycharm/download
Using IDE editor will assist with auto-completion and type hints. Additionally, use type checking tools like mypy to check your code before deploying.
When using the IDE, open investfly
directory created above as a project with your IDE.
Make sure that Python Interpreter is configured to the virtual environment investfly/venv/bin/python
created above.
Getting Help
Please email admin@investfly.com for any support or bug report
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
Built Distribution
File details
Details for the file investfly_sdk-1.1.tar.gz
.
File metadata
- Download URL: investfly_sdk-1.1.tar.gz
- Upload date:
- Size: 53.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6b6245370a53c9ffb6f7c1de62658555fec83dfda60898e4b5d170dc7680b9e8 |
|
MD5 | 62fef4d4633365a5c3133777e772ec59 |
|
BLAKE2b-256 | d22e93d1a2de36a4c70a51d35c3120ff0680b50087c6dc1b9ba760b0c7d8ee1a |
File details
Details for the file investfly_sdk-1.1-py3-none-any.whl
.
File metadata
- Download URL: investfly_sdk-1.1-py3-none-any.whl
- Upload date:
- Size: 60.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c8b4b23ec8832398e3ca61370fe12d482962033feec4e762dd61e8b3350fde88 |
|
MD5 | 406fb4c5253998bc37cfc79174718b55 |
|
BLAKE2b-256 | 151cc8ae718c68edd88cc85c77d7f7fc4ee3c7a42209abb120988ec57827849b |