the FOSS computational trading platform (for non-tinas..) https://github.com/pikers/piker
Go to file
Tyler Goodlet 395f0c8e4a Synchronize Questrade token refreshing per client
Questrade's API is half baked and can't handle concurrency.
It allows multiple concurrent requests to most endpoints *except*
for the auth endpoint used to refresh tokens:

    https://www.questrade.com/api/documentation/security

I've gone through extensive dialogue with their API team and despite
making what I think are very good arguments for doing the request
serialization on the server side, they decided that I should instead
do the "locking" on the client side. Frankly it doesn't seem like they
have that competent an engineering department as it took me a long time
to explain the issue even though it's rather trivial and probably not
that hard to fix; maybe it's better this way.

This adds a few things to ensure more reliable token refreshes on
expiry:

- add a `@refresh_token_on_err` decorator which can be used on `_API`
  methods that should refresh tokens on failure
- decorate most endpoints with this *except* for the auth ep
- add locking logic for the troublesome scenario as follows:
  * every time a request is sent out set a "request in progress" event
    variable that can be used to determine when no requests are currently
    outstanding
  * every time the auth end point is hit in order to refresh tokens set
    an event that locks out other tasks from making requests
  * only allow hitting the auth endpoint when there are no "requests in
    progress" using the first event
  * mutex all auth endpoint requests; there can only be one outstanding

- don't hit the accounts endpoint at client startup; we want to
  eventually support keys from multiple accounts and you can disable
  account info per key and just share the market data function
2019-02-09 21:39:22 -05:00
piker Synchronize Questrade token refreshing per client 2019-02-09 21:39:22 -05:00
tests Add a token refresh test that exhibits an API race issue 2019-02-04 00:16:16 -05:00
.gitignore Initial commit 2018-01-15 22:58:02 -05:00
.travis.yml Screw it; go 3.7 for ``datetime.fromisoformat()`` 2018-11-11 23:12:13 -05:00
LICENSE Go GPLv3 2018-11-12 00:29:43 -05:00
MANIFEST.in Extend install docs 2018-02-15 13:33:53 -05:00
Pipfile Update Pipfiles 2018-11-12 00:30:55 -05:00
Pipfile.lock Deps bump 2019-01-27 22:10:49 -05:00
README.rst Mention 3.7 in Readme 2018-11-23 11:22:44 -05:00
setup.py Go GPLv3 2018-11-12 00:29:43 -05:00

README.rst

piker

Trading gear for hackers.

travis

Install

piker is currently under heavy alpha development and as such should be cloned from this repo and hacked on directly.

A couple bleeding edge components are being used atm pertaining to async ports of libraries for use with trio.

Before installing make sure you have pipenv. For a development install:

git clone git@github.com:pikers/piker.git
cd piker
pipenv install --dev -e .
pipenv shell

To start the real-time index ETF watchlist with the robinhood backend:

piker watch indexes -l info

If you want to see super granular price changes, increase the broker quote query rate with -r:

piker watch indexes -l info -r 10

It is also possible to run the broker-client micro service as a daemon:

pikerd -l info

Then start the client app as normal:

piker watch indexes -l info

Laggy distros

For those running pop-culture distros that don't yet ship python3.7 you'll need to install it as well as kivy source build dependencies since currently there's reliance on an async development branch.

Tech

piker is an attempt at a pro-grade, next-gen open source toolset for real-time trading and financial analysis.

It tries to use as much cutting edge tech as possible including (but not limited to):

  • Python 3.7+
  • trio
  • tractor