What is LibKloudTrader?
LibKloudTrader is a trading framework optimized for computational finance. Connect your trading models and conquer the markets. libkloudtrader's main aim is to help algorithmic traders and quants to rapidly protoype their strategies and deploy them on Narwhal. This is python3 version developed and maintained by KloudTrader. R, Julia, Golang versions coming soon!
What is Narwhal?
Narwhal is an algorithmic trading deployment platform developed by KloudTrader. It is an end-to-end PaaS for deploying your algorithmic/automated trading strategies at a comission-free flat rate brokerage. You can code your trading strategy using libkloudtrader and deploy it on Narwhal so that it can trade for you in the U.S financial equities' market.
pipenv install -e git+https://github.com/KloudTrader/libkloudtrader.git#egg=libkloudtrader
Deployment on Narwhal
Add your card
Don't worry you are not charged right away.
Creating a Runtime
In Narwhal, a Runtime is a basic computational unit that runs your strategy/algorithm. The algorithm running on your Runtime is totally your property and no other Narwhal user or KloudTrader employee can view it. Currently we only support Python-3 runtimes which means you can only deploy algorithms written in Python but we will be introducing R, Julia, Excel and many more types of Runtimes very soon, thus libkloudtrader library's wrappers for respective languages will also be available soon.
It is extremely easy to create a Runtime. All you need to do is:
Select a location for your runtime.
Select a size for your runtime.
Enter your SSH/RSA public key.
We ask for your RSA public key only once(when you create your first runtime). Your public SSH/RSA key is needed so that we can create a secure connection between you and your Runtime and is only accessible by You, the owner.
Where is my SSH/RSA public key?
Enter a name for your runtime. It can be whatever you want it to be.
And you are good to go.
After you have created a runtime, you can view your runtime on the dashboard.
Linking your trading account
Now that you have created a created a runtime you shal link Brokerage to your Narwhal Account.
Narwhal provides flat-rate brokerage via Tradier Brokerage Inc.
Linking your Tradier account or Signing up if you are not a Tradier user is pretty easy. It generally takes 1-2 business days to open account with Tradier.
Now we will look at your workflow from after creating a Runtime till deploying your algorithm to your Runtime. All it takes is, are a few commands to deploy your "alpha".
The following steps require Git
You have to type the commands in the order they are described.
Make a directory where you will be working/coding your trading algorithm.
Enter into your directory 'my-algorithm'
Add the remote-link of your Runtime. You can copy the remote-link by clicking on the Left-most button on the lower corner of your Runtime card.
git remote add narwhal "you remote-link here" Example: git remote add narwhal ssh://firstname.lastname@example.org:10022/15/proud-snowflake-s9sx.git
Narwhal's Python3 Runtime uses Pipenv to manage the dependencies of your algorithm.
To install and get started with Pipenv, please refer it's official webiste. Pipenv is pretty easy to install and much easier to use.
You can install libkloudtrader and other libraries of your choice by typing:
pipenv install -e git+https://github.com/KloudTrader/libkloudtrader.git#egg=libkloudtrader pipenv install pandas, numpy
Enable your virtual environment so that you can start writing your algorithm
The algorithm you want to deploy should be in a file called main.py
Your algorithm must have these imports:
from libkloudtrader.defaults import *
This will help Narwhal to access your access token and account number from the Narwhal Environment so that you don't have to explicitly pass them with each API call. Narwhal would not be able to load your access token and account number from the Narwhal Environment if you don't link your tradier account. So the best practice is to link your tradier account before deploying your Trading Algorithm.
This is what the imports of algorithm written with libkloudtrader shall look like:
You directory structure for a Python3 Runtime should look like:
/my-algorithm |-main.py |-Pipfile.lock |-Pipfile
Deploying your algorithm
Deploying your algorithm only takes 3 steps and commands.
Add your files
git add -A
Commit your files
git commit -m "hope this is alpha!"
Isn't that what everyone is hoping for?! 😄 📈 📊 📉 😄
And finally, Deploy
git push -u narwhal master
Note: Your access token will expire after 24 hours. In order to allow your deployed algorithm to trade seemlessly, please manually link your tradier account after 24 hours. Don't worry this is just in Beta Version and will be automated soon!