From 67ea786614331657d7044d941edabc756a43979d Mon Sep 17 00:00:00 2001 From: rgalbo Date: Fri, 23 Aug 2019 19:52:34 -0400 Subject: [PATCH 01/21] refactor lib and add key file --- .gitignore | 1 + .vscode/settings.json | 4 ++ bybit/LICENSE => LICENSE | 0 bybit/__init__.py => __init__.py | 0 __pycache__/bybit.cpython-37.pyc | Bin 0 -> 4588 bytes bybit.egg-info/PKG-INFO | 94 ++++++++++++++++++++++++++++ bybit.egg-info/SOURCES.txt | 6 ++ bybit.egg-info/dependency_links.txt | 1 + bybit.egg-info/top_level.txt | 1 + bybit/bybit.py => bybit.py | 0 bybit/README.md | 80 ----------------------- bybit/bybit/__init__.py | 1 - bybit_test.py | 16 +++++ bybit/setup.py => setup.py | 23 +++++-- 14 files changed, 142 insertions(+), 85 deletions(-) create mode 100644 .gitignore create mode 100644 .vscode/settings.json rename bybit/LICENSE => LICENSE (100%) rename bybit/__init__.py => __init__.py (100%) create mode 100644 __pycache__/bybit.cpython-37.pyc create mode 100644 bybit.egg-info/PKG-INFO create mode 100644 bybit.egg-info/SOURCES.txt create mode 100644 bybit.egg-info/dependency_links.txt create mode 100644 bybit.egg-info/top_level.txt rename bybit/bybit.py => bybit.py (100%) delete mode 100644 bybit/README.md delete mode 100644 bybit/bybit/__init__.py create mode 100644 bybit_test.py rename bybit/setup.py => setup.py (54%) diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5af0808 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +key.sh \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..7b545ec --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,4 @@ +{ + "python.formatting.provider": "black", + "python.pythonPath": "/home/rgalbo/.virtualenvs/bt/bin/python" +} \ No newline at end of file diff --git a/bybit/LICENSE b/LICENSE similarity index 100% rename from bybit/LICENSE rename to LICENSE diff --git a/bybit/__init__.py b/__init__.py similarity index 100% rename from bybit/__init__.py rename to __init__.py diff --git a/__pycache__/bybit.cpython-37.pyc b/__pycache__/bybit.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..cea7b00fe38dc3a84b817f6442e063eb7c8f0283 GIT binary patch literal 4588 zcmcgvOLN=S6~@JjAVunBMY0{+Vbat#+e(a6H_mt*$Fi)*PHb7VlsM*$hlO|{5)=qh z7nhF70liVCkA*W`blHWp>`ebh`x~(Brv3|B^*a|7^{5wJq#=jrT;RUW^E-!k3x%A9 z&p$f9d+tnW+P~=G@MBb(}Q*oIq-3Qp1%t|!7uQO;FJ6k z_j)qWw+xmY|^WRTDw(#@o~AP4+SSqza{)4GG)wStqLpQ9JX3w ziL>cOUbQQNlAf567iglxzTQUWl?v7&33sHxV?@Smep1B-pg9U4eQ=~ zrzacja6aPO>C8f>mpIj`ANsOd9ixktG^{_a#9la@s*zFYL!5p}$O{-qh{@Tm4pAA# z`fvm_#N)r2QYhOlsiAY}#Jt~5zW29Js9c4cE6 zqlh%sSf2HBsbDm5!g6#F2^L)iky;bNH1#>{Pl&ZW;}6;vQ~r0P8M9q>PupetDt`JO zE(RUgrrYv_Un>eXr z{V=g0TOA@PCnWiF%R?`$%Z3uA#02tK6Ur5Z6Sq#2RLUnhd~)V3a@Eu{s@;+A}TGztv)^nc>E^E*dz)*+=woodBXgvDV!T;MynNPS=ZM1k2kUSGcWc z_02yaPARL>C~?GaL6RAcl1btE$hfVxs7BJ2-6+W+le~`f+hLSs?{93ZEenD0usVnr znT(~Ysl7o_he4ymlVuHzFD}+}~XLxWoXFejS!=wRy=&YyzoIu2-^~pIrCC z)Dn%BTT6`4`%Wc!l4-b6Bk(sXCXTqKf)d+@V31^R3(PH&EL{hy3-7dLa&=EuY1ZQ( zK%t26kF0Wu^(RwX94#2dA;HKf4sRiyIU6AE#2Qe`*kk*Egn{+)qu9EqJ-<4zW0UJr zk8N(8!_1t<%{fgyTj}!+#P81er&?_88C-|GOsPv#T6@;M#_bvG!Fd^2)>g6Z03|bs z&cDQ__IEJd0IXtor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K(09Vz9+O)%JgD%xTdK>-e6tHS4Z36{b3Xl5vAxNo-lfYDQ)ExdIoesu) zdQOT?J0v4Xpy~ZXbW*3K)A-*l2ue#+^glU7BV4T}xoQ>7Za1KDzFOVsx Date: Fri, 23 Aug 2019 19:56:52 -0400 Subject: [PATCH 02/21] update the . --- .gitignore | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 5af0808..95e9cbc 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,5 @@ -key.sh \ No newline at end of file +key.sh +__pycache__ +.vscode +*.egg-info +.pytest_cache From aa5c44b43ab40871d3214e43ddfe91e27eaa06c4 Mon Sep 17 00:00:00 2001 From: rgalbo Date: Fri, 23 Aug 2019 20:17:47 -0400 Subject: [PATCH 03/21] add simple test script, example file for api key storage and update readme --- README.md | 80 ++++++++++++------------------- __pycache__/bybit.cpython-37.pyc | Bin 4588 -> 0 bytes bybit.py | 6 +-- bybit_test.py | 7 ++- key_example.sh | 2 + 5 files changed, 39 insertions(+), 56 deletions(-) delete mode 100644 __pycache__/bybit.cpython-37.pyc create mode 100644 key_example.sh diff --git a/README.md b/README.md index b44f324..824a2a4 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,8 @@ -# bybit-exchange-python-sdk -This is an unofficial Bybit Exchange API python implementation for automated trading. Find the documentation [here](https://bybit-exchange.github.io/bybit-official-api-docs/en/index.html). +bybit-exchange-python-sdk +========================= +This is an unofficial Bybit Exchange API python implementation for automated trading. [API Documentation](https://bybit-exchange.github.io/bybit-official-api-docs/en/index.html). Features -------- @@ -12,7 +13,6 @@ Features - Response exception handling - Historical Kline/Candle fetching function - Quick Start ----------- @@ -20,61 +20,41 @@ To register an account with Bybit [Click here](https://www.bybit.com/app/registe To Generate an API Key and assign relevant permissions [Click here](https://www.bybit.com/app/user/api-management) -**Terminal Installation** - - pip install bybit - - -**Python** - - from bybit import Bybit - client = Client(api_key, api_secret) - - # get exchange symbols - depth = Bybit().get_symbols() - - - # get all symbol prices - prices = Bybit().get_klines('BTCUSD', '15', '1563367231') - - - # Create Market Buy Orders - auth = Bybit().auth(key, secret) - prices = buy('BTCUSD', 9550, 1.000) - - - - - # Create Market Sell Orders - auth = Bybit().auth(key, secret) - prices = buy('BTCUSD', 9550, 1.000) - - +Installation +------------ +`$ pip install .` - - # Create Market Buy Limit Orders - auth = Bybit().auth(key, secret) - prices = buy('BTCUSD', 9550, 1.000) +or for development purposes - +`$ python setup.py develop` - - # Create Market Sell Limit Orders - auth = Bybit().auth(key, secret) - prices = buy('BTCUSD', 9550, 1.000) +KEY Env Variables +----------------- +``` +$ vi key_example.sh # add your api key from bybit in the parenthesis +$ mv key_example.sh key.sh +$ bash key.sh # if this doesnt work, copy paste the two lines to your terminal +``` - +```python +import os +from bybit import Bybit - - # Cancelling an order - auth = Bybit().auth(key, secret) - prices = cancel_order(order_id) - +KEY = os.environ['BTKEY'] +SECRET = os.environ['BTSECRET'] +bt = Bybit() +bt.(api_key, api_secret) +# get exchange symbols +depth = bt.get_symbols() +# get all symbol prices +prices = bt.get_klines('BTCUSD', '15', '1563367231') -For more check out the documentation +# Create Market Buy Orders +prices = bt.buy('BTCUSD', 9550, 1.000) +``` - https://bybit-exchange.github.io/bybit-official-api-docs/en/index.html +check out the [documentation](https://bybit-exchange.github.io/bybit-official-api-docs/en/index.html)! diff --git a/__pycache__/bybit.cpython-37.pyc b/__pycache__/bybit.cpython-37.pyc deleted file mode 100644 index cea7b00fe38dc3a84b817f6442e063eb7c8f0283..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4588 zcmcgvOLN=S6~@JjAVunBMY0{+Vbat#+e(a6H_mt*$Fi)*PHb7VlsM*$hlO|{5)=qh z7nhF70liVCkA*W`blHWp>`ebh`x~(Brv3|B^*a|7^{5wJq#=jrT;RUW^E-!k3x%A9 z&p$f9d+tnW+P~=G@MBb(}Q*oIq-3Qp1%t|!7uQO;FJ6k z_j)qWw+xmY|^WRTDw(#@o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YT6h9-9Cbt5a zibGOVJ8myw+m$Tc2#{!XD$Z6n2ox0jlD1G{it9u^B=U126xJzG2t1xf{2?Ator`FP zW|+)mdBp!!pur5w=?*=!aptf|eG;=eb4;C01FC27?gEw3A!eLBa#ZBVS!5T58H72A zKjaJI91Ykxs_bU}{E8=wZV(isUTd=*L`6R=%7#~5Tzep{VM~9AU*+LEN}(5Z1Bt3~ z8Pi~@_McL6Ol59*;$tjJ`w_iAbu6#b*->KC33Sv~w4AJhM9`_AAT_9_=1@WP z0I{`?9#AP^_1}jQlEBO@!d=p@bpuxvYp9M_qT)76tcT9UPBlmz1dS(NxIx9-675#1 z~NkNQKR5rz@ya zXGiPUHiWu7!TvF*OBamXN9_VKEwxA<11h=Ph}jQm&old&I*8(u@LVco#r1BdgD4f$ z(;Up8mc4-7WmWLY=+p3kCV?i!G6+2P8L_l)c&pU;bXQd!@eGR(-8h}P@%Z$}j}&kt zfL4B_Mgh$wfSAR`E(6tf8T3GBM_v4D#_iV`1Y@Q@_sA97h{wC#9(l991&5Ls69aD& zJDp9&SK4j9;RnHz8`iww4Mh&LnI)DHcfinB`&7Fnn&-sWkv&z~YhF^I%tfC}%|Oi) zRE$xuz5o+9h^QClF(f2{!TWNabN8PZK|i z&a)5wmjB-oAXac|VyVfWRAmRwRJYbos6G5+bvXHdRs9J$VS~s|>FX@HRB0ZZ(0n3| z@zLz4LnXK(09Vz9+O)%JgD%xTdK>-e6tHS4Z36{b3Xl5vAxNo-lfYDQ)ExdIoesu) zdQOT?J0v4Xpy~ZXbW*3K)A-*l2ue#+^glU7BV4T}xoQ>7Za1KDzFOVsx Date: Fri, 23 Aug 2019 20:22:45 -0400 Subject: [PATCH 04/21] rewrite test_bybit.py to match pytest standards --- bybit_test.py | 19 ------------------- test_bybit.py | 13 +++++++++++++ 2 files changed, 13 insertions(+), 19 deletions(-) delete mode 100644 bybit_test.py create mode 100644 test_bybit.py diff --git a/bybit_test.py b/bybit_test.py deleted file mode 100644 index 9c9b633..0000000 --- a/bybit_test.py +++ /dev/null @@ -1,19 +0,0 @@ -import os -from bybit import Bybit - -KEY = os.environ['BTKEY'] -SECRET = os.environ['BTSECRET'] - - -def test_connection(): - bt = Bybit() - bt.auth(KEY, SECRET) - return bt - -def test_get_symbols(bt): - assert bt.get_symbols().status == 200 - - -if __name__ == "__main__": - - bt = test_connection() diff --git a/test_bybit.py b/test_bybit.py new file mode 100644 index 0000000..cc7c66e --- /dev/null +++ b/test_bybit.py @@ -0,0 +1,13 @@ +import pytest +import os +from bybit import Bybit + +KEY = os.environ['BTKEY'] +SECRET = os.environ['BTSECRET'] + +bt = Bybit() +bt.auth(KEY, SECRET) + + +def test_get_symbols(bt): + assert bt.get_symbols().status == 200 \ No newline at end of file From 0884d090e5726aa071c1532500f67a9425af96ba Mon Sep 17 00:00:00 2001 From: rgalbo Date: Fri, 23 Aug 2019 20:43:50 -0400 Subject: [PATCH 05/21] fix pytest create working test for --- test_bybit.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test_bybit.py b/test_bybit.py index cc7c66e..bd92b54 100644 --- a/test_bybit.py +++ b/test_bybit.py @@ -8,6 +8,7 @@ bt = Bybit() bt.auth(KEY, SECRET) - +@pytest.mark.parametrize("bt",[(bt)]) def test_get_symbols(bt): - assert bt.get_symbols().status == 200 \ No newline at end of file + assert len(bt.get_symbols()) > 0 + \ No newline at end of file From e70c3fb6d7cf4900de759969af62523ecc9aa4ff Mon Sep 17 00:00:00 2001 From: rgalbo Date: Fri, 23 Aug 2019 20:46:27 -0400 Subject: [PATCH 06/21] fix readme heading --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 824a2a4..538e41c 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,3 @@ - bybit-exchange-python-sdk ========================= @@ -36,6 +35,9 @@ $ mv key_example.sh key.sh $ bash key.sh # if this doesnt work, copy paste the two lines to your terminal ``` +API Usage Examples +------------------ + ```python import os from bybit import Bybit From 3bf39b56a62162a9e81fc23551c02be932de11ee Mon Sep 17 00:00:00 2001 From: rgalbo Date: Fri, 23 Aug 2019 21:12:07 -0400 Subject: [PATCH 07/21] add file --- .travis.yml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..0d99644 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,7 @@ +language: python +python: + -"3.7.4" +install: + - python setup.py install +script: + - pytest From a7d52d5208e73f114cfe416eae0b364c2f87ebbd Mon Sep 17 00:00:00 2001 From: rgalbo Date: Fri, 23 Aug 2019 21:16:17 -0400 Subject: [PATCH 08/21] fix python version 3.7 in travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 0d99644..5ddbed6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: python python: - -"3.7.4" + -"3.7" install: - python setup.py install script: From 582fb7edd2c510e232ad2daec58bbca6897447eb Mon Sep 17 00:00:00 2001 From: rgalbo Date: Fri, 23 Aug 2019 21:21:50 -0400 Subject: [PATCH 09/21] fix python version 3.7 in travis ~ again ~ --- .travis.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5ddbed6..1031a15 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ -language: python -python: - -"3.7" -install: - - python setup.py install -script: - - pytest +- os: windows + language: sh + python: "3.7" + before_install: + - choco install python3 + - export PATH="/c/Python37:/c/Python37/Scripts:$PATH" + - python -m pip install --upgrade pip wheel From 0e4d8a490a75a1444437c6cd538c223335956489 Mon Sep 17 00:00:00 2001 From: rgalbo Date: Fri, 23 Aug 2019 21:33:47 -0400 Subject: [PATCH 10/21] fix fucking travis fuck fuck fuck --- .travis.yml | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1031a15..b849e10 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,12 @@ -- os: windows - language: sh - python: "3.7" - before_install: - - choco install python3 - - export PATH="/c/Python37:/c/Python37/Scripts:$PATH" - - python -m pip install --upgrade pip wheel +language: python +python: + - "2.6" + - "2.7" + - "3.2" + - "3.3" + - "3.7" +# command to install dependencies +script: pytest test_bybit.py +branches: + only: + - master \ No newline at end of file From 18c1581a76358daeb307a8087aae995018aeb426 Mon Sep 17 00:00:00 2001 From: rgalbo Date: Sat, 24 Aug 2019 10:53:06 -0400 Subject: [PATCH 11/21] abort travis, clean up --- .travis.yml | 12 ------------ README.md | 2 +- test_bybit.py | 5 ++++- 3 files changed, 5 insertions(+), 14 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index b849e10..0000000 --- a/.travis.yml +++ /dev/null @@ -1,12 +0,0 @@ -language: python -python: - - "2.6" - - "2.7" - - "3.2" - - "3.3" - - "3.7" -# command to install dependencies -script: pytest test_bybit.py -branches: - only: - - master \ No newline at end of file diff --git a/README.md b/README.md index 538e41c..1af506e 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ KEY Env Variables ----------------- ``` $ vi key_example.sh # add your api key from bybit in the parenthesis -$ mv key_example.sh key.sh +$ cp key_example.sh key.sh $ bash key.sh # if this doesnt work, copy paste the two lines to your terminal ``` diff --git a/test_bybit.py b/test_bybit.py index bd92b54..591d2a0 100644 --- a/test_bybit.py +++ b/test_bybit.py @@ -11,4 +11,7 @@ @pytest.mark.parametrize("bt",[(bt)]) def test_get_symbols(bt): assert len(bt.get_symbols()) > 0 - \ No newline at end of file + +@pytest.mark.parametrize("bt",[(bt)]) +def test_get_klines(bt): + print bt.get_klines('BTCUSD', in) \ No newline at end of file From f638fa68235c4c4b785ce01a731396da3f8d26ec Mon Sep 17 00:00:00 2001 From: rgalbo Date: Sat, 24 Aug 2019 16:16:34 -0400 Subject: [PATCH 12/21] fix test and add circleci config --- .circleci/config.yml | 8 ++++ bybit.egg-info/PKG-INFO | 82 ++++++++++++++++------------------------- test_bybit.py | 7 +++- 3 files changed, 46 insertions(+), 51 deletions(-) create mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..8fc0155 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,8 @@ +version: 2 +jobs: + build: + docker: + - image: python/3.7-alpine + steps: + - checkout + - run: python setup.py develop \ No newline at end of file diff --git a/bybit.egg-info/PKG-INFO b/bybit.egg-info/PKG-INFO index 0548f71..2f6dddd 100644 --- a/bybit.egg-info/PKG-INFO +++ b/bybit.egg-info/PKG-INFO @@ -6,10 +6,10 @@ Home-page: https://github.com/m-root/bybit-exchange-python-sdk Author: Muemrga Author-email: hi@ssi.co.ke License: UNKNOWN -Description: - # bybit-exchange-python-sdk - This is an unofficial Bybit Exchange API python implementation for automated trading. Find the documentation [here](https://bybit-exchange.github.io/bybit-official-api-docs/en/index.html). +Description: bybit-exchange-python-sdk + ========================= + This is an unofficial Bybit Exchange API python implementation for automated trading. [API Documentation](https://bybit-exchange.github.io/bybit-official-api-docs/en/index.html). Features -------- @@ -20,7 +20,6 @@ Description: - Response exception handling - Historical Kline/Candle fetching function - Quick Start ----------- @@ -28,63 +27,46 @@ Description: To Generate an API Key and assign relevant permissions [Click here](https://www.bybit.com/app/user/api-management) - **Terminal Installation** - - pip install bybit - - - **Python** - - from bybit import Bybit - client = Client(api_key, api_secret) - - # get exchange symbols - depth = Bybit().get_symbols() - - - # get all symbol prices - prices = Bybit().get_klines('BTCUSD', '15', '1563367231') - - - # Create Market Buy Orders - auth = Bybit().auth(key, secret) - prices = buy('BTCUSD', 9550, 1.000) - - - - - # Create Market Sell Orders - auth = Bybit().auth(key, secret) - prices = buy('BTCUSD', 9550, 1.000) + Installation + ------------ + `$ pip install .` - + or for development purposes - - # Create Market Buy Limit Orders - auth = Bybit().auth(key, secret) - prices = buy('BTCUSD', 9550, 1.000) + `$ python setup.py develop` - + KEY Env Variables + ----------------- + ``` + $ vi key_example.sh # add your api key from bybit in the parenthesis + $ cp key_example.sh key.sh + $ bash key.sh # if this doesnt work, copy paste the two lines to your terminal + ``` - - # Create Market Sell Limit Orders - auth = Bybit().auth(key, secret) - prices = buy('BTCUSD', 9550, 1.000) + API Usage Examples + ------------------ - + ```python + import os + from bybit import Bybit - - # Cancelling an order - auth = Bybit().auth(key, secret) - prices = cancel_order(order_id) - + KEY = os.environ['BTKEY'] + SECRET = os.environ['BTSECRET'] + bt = Bybit() + bt.(api_key, api_secret) + # get exchange symbols + depth = bt.get_symbols() + # get all symbol prices + prices = bt.get_klines('BTCUSD', '15', '1563367231') - For more check out the documentation + # Create Market Buy Orders + prices = bt.buy('BTCUSD', 9550, 1.000) + ``` - https://bybit-exchange.github.io/bybit-official-api-docs/en/index.html + check out the [documentation](https://bybit-exchange.github.io/bybit-official-api-docs/en/index.html)! Platform: UNKNOWN diff --git a/test_bybit.py b/test_bybit.py index 591d2a0..aacb70c 100644 --- a/test_bybit.py +++ b/test_bybit.py @@ -14,4 +14,9 @@ def test_get_symbols(bt): @pytest.mark.parametrize("bt",[(bt)]) def test_get_klines(bt): - print bt.get_klines('BTCUSD', in) \ No newline at end of file + klines = bt.get_klines('BTCUSD', '15', '1563367231') + print(klines) + print(f'len klines: {len(klines)}') + +if __name__ == "__main__": + test_get_klines(bt) \ No newline at end of file From 9fe1ba40633185c2eaf189a7ea9d6c7953ae7786 Mon Sep 17 00:00:00 2001 From: rgalbo Date: Sat, 24 Aug 2019 16:20:57 -0400 Subject: [PATCH 13/21] ammend circle ci and add requirements.txt --- .circleci/config.yml | 4 ++-- requirements.txt | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 requirements.txt diff --git a/.circleci/config.yml b/.circleci/config.yml index 8fc0155..3c30db0 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -2,7 +2,7 @@ version: 2 jobs: build: docker: - - image: python/3.7-alpine + - image: circleci/python:3.7.4-stretch steps: - checkout - - run: python setup.py develop \ No newline at end of file + - run: pip install -r requirements.txt \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..085efe9 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,39 @@ +appdirs==1.4.3 +atomicwrites==1.3.0 +attrs==19.1.0 +backcall==0.1.0 +black==19.3b0 +-e git+https://github.com/rgalbo/bybit-exchange-python-sdk@f638fa68235c4c4b785ce01a731396da3f8d26ec#egg=bybit +certifi==2019.6.16 +chardet==3.0.4 +Click==7.0 +decorator==4.4.0 +idna==2.8 +importlib-metadata==0.19 +influxdb==5.2.2 +ipython==7.7.0 +ipython-genutils==0.2.0 +ipython-pytest==0.0.1 +jedi==0.15.1 +more-itertools==7.2.0 +packaging==19.1 +parso==0.5.1 +pexpect==4.7.0 +pickleshare==0.7.5 +pluggy==0.12.0 +prompt-toolkit==2.0.9 +ptyprocess==0.6.0 +py==1.8.0 +Pygments==2.4.2 +pyparsing==2.4.2 +pytest==5.1.1 +python-dateutil==2.8.0 +pytz==2019.2 +requests==2.22.0 +six==1.12.0 +toml==0.10.0 +traitlets==4.3.2 +urllib3==1.25.3 +wcwidth==0.1.7 +websockets==8.0.2 +zipp==0.5.2 From ac8febc0373d364a34af1e5190ed8ee1aa8ffd62 Mon Sep 17 00:00:00 2001 From: rgalbo Date: Sat, 24 Aug 2019 16:23:57 -0400 Subject: [PATCH 14/21] add proper install line --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 3c30db0..3eedae3 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -5,4 +5,4 @@ jobs: - image: circleci/python:3.7.4-stretch steps: - checkout - - run: pip install -r requirements.txt \ No newline at end of file + - run: pip install . \ No newline at end of file From 4ef43f16ac57a85b35f1dec1205c2572ebba1967 Mon Sep 17 00:00:00 2001 From: rgalbo Date: Sat, 24 Aug 2019 16:25:57 -0400 Subject: [PATCH 15/21] add to pip install for circle --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 3eedae3..aff6d7c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -5,4 +5,4 @@ jobs: - image: circleci/python:3.7.4-stretch steps: - checkout - - run: pip install . \ No newline at end of file + - run: pip install . -U From f6fd0aa619ad76493bdc54846b60287d5badb3be Mon Sep 17 00:00:00 2001 From: rgalbo Date: Sat, 24 Aug 2019 16:26:55 -0400 Subject: [PATCH 16/21] .. x2 --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index aff6d7c..06bc309 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -5,4 +5,4 @@ jobs: - image: circleci/python:3.7.4-stretch steps: - checkout - - run: pip install . -U + - run: pip install --user . From e659e5ea6dfe5eb01c1f24db5408fc565b22b764 Mon Sep 17 00:00:00 2001 From: rgalbo Date: Sat, 24 Aug 2019 16:29:53 -0400 Subject: [PATCH 17/21] add parallelism for faster circleci --- .circleci/config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 06bc309..6d5a2da 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -6,3 +6,4 @@ jobs: steps: - checkout - run: pip install --user . + parallelism: 4 From 03aa19b8193d4b37e662b2c0c5314b50a2ce9759 Mon Sep 17 00:00:00 2001 From: rgalbo Date: Sat, 24 Aug 2019 16:34:28 -0400 Subject: [PATCH 18/21] add circleci badge to readme --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 1af506e..7073ef6 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ bybit-exchange-python-sdk ========================= +[![CircleCI](https://circleci.com/gh/rgalbo/bybit-exchange-python-sdk.svg?style=svg)](https://circleci.com/gh/rgalbo/bybit-exchange-python-sdk) + This is an unofficial Bybit Exchange API python implementation for automated trading. [API Documentation](https://bybit-exchange.github.io/bybit-official-api-docs/en/index.html). Features From 8b9fb4c4bec0b0b6bcf7fe3253570d48c6b61b19 Mon Sep 17 00:00:00 2001 From: rgalbo Date: Fri, 30 Aug 2019 15:40:28 -0400 Subject: [PATCH 19/21] redo env addition, rework readme examples --- .gitignore | 4 +++- .vscode/settings.json | 4 ---- README.md | 34 +++++++++++++++++++++++++++++++--- bybit.egg-info/PKG-INFO | 36 +++++++++++++++++++++++++++++++++--- key_example.py | 0 key_example.sh | 2 -- requirements.txt | 1 - setup.py | 2 +- 8 files changed, 68 insertions(+), 15 deletions(-) delete mode 100644 .vscode/settings.json create mode 100644 key_example.py delete mode 100644 key_example.sh diff --git a/.gitignore b/.gitignore index 95e9cbc..b48b549 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ key.sh __pycache__ .vscode -*.egg-info +bybit.egg-info .pytest_cache +.ipynb_checkpoints +key.sh diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 7b545ec..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "python.formatting.provider": "black", - "python.pythonPath": "/home/rgalbo/.virtualenvs/bt/bin/python" -} \ No newline at end of file diff --git a/README.md b/README.md index 7073ef6..205cfa7 100644 --- a/README.md +++ b/README.md @@ -25,16 +25,44 @@ Installation ------------ `$ pip install .` -or for development purposes +or for my purposes: -`$ python setup.py develop` +``` +pyenv local 3.7.4 +mkvirtualenv futures +workon futures +pip install -r requirements.txt +cd bybit +python -m pip install -e . +cd .. +jupyter lab +``` KEY Env Variables ----------------- ``` $ vi key_example.sh # add your api key from bybit in the parenthesis $ cp key_example.sh key.sh -$ bash key.sh # if this doesnt work, copy paste the two lines to your terminal +$ source key.sh # if this doesnt work, copy paste the two lines to your terminal +``` + +alternatively, in the disgust of all other failure you are likely to ask to just please god fucking hell make jupyter environments stop and run(see [jvp](https://jakevdp.github.io/blog/2017/12/05/installing-python-packages-from-jupyter/)): + +for ipython: + +```ipython +# follows conveintion %set_env var val: +%set_env BTKEY '[your_key_here]' +%set_env BTSECRET '[your_secret_here]' +``` + +for last resort, (key.py): + +```python +import sys,os,os.path +sys.path.append(os.path.expanduser('~/code/eol_hsrl_python')) +os.environ['HSRL_INSTRUMENT']='gvhsrl' +os.environ['HSRL_CONFIG']=os.path.expanduser('~/hsrl_config') ``` API Usage Examples diff --git a/bybit.egg-info/PKG-INFO b/bybit.egg-info/PKG-INFO index 2f6dddd..068216e 100644 --- a/bybit.egg-info/PKG-INFO +++ b/bybit.egg-info/PKG-INFO @@ -9,6 +9,8 @@ License: UNKNOWN Description: bybit-exchange-python-sdk ========================= + [![CircleCI](https://circleci.com/gh/rgalbo/bybit-exchange-python-sdk.svg?style=svg)](https://circleci.com/gh/rgalbo/bybit-exchange-python-sdk) + This is an unofficial Bybit Exchange API python implementation for automated trading. [API Documentation](https://bybit-exchange.github.io/bybit-official-api-docs/en/index.html). Features @@ -31,16 +33,44 @@ Description: bybit-exchange-python-sdk ------------ `$ pip install .` - or for development purposes + or for my purposes: - `$ python setup.py develop` + ``` + pyenv local 3.7.4 + mkvirtualenv futures + workon futures + pip install -r requirements.txt + cd bybit + python -m pip install -e . + cd .. + jupyter lab + ``` KEY Env Variables ----------------- ``` $ vi key_example.sh # add your api key from bybit in the parenthesis $ cp key_example.sh key.sh - $ bash key.sh # if this doesnt work, copy paste the two lines to your terminal + $ source key.sh # if this doesnt work, copy paste the two lines to your terminal + ``` + + alternatively, in the disgust of all other failure you are likely to ask to just please god fucking hell make jupyter environments stop and run(see [jvp](https://jakevdp.github.io/blog/2017/12/05/installing-python-packages-from-jupyter/)): + + for ipython: + + ```ipython + # follows conveintion %set_env var val: + %set_env BTKEY '[your_key_here]' + %set_env BTSECRET '[your_secret_here]' + ``` + + for last resort, (key.py): + + ```python + import sys,os,os.path + sys.path.append(os.path.expanduser('~/code/eol_hsrl_python')) + os.environ['HSRL_INSTRUMENT']='gvhsrl' + os.environ['HSRL_CONFIG']=os.path.expanduser('~/hsrl_config') ``` API Usage Examples diff --git a/key_example.py b/key_example.py new file mode 100644 index 0000000..e69de29 diff --git a/key_example.sh b/key_example.sh deleted file mode 100644 index e75cdee..0000000 --- a/key_example.sh +++ /dev/null @@ -1,2 +0,0 @@ -export BTKEY="" -export BTSECRET="" \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 085efe9..fb479be 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,7 +3,6 @@ atomicwrites==1.3.0 attrs==19.1.0 backcall==0.1.0 black==19.3b0 --e git+https://github.com/rgalbo/bybit-exchange-python-sdk@f638fa68235c4c4b785ce01a731396da3f8d26ec#egg=bybit certifi==2019.6.16 chardet==3.0.4 Click==7.0 diff --git a/setup.py b/setup.py index 7b075e9..7cf6a20 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ class keyadd(sdist_orig): def run(self): try: - self.spawn(['bash', 'key.sh']) + self.spawn(['source', 'key.sh']) except: self.warn('adding key env variables failed') super().run() From 317d528a232209c8bcf481fbad48db4a289d37d5 Mon Sep 17 00:00:00 2001 From: rgalbo Date: Fri, 30 Aug 2019 15:42:03 -0400 Subject: [PATCH 20/21] remove bybit egginfo --- bybit.egg-info/PKG-INFO | 106 ---------------------------- bybit.egg-info/SOURCES.txt | 6 -- bybit.egg-info/dependency_links.txt | 1 - bybit.egg-info/top_level.txt | 1 - 4 files changed, 114 deletions(-) delete mode 100644 bybit.egg-info/PKG-INFO delete mode 100644 bybit.egg-info/SOURCES.txt delete mode 100644 bybit.egg-info/dependency_links.txt delete mode 100644 bybit.egg-info/top_level.txt diff --git a/bybit.egg-info/PKG-INFO b/bybit.egg-info/PKG-INFO deleted file mode 100644 index 068216e..0000000 --- a/bybit.egg-info/PKG-INFO +++ /dev/null @@ -1,106 +0,0 @@ -Metadata-Version: 2.1 -Name: bybit -Version: 0.0.1 -Summary: unofficial Bybit Exchange API python implementation for automated trading -Home-page: https://github.com/m-root/bybit-exchange-python-sdk -Author: Muemrga -Author-email: hi@ssi.co.ke -License: UNKNOWN -Description: bybit-exchange-python-sdk - ========================= - - [![CircleCI](https://circleci.com/gh/rgalbo/bybit-exchange-python-sdk.svg?style=svg)](https://circleci.com/gh/rgalbo/bybit-exchange-python-sdk) - - This is an unofficial Bybit Exchange API python implementation for automated trading. [API Documentation](https://bybit-exchange.github.io/bybit-official-api-docs/en/index.html). - - Features - -------- - - - Implementation of all General, Market Data and Account endpoints. - - Simple handling of authentication - - No need to generate timestamps yourself, the wrapper does it for you - - Response exception handling - - Historical Kline/Candle fetching function - - Quick Start - ----------- - - To register an account with Bybit [Click here](https://www.bybit.com/app/register?ref=00xv5) - - To Generate an API Key and assign relevant permissions [Click here](https://www.bybit.com/app/user/api-management) - - Installation - ------------ - `$ pip install .` - - or for my purposes: - - ``` - pyenv local 3.7.4 - mkvirtualenv futures - workon futures - pip install -r requirements.txt - cd bybit - python -m pip install -e . - cd .. - jupyter lab - ``` - - KEY Env Variables - ----------------- - ``` - $ vi key_example.sh # add your api key from bybit in the parenthesis - $ cp key_example.sh key.sh - $ source key.sh # if this doesnt work, copy paste the two lines to your terminal - ``` - - alternatively, in the disgust of all other failure you are likely to ask to just please god fucking hell make jupyter environments stop and run(see [jvp](https://jakevdp.github.io/blog/2017/12/05/installing-python-packages-from-jupyter/)): - - for ipython: - - ```ipython - # follows conveintion %set_env var val: - %set_env BTKEY '[your_key_here]' - %set_env BTSECRET '[your_secret_here]' - ``` - - for last resort, (key.py): - - ```python - import sys,os,os.path - sys.path.append(os.path.expanduser('~/code/eol_hsrl_python')) - os.environ['HSRL_INSTRUMENT']='gvhsrl' - os.environ['HSRL_CONFIG']=os.path.expanduser('~/hsrl_config') - ``` - - API Usage Examples - ------------------ - - ```python - import os - from bybit import Bybit - - KEY = os.environ['BTKEY'] - SECRET = os.environ['BTSECRET'] - - bt = Bybit() - bt.(api_key, api_secret) - - # get exchange symbols - depth = bt.get_symbols() - - # get all symbol prices - prices = bt.get_klines('BTCUSD', '15', '1563367231') - - # Create Market Buy Orders - prices = bt.buy('BTCUSD', 9550, 1.000) - ``` - - check out the [documentation](https://bybit-exchange.github.io/bybit-official-api-docs/en/index.html)! - - -Platform: UNKNOWN -Classifier: Programming Language :: Python :: 3 -Classifier: License :: GNU GENERAL PUBLIC LICENSE -Classifier: Operating System :: OS Independent -Description-Content-Type: text/markdown diff --git a/bybit.egg-info/SOURCES.txt b/bybit.egg-info/SOURCES.txt deleted file mode 100644 index 4a7954e..0000000 --- a/bybit.egg-info/SOURCES.txt +++ /dev/null @@ -1,6 +0,0 @@ -README.md -setup.py -bybit.egg-info/PKG-INFO -bybit.egg-info/SOURCES.txt -bybit.egg-info/dependency_links.txt -bybit.egg-info/top_level.txt \ No newline at end of file diff --git a/bybit.egg-info/dependency_links.txt b/bybit.egg-info/dependency_links.txt deleted file mode 100644 index 8b13789..0000000 --- a/bybit.egg-info/dependency_links.txt +++ /dev/null @@ -1 +0,0 @@ - diff --git a/bybit.egg-info/top_level.txt b/bybit.egg-info/top_level.txt deleted file mode 100644 index 8b13789..0000000 --- a/bybit.egg-info/top_level.txt +++ /dev/null @@ -1 +0,0 @@ - From e0228e9220cfee4fdc2a5978fb21c8f1c718f22d Mon Sep 17 00:00:00 2001 From: rgalbo Date: Fri, 30 Aug 2019 15:43:21 -0400 Subject: [PATCH 21/21] update readme example --- .gitignore | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index b48b549..2beae2c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,7 @@ key.sh __pycache__ .vscode -bybit.egg-info +*.egg-info .pytest_cache .ipynb_checkpoints key.sh diff --git a/README.md b/README.md index 205cfa7..940f5e5 100644 --- a/README.md +++ b/README.md @@ -85,7 +85,7 @@ depth = bt.get_symbols() prices = bt.get_klines('BTCUSD', '15', '1563367231') # Create Market Buy Orders -prices = bt.buy('BTCUSD', 9550, 1.000) +orders = bt.buy('BTCUSD', 9550, 1.000) ``` check out the [documentation](https://bybit-exchange.github.io/bybit-official-api-docs/en/index.html)!