Code Monkey home page Code Monkey logo

tai's Introduction

Tai - Orchestrate Your Trading

Build Status Coverage Status hex.pm version

A composable, real time, market data and trade execution toolkit. Built with Elixir, runs on the Erlang virtual machine

Getting Started | Built with Tai | Commands | Architecture | Examples | Configuration | Observability

What Can I Do? TLDR;

Stream market data to create and manage orders with a near-uniform API across multiple venues

Here's an example of an advisor that logs the spread between multiple products on multiple venues

asciicast

Supported Venues

Venues Live Order Book Accounts Orders Products Fees
FTX [x] [x] [x] [x] [x]
OkEx [x] [x] [x] [x] [x]
BitMEX [x] [x] [x] [x] [x]

Venues In Progress

Venue Live Order Book Accounts Orders Products Fees
Binance [x] [x] [ ] [x] [x]
Deribit [x] [x] [ ] [x] [x]
GDAX [x] [x] [ ] [x] [x]
Huobi [x] [ ] [ ] [x] [ ]
Delta Exchange [x] [ ] [ ] [x] [x]
Bybit [ ] [ ] [ ] [x] [ ]
bit.com [ ] [ ] [ ] [ ] [ ]
Bitfinex [ ] [ ] [ ] [ ] [ ]
Kraken [ ] [ ] [ ] [ ] [ ]
CME [ ] [ ] [ ] [ ] [ ]
Phemex [ ] [ ] [ ] [ ] [ ]
BTSE [ ] [ ] [ ] [ ] [ ]
KuCoin [ ] [ ] [ ] [ ] [ ]
BitMax [ ] [ ] [ ] [ ] [ ]
Bitget [ ] [ ] [ ] [ ] [ ]
MEXC [ ] [ ] [ ] [ ] [ ]
PrimeXBT [ ] [ ] [ ] [ ] [ ]
Gate.io [ ] [ ] [ ] [ ] [ ]
Coinflex [ ] [ ] [ ] [ ] [ ]
bitFlyer [ ] [ ] [ ] [ ] [ ]

Install

tai requires Elixir 1.11+ & Erlang/OTP 22+. Add tai to your list of dependencies in mix.exs

def deps do
  [
    {:tai, "~> 0.0.75"}
    # Choose your order data store
    # {:ecto_sqlite3, "~> 0.5.6"}
    # {:postgrex, "~> 0.15"}
  ]
end

Create an .iex.exs file in the root of your project and import the tai helper

# .iex.exs
Application.put_env(:elixir, :ansi_enabled, true)

import Tai.IEx

Run the setup mix task to:

  • Download dependencies
  • Create an orders database
  • Generate tai migrations for the orders database
  • Run migrations
$ mix setup

Usage

tai runs as an OTP application.

During development we can leverage mix to compile and run our application with an interactive Elixir shell that imports the set of tai helper commands.

iex -S mix

Upgrading Tai

Bump the required version number in mix.exs and download the dependencies.

$ mix deps.update tai

Regenerate new or updated migrations

$ mix tai.gen.migration

Rerun ecto migrations

$ mix ecto.migrate

Help Wanted :)

If you think this tai thing might be worthwhile and you don't see a feature or venue listed we would love your contributions to add them! Feel free to drop us an email or open a Github issue.

Authors

License

tai is released under the MIT license

tai's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tai's Issues

Questions

Hey. First of all, thanks for a great library :)

I'm going to experiment with it, but before want to ask some questions

  • Are you use it in production?
  • Are there any possibilities for backtesting?
  • How is it handles rate limiting?
  • Any plans for Dead men's switch functionality or is it possible to implement is as an advisor?

Best,
Ihor

Manage orders in separate process to caller

Currently orders are managed by the caller process. This has the limitation that orders cannot be updated once that process is terminated.

For example:

When an advisor cancels an order in the on_terminate callback
Then the order should be sent to the venue and updated within the OrderStore
But the async task terminates early and never sends the order to the venue

start error

I got the following error when executing the run command : elixir --sname tai -S mix run --no-halt
OS: Mac
Elixir version: Elixir 1.7.3 (compiled with Erlang/OTP 21)

** (Mix) Could not start application echo_boy: EchoBoy.start(:normal, []) returned an error: shutdown: failed to start child: {:ranch_listener_sup, EchoBoy.Router.HTTP}
    ** (EXIT) shutdown: failed to start child: :ranch_acceptors_sup
        ** (EXIT) :badarg
{"log":"Application echo_boy exited: EchoBoy.start(:normal, []) returned an error: shutdown: failed to start child: {:ranch_listener_sup, EchoBoy.Router.HTTP}\n    ** (EXIT) shutdown: failed to start child: :ranch_acceptors_sup\n        ** (EXIT) :badarg","logging.googleapis.com/sourceLocation":{"file":"application_controller.erl","line":1935,"function":"application_controller.info_exited/3"},"severity":"INFO","time":"2018-12-13T18:49:50.723Z"}

Installation failed

Describe the bug

I'm new to Elixir and Tai.when I followed the installation instruction and ran mix setup , i got
** (Mix) The task "setup" could not be found.

To Reproduce
> mix new example
Then follow the instructions

Expected behavior
Maybe the Tai App? Still trying to understand.

Desktop (please complete the following information):

  • OS: macOS12.6,Elixir 1.14,Erlang 25
  • deps:
    {:tai, "~ > 0.0.75"},
    {:ecto_sqlite3, "~ > 0.7.1"},

