Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/asgeir-s/tb-signals

Microservice for handeling trading signals in TradersBit
https://github.com/asgeir-s/tb-signals

cryptocurrency trading trading-signal

Last synced: 20 days ago
JSON representation

Microservice for handeling trading signals in TradersBit

Awesome Lists containing this project

README

        

# Signals Microservice
Microservice used for handling trading signals in the tradersbit project. TradersBit is shut down and open sourced.

## What is TradersBit?
TradersBit is (was a) a marketplace for streams of Bitcoin trading signals.

Publishers create streams, send trading signals to streams, and sell subscriptions to streams. Publishing on TradersBit is completely free. Signals can be published through our website, API or by connecting your Bitfinex account. The API makes it possible to connect trading bots and other applications.

Statistics for each stream's performance are computed and displayed in the marketplace. Trading fees are incorporated in the statistics.

Subscribers can browse, filter and sort streams based on average monthly profit, average trade, and other indicators. When subscribing to a stream, users can receive signals via email or have the signaled trades automatically executed through their own Bitfinex accounts.

The publishers of the streams will set the monthly subscription fee. Upon selling subscriptions, publishers will earn 70 percent of the subscription fees. We get the remaining 30 percent. TradersBit earns profits only when the publishers make profits, so our respective interests are the same.

Upon the reception of a trading signal, we simulate the trade (including trading fees). As a result of this, there is no way for the publishers to manipulate statistics.

There is no social interaction in this marketplace because the statistics and trading signals speak for themselves. This way, subscribers will not be scammed easily. A subscriber should not need to know or care whether signals are sent manually by a teenager, an MBA graduate or automatically generated by a trading bot. At TradersBit, the streams and statistics matter, not the people behind them.

TradersBit will also host trading competitions. For instance, most profitable streams last 30 days, etc., with rewards in Bitcoins.

## TradersBit consists of
* [tradersbit.com](https://github.com/sogasg/tradersbit.com) - the webpage
* [tb-front](https://github.com/sogasg/tb-front) - serverless REST API
* [tb-back](https://github.com/sogasg/tb-back) - serverless backend (not accessed directly by users)
* [tb-signals](https://github.com/sogasg/tb-signals) - microservice for handling incoming trading signals
* [tb-streams](https://github.com/sogasg/tb-streams) - microservice for handling stats for streams of trading signals

## API
* **POST: /streams/'streamID'/signals** body: -1,0 or 1 => the signal
* **GET: /streams/'streamID'/signals?** (optional URL-params: onlyClosed, fromId, toId, afterTime, beforeTime and lastN (see combinations at the bottom of this page)) => all signals
* **GET: /streams/'streamID'/status** => last signal

## Environment Variables
AWS_ACCESS_KEY_ID (default 'none')
AWS_SECRET_KEY (default 'none')
AWS_SNS_REGION (default 'none')
AWS_DYNAMO_REGION (default 'none')
AWS_DYNAMO_STREAMS_TABLE (default 'none')

MICROSERVICES_HTTPS
STREAMS_SERVICE_ADDRESS (default 'none')
STREAMS_SERVICE_PORT (default '80')
SERVICE_APIKEY (default 'none')

LOG_LEVEL (default 'DEBUG')

optional(initialized for testing and automatically provided by AWS):
RDS_HOSTNAME
RDS_PORT
RDS_DB_NAME
RDS_USERNAME
RDS_PASSWORD_NEW (OBS: must be set!)

### Test parameters
AWS_DYNAMO_REGION=us-west-2
AWS_DYNAMO_STREAMS_TABLE=streams-staging
MICROSERVICES_HTTPS=false
SERVICE_APIKEY=secret
AWS_SNS_REGION=us-west-2
LOG_LEVEL=DEBUG
AWS_SECRET_KEY=q9/igUKZHmIarMVA8pjGkkd33/XTqHcjXZicO8Kp
AWS_ACCESS_KEY_ID=AKIAJTDJWSYFWGUK5YOQ
STREAMS_SERVICE_ADDRESS=tb-staging-streams.elasticbeanstalk.com

## OSX Set Up
##### Docker
Local if runing docker: localhost

One time setup:

boot2docker init
VBoxManage modifyvm "boot2docker-vm" --natpf1 "postgres-port,tcp,127.0.0.1,5432,,5432" #osx specific bind (local) # set postgres to "listen on *" and "host all all 0.0.0.0/0 trust"

Setup on each shell:

boot2docker start
eval "$(boot2docker shellinit)"

##### Deployment
One time setup:

cd docker
eb init (then select environment etc...)

## Makefile
-test
-test-u (unit)
-test-s (service)
-run-l (run locally)
-build (builds an artifact and place it in the docker folder and after that build the docker container)
-deploy-s (deploy on staging)
-test-s-s (service tests against staging)
-deploy-p (deploy in production)

## Valid GET requests parameter combinations:
onlyClosed => signals for all closed trades (the last signal is CLOSE)
fromId, toId => signals between (not including)
afterTime, beforeTime => signals between (not including)
afterId => signals newer the signal with 'afterId' (not including)
toId => signals older the 'toId' (not including)
afterTime => signals newer then 'afterTime' (not including)
beforeTime => signal older then 'beforeTime' (not including)
lastN => returns the last n number of signals

## Local Testing Setup

#### Postgres

postgresql.conf

listen_addresses = '*'

pg_hba.conf

# TYPE DATABASE USER ADDRESS METHOD

# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 trust
host all all 0.0.0.0/0 trust
# Allow replication connections from localhost, by a user with the
# replication privilege.
#local replication sogasg trust
#host replication sogasg 127.0.0.1/32 trust
#host replication sogasg ::1/128 trust

With problems: RESTART COMPUTER ;P

## Troubleshoot
This project requires Java Cryptography Extension (JCE) Unlimited Strength to run.
Error: ava.security.InvalidKeyException: Illegal key size or default parameters means JCE is missing.