From 82d2da0cf166c5a941c816ddaff163ae334e0c59 Mon Sep 17 00:00:00 2001 From: Igor Limansky Date: Thu, 2 Apr 2020 22:07:15 +0300 Subject: [PATCH] add first example that will place simple Smart Trade --- .gitignore | 3 +++ README.md | 17 ++++++++++++++++- requirements.txt | 1 + trade.py | 42 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 requirements.txt create mode 100644 trade.py diff --git a/.gitignore b/.gitignore index b6e4761..c65650f 100644 --- a/.gitignore +++ b/.gitignore @@ -127,3 +127,6 @@ dmypy.json # Pyre type checker .pyre/ + +# Idea +.idea \ No newline at end of file diff --git a/README.md b/README.md index ca9b716..668f99b 100644 --- a/README.md +++ b/README.md @@ -1 +1,16 @@ -# trading-bot-example \ No newline at end of file +# trading-bot-example + +Simple example of own trading bot running on your computer or own cloud, using Cryptocurrencies.AI for more advanced execution + +### Installation + +``` +$ git clone git@github.com:Cryptocurrencies-AI/trading-bot-example.git +$ cd trading-bot +$ pip3 install -r requirements.txt +$ python3 trade.py +``` + +### Deployment + +// todo \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..b253d14 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +ccai-client==0.0.3 \ No newline at end of file diff --git a/trade.py b/trade.py new file mode 100644 index 0000000..657b4cb --- /dev/null +++ b/trade.py @@ -0,0 +1,42 @@ +from ccai.client import Client + +def test_create_smart_order(): + # create simple smart order that will entry by market and exit with 15% profit + # or exit at 10% loss + + client = Client('SECRET', + 'KEYID') + smart_order = { + "marketType": 1, # 0 - spot, 1 - futures + "pair": "BTC_USDT", + "stopLoss": 10.0, # 7% loss + "stopLossType": "market", # will place stop-limit or stop-market + "leverage": 30, # leverage + "entryOrder": { + "side": "buy", + "orderType": "limit", + "price": 6300, + "type": 0, # not using yet, just place 0 + "amount": 0.001 # btc amount + }, + "exitLevels": [ + { + "price": 15, # 15% profit + "amount": 100, # 70% from entry + "type": 1, # 1 - means amount and price is in percentage + "orderType": "limit" + } + ] + } + response = client.create_order(params=smart_order) + print(response) + +def test_get_balances(): + client = Client('SECRET', + 'KEID') + response = client.get_balances() + print(response) + +#test_create_smart_order() +#test_get_balances() +test_create_smart_order() \ No newline at end of file