Skip to content

Commit

Permalink
Merge pull request #17 from acontry/style-black
Browse files Browse the repository at this point in the history
Add pre-commit
  • Loading branch information
acontry authored Jan 8, 2021
2 parents 8b3d4cb + c0207ff commit f68cb62
Show file tree
Hide file tree
Showing 17 changed files with 544 additions and 451 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/pre-commit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: pre-commit

on:
pull_request:
push:
branches: [master]

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: pre-commit/[email protected]
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ build/
dist
coinbasepro.egg-info/

__pycache__/
__pycache__/
11 changes: 11 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- repo: https://github.com/psf/black
rev: 19.10b0
hooks:
- id: black
4 changes: 2 additions & 2 deletions AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* khoo-j

## Acknowledgements
This package was derived from:
This package was derived from:

###GDAX-Python

Expand All @@ -25,4 +25,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
SOFTWARE.
4 changes: 2 additions & 2 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ dev

**Improvements**

- Added rate-limiting to all public and authenticated endpoints. Dropping support for Python 3.4 to keep the implemenation simple.
- Added rate-limiting to all public and authenticated endpoints. Dropping support for Python 3.4 to keep the implementation simple.

0.1.1 (2019-07-23)
++++++++++++++++++
Expand Down Expand Up @@ -101,4 +101,4 @@ dev
0.0.1 (2018-06-27)
+++++++++++++++++++

- Hello world.
- Hello world.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
SOFTWARE.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ publish:
twine upload dist/*
rm -rf build dist .egg coinbasepro.egg-info

.PHONY: init publish
.PHONY: init publish
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ Features
# This call throws a BadRequest exception
>>> auth_client.get_order('invalid_order_num')
coinbasepro.exceptions.BadRequest: Invalid order id
# CoinbaseAPIError is the parent exception for all exceptions the API
# throws, so catching this will catch anything
>>> try:
Expand All @@ -120,4 +120,4 @@ Installation

.. code-block:: bash
$ pip install coinbasepro
$ pip install coinbasepro
Binary file added coinbasepro/.DS_Store
Binary file not shown.
22 changes: 12 additions & 10 deletions coinbasepro/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,26 @@ class CoinbaseProAuth(AuthBase):
Provided by Coinbase Pro:
https://docs.pro.coinbase.com/?python#signing-a-message
"""

def __init__(self, api_key, secret_key, passphrase):
self.api_key = api_key
self.secret_key = secret_key
self.passphrase = passphrase

def __call__(self, request):
timestamp = str(time.time())
message = (timestamp + request.method + request.path_url +
(request.body or ''))
message = message.encode('ascii')
message = timestamp + request.method + request.path_url + (request.body or "")
message = message.encode("ascii")
hmac_key = base64.b64decode(self.secret_key)
signature = hmac.new(hmac_key, message, hashlib.sha256)
signature_b64 = base64.b64encode(signature.digest())
request.headers.update({
'CB-ACCESS-SIGN': signature_b64,
'CB-ACCESS-TIMESTAMP': timestamp,
'CB-ACCESS-KEY': self.api_key,
'CB-ACCESS-PASSPHRASE': self.passphrase,
'Content-Type': 'application/json'
})
request.headers.update(
{
"CB-ACCESS-SIGN": signature_b64,
"CB-ACCESS-TIMESTAMP": timestamp,
"CB-ACCESS-KEY": self.api_key,
"CB-ACCESS-PASSPHRASE": self.passphrase,
"Content-Type": "application/json",
}
)
return request
Loading

0 comments on commit f68cb62

Please sign in to comment.