- Notifications
You must be signed in to change notification settings - Fork14
a command-line ui for market data and algo management. currently integrates with iexcloud for stock and crypto charts 💹 and market data 🗃, and alpaca 🦙 for trading.
License
hp4k1h5/agora
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
This package is now deprecated.
The main goal of this project was to provide a full trading and algo management application in the terminal. When this app was fully functioning, it was able to provide a range of interesting functionalities. Unfortunately, I have not been able to find the time to maintain the app, and it has fallen into a semi-broken state of disrepair.
Thanks for the support and good luck to all.
view market info and charts and trade stocks in the terminal
contributions andbugreportsarewelcome
the workspace used to generate this image is defined indocs/example-configs/dense.json
- crypto book and quote, use prefix
¢
- help menu bugfix
- nodeJs ✅ tested with
v14.8.0
download or clone this repo
- either run
yarn global add @hp4k1h5/agora
ORnpm i -g @hp4k1h5/agora
. - or run
git clone https://github.com/HP4k1h5/agora.git
and getdependencies by runningyarn
in this directory, ornpm i
.
- either run
add apublishable iex api key
- either export an ENV var namedIEX_PUB_KEY
ex.export IEX_PUB_KEY=pk_Y0urIeXaPipUbl15h4bLeKEY
locally or in your.bashrc
equivalent. - or set the
IEX_PUB_KEY
inconfig.json
in this repo, or the defaultconfig location; on a mac, this will be~/.config/agora/config.json
.You will have to create the directory with e.g.mkdir ~/.config/agora
, and then copy over your config with e.g. on a mac
cp~/.config/yarn/global/node_modules/@hp4k1h5/agora/config.json~/.config/agora
examples
in
.bashrc
equivalent or from the command lineexport IEX_PUB_KEY="yourIEXpublishablekey"export IEX_SECRET_KEY="yourIEXsecretkey"# optional
or in config.json
{"IEX_PUB_KEY":"yourIEXpublishablekey","IEX_SECRET_KEY":"yourIEXsecretkey # optional"}
Seeconfig.json for configuration tips and example configs.
- either export an ENV var namedIEX_PUB_KEY
If you installed globally, you should be able to use the shell alias
agora
from anywhere. If you encounter problems or want a morecomprehensive tutorial, please seetutorial.
iex account info
In order to see iex account information also set theIEX_SECRET_KEY
in thesame manner as above. Seeaccount.🦙 alpaca account integration.
See🦙 trading.
for a freeiex account andcopy thepublishable api key. These typically start withpk
if you receive"Payment required" errormessages, this is iexcloud telling you that your remaining message allotmentis insufficient for the data request you are making. You can visit youriexcloud console or type
@
from the replfor more information. If you wish to make the most use of your 500,000 freemonthly iex messages, avoid longer time-range graph queries. For example,a 1-year chart costs roughly 12,590 messages (~252 trading days * 50messages/day). Intraday time ranges such as:1d
or:100min
are free, i.e.incur no message cost. Seeiex apidocumentation to learn moreabout endpoint pricing.
Please consult thetutorial.
Please consult thetutorial.
Typinghelp
orh
brings up a help menu. If you include another commandname after, command-specific help is returned to the repl. Typex
in therepl to close the help menu
examples
help $--> show help for stock prefix commandh :--> show help for time prefix commandh #--> show help for chart commandh--> show general help
Typingquit
,exit
orCtrl-c
will exit the app
Use left and right arrow-keys to switch between workspaces. By default,agora comes with several workspaces. Depending on you terminal and tradingpreferences, these can be configured inconfig.json
. Seeconfiguringworkspaces
If the repl is not focused, hit>
to return to repl. The last active windowwill be the target of the commands entered unless a window prefix-command hasbeen issued.
From the repl, hitesc
to return to the focus rotation.
Typing a[
followed immediately by a window id, or one of the keywordsall
ornew
will target the window(s) with the command. Window ids are found in thetop-left corner of each targetable window.
examples
[4 # :max $tm--> display max-time chart of $tmin the fourth window$aa [all--> update all targetable windows with stock symobl $aa[2 x-->close the second window= [new-->open a new watchlist window
Typing an x will close the active window. May be combined with window prefixto target a specific window.examples
[4x-->closesthe4thwindowx-->closestheactivewindow
Typing?
followed by search terms will query stock symbols and company namesfor approximate (fuzzy) matches. Capitalization and spacing is ignored as arequotes and most other non word symbols.If you are searching by key word like "solar", consider adding more words tonarrow down the result set
examples
? electric tlsa??"american Motor" company
Typing$
followed immediately by a stock ticker symbol changes the symbol inthe active window. Can be combined with window, technical-indicator and timeprefixes to update multiple values at the same time
examples
$TM--> update symbolin active componentto TSLA[2 $BRK.B :1.5h--> update active symbolto BRK.B and update timeto last90 minutes
Typing¢
followed immediately by a valid crypto/currency pair changes theinstrument in the active window. Can be combined with window,technical-indicator and time prefixes to update multiple values at the sametime
examples
¢BTCUSD ^ --> update active window to a book of BTC/USD" ¢ethusd --> update active window to a quote of ETH/USD
Typing:
followed immediately by a combination of the following parameterswill change the currently active time range and update the currently activewindow. This will only apply to chart windows.
valid time ranges1d, 5d, 5dm, 1m, 1mm, 3m, 6m, ytd, 1y, 5y, max
OR
numeric values affixed withmin
orh
, see examples.
Can be combined with time prefix to update multiple values at the same time
examples
:100min --> updatetime to last 100 minutes:6.5h [4 --> updatetime to last trading dayin the fourth window:5dm$x --> updatetime to last 5 days minute-averaged and update stock to X
Typing#
brings up the price/volume chart display in the targeted window.You may also set time, stock symbol, andtechnical-indicator by including thoseprefix-commands in the query.
examples
# :1dm$t-->changetheactivewindowtoa1day5-minuteschartof$t[2 # %wma-->changethesecondwindowtoachartwithweighted-moving-averageoverlay
Typing^
orbook
will bring up the order book for the active symbol.
examples
$de ^ poll6e4--> change the symbolin the active windowto $de order book and poll every minutebook $aa [3--> order book for $aain the third window
Typing!
brings up the news display with up to the latest 20 resultsrelevant to the active symbol. Use mouse to scroll the table. Usetab
oresc
to return to repl. Can be combined with stock prefix to update multiplevalues at the same time
examples
$de!# show news and update active stock to DE!$ibm [3# show news and update stock to ibm in window 3
Typing=
brings up the watchlist display. Use mouse to scroll the table. Usetab
oresc
to return to repl.. Watchlist is in the top-left corner. Use mouseto scroll. This workspace is defined indense.json
note: Key values
open high low close
are only available to iex premiumdata subscribers and during non-market hours to other api consumers
If the watchlist expands beyond its defined boundaries and is occluding othercomponents, try rotating through your other components withtab
orShift-tab
. Alternatively, use the arrow-keys 'right' and then 'left' toreset the workspace
🐴 set watchlist to string value "alpaca" to source your alpaca watchlists.
examples
= [4
Typing&
brings up a profile of the active symbol in the targeted window.Use mouse to scroll components.
examples
$qcom&
Typing*
brings up a list of gainers/losers/active/etc in the targetedwindow. List can be customized inconfig.json
.examples
*
Typing"
displays a real-time quote for the active symbol in the targetedwindow.
examples
[4"$r
Components can update themselves periodically either by callingpoll
followed immediately by a number greater than 10, or by setting thepollMs
key for the component inconfig.json
to a number greater than 10, whichequals 100 requests/s, which is the max allowable by iex's rate limits.scientific notation (i.e.poll1e3
) is allowed.
If you poll multiple components at 10 ms intervals, you will quickly exceediex's rate limit which is based on ip, and therefore anything lower than 100,is inadvisable, since you may have multiple polling components at the sametime.
All polls are cleared when switching workstations. For now, you will have tomanually restart them. Try[all poll1.5e3
to set all components polling at1.5 second intervals. This is the same as calling[all poll1500
. Use[all poll
to stop all components polling.
examples
[3 poll60000 --> poll the 3rd window every 60 secondspoll [2 --> stop pollingin window 2[new ^$aapl poll1000 --> open a new book window with$aapl polling every 1 secondpoll6e4 [3 --> poll the 3rd window every minute (60,000 milliseconds)[all poll --> STOP all windows from polling[all poll1000 --> all components poll at 1 second intervals
iex paid subscribers only
Typing%
followed immediately by the abbreviated name of the technicalindicator will overlay the active chart window with the technical indicator.This will only apply to chart windows.
valid technical indicators includebbands, wma, ema, hma
. Seefulllist. Can be combined with time, stock and windowprefixes to update multiple values at the same time
examples
%bbands --> add bollinger bands overlay to current active chart[4$qqq %wma --> update fourth window with weighted moving average and$qqq% --> % by itself with no indicator name will remove any indicator from the targeted window
Typing@
will bring up the account window if you have set yourIEX_SECRET_KEY
in the config.json or as an env var.
⚠ disclaimer: agora's trading integration is in earlyalpha and it is notrecommended for use with real money accounts. Per theLICENSE,neither hp4k1h5 nor any contributors to this repository, nor agora make anyguarantees or claims regarding the status of trades executed via agora.Please consult a financial professional before deciding whether to use agorafor live, real-money trading. While trading integration is in development, itis recommended to only use "paper" accounts with no real-money value,although the user is free to make their own judgement.
You will need analpaca trading account.Accounts are free as are trades. After signing up you can generate real orpaper api keys. Use one set of these to set env vars orconfig.json
valuesas follows:
export APCA_API_KEY_ID="YourAlpacaAPIid"export APCA_API_SECRET_KEY="YourAlpacaSecretKey"
or
{"APCA_API_KEY_ID":"YourAlpacaAPIid","APCA_API_SECRET_KEY":"YourAlpacaSecretKey"}
Though it is not recommended, you can setconfig.json
value"alpacaAccountType"
to "live" if you wish to trade real-money with agora.The default value is "paper". If you have entered "live" account keys, youwill need to set the value of"alpacaAccountType"
to "live" in order forthem to work.
Also seealpaca config for a sampletrading work station.
if you have entered your information correctly, you should be able to displayyour account and positions info by typing@
.
Setting config.json key "watchlist" to string value "alpaca" will query yourset of alpaca watchlists. This can be set at the config level, the workspacelevel, or on the watchlist component itself.
Algo-trading support is under active development. As a first step, there isa newbots
component that can display relevant information to your tradingbots. There is abots README available in the botsfolder, as well as some example bots, likealpha bot,a simple mean reversion algorithm.
Export your bots to agora frombots.js.
If you are using paper keys or are comfortable with this bot trading with yourmoney, try typingbots
and thenbots ls
to list bots and then,if you areok with the bot trading on your alpaca account typebots start alpha $spy
in the repl. The first command displays the bots component. The second liststhe available bots and the third starts alpha bot which is based on amean-reversion algorithm, targeting$SPY
. You'll see that the bot can printto the repl output window, and the bot component, which offers some defaulttext formatting, as well as a place to dump more persistent messages.
The above image was generated using the config found atdocs/example-configs/alpaca.json
In the above image, there is a bots component in the upper-right hand corner ofthe screen. The bots are also able to dump text to the repl output.
Also seealpaca config for a sample tradingwork station.
Users can execute manual trades as follows. All orders must have threecomponents:
- orderside buy or sell
- use the
+
buy-prefix to buy. use the-
sell-prefix to sell. - selling when you own no shares will be considered a short sale.
- underscores and commas are allowed in quantities, i.e. 1_000 = 1,000 =1000
- also see
close
andcancel
commands below
- use the
- quantity
- affix the quantity directly to the order side
- stocksymbol
- use the stock symbol prefix
$
to designate the instrument
- use the stock symbol prefix
Optionally users can set the order type and time-in-force. Orders that includea<
limit-prefix, a>
stop-prefix or both, will be submitted as,limit
,stop
, orstop_limit
respectively. If you include the order type with theorder, your order will be loosely validated for correctness before going out.This means that if you submit a stop_limit order that has incorrect limit vsstop prices, alpaca will reject your order, and not this app. However if youexplicitly submit a stop_limit without both a stop price and a limit price,agora will reject your order before it goes out. Including the prefixes `<
`, without explicitly stating what the order type is will automaticallydecide what order type you are submitting.
Orders that include one ofday, gtc, opg, cls, ioc, fok
will be counted assuch.
examples
+100$tm<130.23 -> buy 100 shares of$tm with a limit price of 130.23-50$qqq<297>296 -> sell (short) 50 shares of$qqq stop at 296 limit price 297 or better$gm gtc +1_000 -> buy 1,000 shares of$GM good-to-cancel
Use commandcancel
plus one ofall
,$symbol
,order_id
orclient_order_id
to cancel all orders, all orders for a given symbol, or asingle order.
examples
cancel all -> cancel all open orderscancel$tm -> cancel all open ordersfor$TMcancel 4f447 -> cancel the order starting with id or client id 4f447, must be length 5
Use commandclose
plus one ofall
or$symbol
to close all positions, or theposition for a given symbol.
examples
close all -> cancel all positionsclose$tm -> close positionin$TM
By default agora will look for a config in two places on unix/free-bsdsystems. First it will check~/.config/agora/config.json
, and then it willlook in the root directory of this repo, wherever that is installed on yoursystem. If the path~/.config/agora/
does not exist, you will have tocreate it yourself. You can copy this config and adapt for your own purposes.Please feel free to share handy configurations by submitting an issue or pr.
Please consult thetutorial.
I appreciate your patience as the behavior of the app settles and as i work upsome more thorough explanations of the app's behavior.
this project would not have been possible were it not for the incredibleefforts ofblessed andblessed-contrib authors andcontributors. Though these repos are somewhat dormant and agora is usingforked versions, my heartfelt thanks go to these teams.
stock search is brought to you byfuzzysort
iex for making a robust free market data api
alpaca, for their free trading api
About
a command-line ui for market data and algo management. currently integrates with iexcloud for stock and crypto charts 💹 and market data 🗃, and alpaca 🦙 for trading.