Skip to content

Commit

Permalink
Merge pull request #3 from TeamWertarbyte/version-2020.1.0
Browse files Browse the repository at this point in the history
Version 2020.1.0
  • Loading branch information
saschb2b authored Jan 7, 2021
2 parents 9e3a6f5 + 56f95b7 commit d7699c3
Show file tree
Hide file tree
Showing 25 changed files with 3,486 additions and 2,974 deletions.
20 changes: 0 additions & 20 deletions .babelrc

This file was deleted.

1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.eslintrc.js
57 changes: 57 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json',
sourceType: 'module'
},
root: true,
plugins: ['jest', '@typescript-eslint', 'promise'],
extends: [
'semistandard',
'plugin:@typescript-eslint/recommended',
'plugin:promise/recommended',
'plugin:prettier/recommended',
'prettier/@typescript-eslint'
],
env: {
node: true,
jest: true
},
rules: {
'@typescript-eslint/no-unused-vars': 'error',
'@typescript-eslint/no-unused-expressions': [
'error',
{
allowShortCircuit: true,
allowTernary: true,
allowTaggedTemplates: true
}
],
'import/order': [
'error',
{
'newlines-between': 'always',
alphabetize: {
order: 'asc',
caseInsensitive: true
},
groups: [
'builtin',
'external',
'internal',
'parent',
'sibling',
'index'
],
pathGroups: [
{
pattern: '#**/*',
group: 'external'
}
]
}
],
'no-unused-expressions': 'off',
'no-useless-constructor': 'off'
}
};
7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
build
lib
dist
node_modules
.idea
.idea

yarn-error.log
19 changes: 0 additions & 19 deletions Dockerfile

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2018 Wertarbyte
Copyright (c) 2021 Wertarbyte

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
119 changes: 109 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,126 @@
# USE AT OWN RISK
# Cryptocurrency Trading Bot
I'm using this bot for a long time now and wanted to share it.


Feel free to make it your own. PRs are welcome!

## USE AT YOUR OWN RISK
A trading bot that does what you order him to do (use at your own risk)

I'm using this bot now for a long time and wanted to share it. It's using the ema crossing strategy kinda.
Feel free to make it your own. PRs are also welcome!
I'm not responsible for anything

I also wrote a medium article if you want to learn more https://medium.com/wertarbyte/a-cryptocurrency-bot-that-doesnt-scam-you-67b85d05a400
## EMA crossover strategy
It's using the ema crossover strategy. But instead of EMA 5 and EMA 20 I'm using EMA 9 and EMA 26

https://www.theforexchronicles.com/the-ema-5-and-ema-20-crossover-trading-strategy/

![EMA crossing strategy](ema-crossing.png)

## Program Sequence

## Main loop
```
start = async () => {
const start = now();
log.info(`########## Started ichimoku ##########`);
await this.collectRevenue();
const markets: Market[] = await this.getMarkets();
const marketSummaries: MarketSummary[] = await this.getMarketSummaries(
markets
);
await this.evaluateMarkets(marketSummaries.map(({ symbol }) => symbol));
// await this.report();
log.info(`########## Finished ${(now() - start).toFixed(5)} ms ##########`);
};
```

## Collecting Revenue
```
await this.collectRevenue();
```
* Fetch you current balances
* Only checks assets where available coins are greater than 0
* Ignore assets that you want to HODL see config
* Iterate over every balance
* Fetch current market ticker for this balance (e.g. `ETH-USDT`)
* Calculates how much revenue is already earned (current value minus invest)
* When greate than invest try to sell that bit
* e.g. Current value 57 USDT with an invest of 50 USDT -> sell 7 USDT worth
* It can only sell when the quantity will be greater than the minimum trade size allowed by bittrex

## Evaluate Markets
```
const markets: Market[] = await this.getMarkets();
const marketSummaries: MarketSummary[] = await this.getMarketSummaries(
markets
);
await this.evaluateMarkets(marketSummaries.map(({ symbol }) => symbol));
```
* Filter the markets `getMarkets` and `getMarketSummaries`
* Only use markets using the `config.mainMarket` here `USDT`
* Only use market which are `ONLINE`
* Check against market summary to see if the quote volume is greater than 0 (market is being traded on)
* Use those filtered marked for the next step -> `evaluateMarkets`
* Iterate over every market
* Ignore HODL markets (just buy some manually and HODL on)
* Get candles
* Count EMA ticks. Positive and negative
* If you got some of that asset in your balance
* If it's on the blacklist it will sell it. E.g. Bittrex delisting coins
* If it got too many negative ticks it will sell it
* If you don't have any of that asset in you balance
* If it's not blacklisted and got the amount of positiv ticks it will buy

**Selling**: It will be a limit sell with `timeInForce: TimeInForce.FILL_OR_KILL` Meaning, either it gets sold directly or the order gets canceled and will be tried next round.

**Buying**: The positiv ticks need to be exact the value defined in the config. This will prevent buying into a market "too late"

## (optional) Report
```
// await this.report();
```
Enable this line to report your current state. You will also need to enter your url in `api/BittrexApi.ts report()`

This could be used to track your bot and how much your balances are worth over time.

## Requirements
Node.js

As package manager install yarn https://classic.yarnpkg.com/en/docs/install

## Usage

Add `apiKey` and `apiSecret` from bittrex to your `./config/index.js`
### Adapt the config
Add `apiKey` and `apiSecret` from bittrex to your `./config.ts`

See https://support.coinigy.com/hc/en-us/articles/360001123973-How-do-I-find-my-API-key-on-Bittrex-com-

Tweak the other configuration options to your liking.
For more details on the config see the documentation in `config.ts`

## Build and start
```
yarn
yarn start
```

This will create a `/dist` folder and start the containing `/dist/index.js` file

## Build bundle
```
npm i
npm run start:dev
yarn
yarn build
```

You can also use the included `Dockerfile` to build an image and deploy it wherever you want.
This will create a `/dist` folder containing the created `.js` files. You could now deploy it on any server you like

## Development
```
yarn
yarn start:dev
```

![Screenshot](screenshot.png)
This will start the bot in a watch mode. On every code change it will recompile and restart
6 changes: 0 additions & 6 deletions docker-compose.yml

This file was deleted.

Loading

0 comments on commit d7699c3

Please sign in to comment.