Tai Config
don't know about it.

Seperation of Database from main tai package.

Is your feature request related to a problem? Please describe.
I think there might be a case where a user of Tai would want to use for other tooling, such as analytics of order books or volatility. Therefore the OrderRepo might not be necessary and it might be an additional piece that can be plugged in. What do you think?

Really love the work done here. If i find some time i'll be willing to contribute.

iex -S mix hangs on 'generate tai app'

hi,
It seems that the quickstart you have in your readme doesnt work as intended; it seems like the app hangs indefinitely, I never get the interactive shell back.

awaitfuture@DESKTOP-ICGEU3C:~/elixir_projects/tai$ iex -S mix
Erlang/OTP 22 [erts-10.6.4] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1]

==> tai
Compiling 287 files (.ex)
warning: function EchoBoy.Config.port/0 is undefined (module EchoBoy.Config is not available)
  lib/tai/venue_adapters/mock/stream_supervisor.ex:37

Generated tai app
==> tai
Compiling 1 file (.ex)
warning: redefining module Tai (current version loaded from _build/dev/lib/tai/ebin/Elixir.Tai.beam)
  lib/tai.ex:1

Generated tai app
awaitfuture@DESKTOP-ICGEU3C:~/elixir_projects/tai$ ll
total 17
drwxrwxrwx 1 awaitfuture awaitfuture   512 Aug  2 08:34 ./
drwxrwxrwx 1 awaitfuture awaitfuture   512 Aug  2 08:32 ../
-rw-rw-rw- 1 awaitfuture awaitfuture    97 Aug  2 08:32 .formatter.exs
-rw-rw-rw- 1 awaitfuture awaitfuture   575 Aug  2 08:32 .gitignore
-rw-rw-rw- 1 awaitfuture awaitfuture    77 Aug  2 08:33 .iex.exs
-rw-rw-rw- 1 awaitfuture awaitfuture   477 Aug  2 08:32 README.md
drwxrwxrwx 1 awaitfuture awaitfuture   512 Aug  2 08:34 _build/
drwxrwxrwx 1 awaitfuture awaitfuture   512 Aug  2 08:34 deps/
drwxrwxrwx 1 awaitfuture awaitfuture   512 Aug  2 08:32 lib/
-rw-rw-rw- 1 awaitfuture awaitfuture   584 Aug  2 08:33 mix.exs
-rw-rw-rw- 1 awaitfuture awaitfuture 11779 Aug  2 08:34 mix.lock
drwxrwxrwx 1 awaitfuture awaitfuture   512 Aug  2 08:32 test/
awaitfuture@DESKTOP-ICGEU3C:~/elixir_projects/tai$
# .iex.exs
Application.put_env(:elixir, :ansi_enabled, true)

import Tai.IEx

please let me know if there anything Ive missed or if theres any other information you would like.

(FunctionClauseError) no function clause matching in Tai.VenueAdapters.Bitmex.Stream.RouteOrderBooks.handle_cast/2

Hey @rupurt.
I'm using tai for data mining and recently I was faced with an error.
Any clues?

lib/tai/venue_adapters/bitmex/stream/route_order_books.ex in Tai.VenueAdapters.Bitmex.Stream.RouteOrderBooks.handle_cast/2 at line 30
(FunctionClauseError) no function clause matching in Tai.VenueAdapters.Bitmex.Stream.RouteOrderBooks.handle_cast/2

arg 0:
{%{"action" => "partial", "attributes" => %{"id" => "sorted", "symbol" => "parted"}, "data" => [%{"id" => 33399985065, "price" => 7467.5, "side" => "Sell", "size" => 842, "symbol" => "XBTZ19"}, %{"id" => 33399985066, "price" => 7467, "side" => "Sell", "size" => 36004, "symbol" => "XBTZ19"}, %{"id" => 33399985067, "price" => 7466.5, "side" => "Sell", "size" => 92, "symbol" => "XBTZ19"}, %{"id" => 33399985068, "price" => 7466, "side" => "Sell", "size" => 182502, "symbol" => "XBTZ19"}, %{"id" => 33399985069, "p

arg1:
%Tai.VenueAdapters.Bitmex.Stream.RouteOrderBooks.State{stores: %{"XBTUSD" => Tai.VenueAdapters.Bitmex.Stream.ProcessOrderBook_bitmex_XBTUSD, "XBTZ19" => Tai.VenueAdapters.Bitmex.Stream.ProcessOrderBook_bitmex_XBTZ19}, venue_id: :bitmex}

Getting up and running

I'm trying to get this running. Do I need to register + provide API details for each exchange, or can I stream the public information using the dummy abc123 keys?

Using the dev.exs example:

** (Mix) Could not start application tai: exited in: Tai.start(:normal, [])
    ** (EXIT) an exception was raised:
        ** (ArgumentError) can't fetch value for key `:api_secret` of application `:ex_poloniex`, can not resolve key POLONIEX_API_SECRET value via adapter Elixir.Confex.Adapters.FileFromSystemEnvironment
            (confex) lib/confex.ex:245: Confex.resolve_and_update_env/2
            (elixir) lib/enum.ex:1336: Enum."-map/2-lists^map/1-0-"/2
            (tai) lib/tai.ex:8: Tai.start/2
            (kernel) application_master.erl:277: :application_master.start_it_old/4

I see the poloniex_api_key and poloniex_api_secret files in the /secrets folder, so I'm assuming that bit is all good.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.