This is a client implementation of trading program(bot) which can use Pine script langauge used in TradingView to define a strategy.
- (Currently) Only support crypto trading using ccxt and cryptowatch API.
- Work with server module (which is not public)
- Pine script is processed on server-side.
- Client module collects price information (OHLCV) adn make an order. (API key and secret information won't be sent to server.)
This program uses ccxt to make an order and use cryptowatch API to acquire price information to reduce the number API calls of exchange. It means you can trade any pairs at any exchanges which are supported by both modules theortically.
However the above two system often diffrent symbol name for identical market, so we need to translate it (by implementing). Your feedback and request are appreciated.
(In server-side,) an original Pine runtime is implemented and used. So far it has supported subset of Pine language and here are notable restrictions.
- Version 3 is supported
- Not implemented builtin functions
security()
strategy.order()
- Many others...(Your request is appreciated)
- Syntax
- Multiple assignment statement
- Order
- Limit order
- Stop/Stop-limit order
- Pyramiding
starategy.risk
builtin variables
Just extract released tarball/zip file.
Here are prerequistics:
- Python >= 3.6 (Mandaotry)
- ccxt >= 1.17.376 (Recommendation)
$ cd pine-bot-client-xxxx
$ mv global-parameters.json.tmpl global-parameters.json
Supported parameters are explained in different section. You set API key in this file usually.
$ python pine-bot-client.py init <your Pine script>
If finished successfully, it generates <Pine script>.json
file. You usually set exchange, market, time resolution and order lot with the parameters you defined by input()
function in the Pine script.
$ python pine-bot-client.py run <your Pine script>
It outputs log files under log/
directory with console output.
In the above section, init
and run
commands are introduced. There are other commands, help
to show usage and support
command to output exchange/market support information.
Show usage
$ python pine-bot-client.py help
Show list of supported exchange
$ python pine-bot-client.py support
Supported symbols in an exchange.
$ python pine-bot-client.py support <exchange>
You can specify an identifier of supported exchange.
This is a simple output.
$ python pine-bot-client.py support bitflyer
BTC/JPY: ['BTC/JPY', 'BTCJPY', 'BTC_JPY']: True: ['1m', '3m', '5m', '15m', '30m', '1h', '2h', '4h', '6h', '12h', '1d', '3d', '1w']
FX_BTC_JPY: ['FX_BTC_JPY', 'FXBTCJPY']: True: ['1m', '3m', '5m', '15m', '30m', '1h', '2h', '4h', '6h', '12h', '1d', '3d', '1w']
ETH/BTC: ['ETH/BTC', 'ETHBTC', 'ETH_BTC']: True: ['1m', '3m', '5m', '15m', '30m', '1h', '2h', '4h', '6h', '12h', '1d', '3d', '1w']
BCH/BTC: ['BCH/BTC', 'BCHBTC', 'BCH_BTC']: True: ['1m', '3m', '5m', '15m', '30m', '1h', '2h', '4h', '6h', '12h', '1d', '3d', '1w']
BTCJPY29MAR2019: ['BTCJPY29MAR2019']: False: []
BTCJPY01MAR2019: ['BTCJPY01MAR2019']: False: []
BTCJPY08MAR2019: ['BTCJPY08MAR2019']: False: []
BTC/USD: ['BTC/USD', 'BTCUSD', 'BTC_USD']: True: ['1m', '3m', '5m', '15m', '30m', '1h', '2h', '4h', '6h', '12h', '1d', '3d', '1w']
BTC/EUR: ['BTC/EUR', 'BTCEUR', 'BTC_EUR']: True: ['1m', '3m', '5m', '15m', '30m', '1h', '2h', '4h', '6h', '12h', '1d', '3d', '1w']
The first column is symbol name. You can also use aliases show in next column surronded by []
.
Next column including True/False
show whether price infomration is availabe with cryptowatch API (with successful tranlation of symbol names).
Last column is supported time resolution. If it's empty, the symbole is not available.
The clock of the box where this bot client is running should be accurate enough even if this program calibrates internally using server-side clock. (The observed delay is shown in log information as jitter=
.
This bot uses three kinds of JSON-format configuration files.
glogal-parameters.json
under current working directory.<pine script name
>.json` next to Pine script file to run.- Additonal file specified as last optional argument of
run
command. You can write all configuration itmes in any of these files because they are merged into single object before running.
In merging, it follows following priority order.
global-parameters.json < <pine script>.json < run command json
- exchange (string) - Exchange id.
- symbol (string) - Market symbol.
- resolution (string,integer) - Time resolution. Something like shown as
support
command or integer value in minute.
Under this item, you can specify paramters defined by input()
function. You need to follow type
defined in input()
function.
Under this item, you can change paramters defined in strategy()
function. Most relavant one should be default_qty_value
.
- default_qty_value (float) - Order lot Currently
default_qty_type
is ignored and this value is directly used as order size in each market.
You can specify options to give to ccxt
library. Please refer to ccxt document for details. Here are most relavant options.
- apiKey (string) - API key
- secret (string) - API secret
You can use different ccxt
parameters for different exchanges. It's useful to write API key/secret informations for all exchanges in global-parameters.json
.
Items for push notification using Discord
- name (string) - Notification name
- url (string) - URL for notification issued by Discord
- avatar_url (string) - URL for avatar image