Skip to content

[feature] config credentials, order_cancel_all(side) #55

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,6 @@ dmypy.json

# vscode settings
.vscode/

# jetbrains settings
.idea
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,26 @@ git clone https://github.com/uJhin/upbit-client.git


### Quick Start
#### Credentials
```shell
mkdir -p ~/.upbit
```
```
# vi ~/.upbit/credentials

[default]
access_key = a
secret_key = b

[a]
access_key = c
secret_key = d
```
```python
client = Upbit() # default
client = Upbit(profile="a")
```

#### REST Client
- Check Your API Keys
```python
Expand Down Expand Up @@ -174,3 +194,15 @@ event_loop.run_until_complete( ticker(sock, payload) )
<br/>
<img alt="uJhin's ETH" src="https://img.shields.io/badge/ETH-0x60dd373f59862d9df776596889b997e24bee42eb-blue?style=flat-square&logo=ethereum">
</div>

### Contributor
```shell
deactivate

rm -rf venv

python3 -m venv venv
source venv/bin/activate

pip3 install -r client/python/requirements.txt
```
5 changes: 3 additions & 2 deletions client/python/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
astroid==2.5
astroid==2.11
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ERROR: Cannot install -r client/python/requirements.txt (line 24) and astroid==2.5 because these package versions have conflicting dependencies.

The conflict is caused by:
    The user requested astroid==2.5
    pylint 2.13.0 depends on astroid<=2.12.0-dev0 and >=2.11.0

attrs==20.3.0
bleach==3.3.0
bravado==11.0.2
Expand All @@ -7,7 +7,7 @@ certifi==2022.12.7
chardet==4.0.0
colorama==0.4.4
docutils==0.16
idna==3.1
idna==2.5
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ERROR: Cannot install -r client/python/requirements.txt (line 32) and idna==3.1 because these package versions have conflicting dependencies.

The conflict is caused by:
    The user requested idna==3.1
    requests 2.25.1 depends on idna<3 and >=2.5

isort==5.7.0
jsonpointer==2.0
jsonref==0.2
Expand Down Expand Up @@ -46,3 +46,4 @@ webcolors==1.11.1
webencodings==0.5.1
websockets==10.1
wrapt==1.12.1
seunggabi_core_python
10 changes: 10 additions & 0 deletions client/python/upbit/client.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

from . import models
from seunggabi_core_python.util.config_util import Config


class Upbit:
Expand All @@ -22,8 +23,17 @@ def __init__(
self,
access_key: str = None,
secret_key: str = None,
profile: str = None,
**kwargs
):
if access_key is None and secret_key is None:
credentials = Config.get(
group="upbit",
context="credentials",
profile=profile
)
access_key = credentials["access_key"]
secret_key = credentials["secret_key"]

self.__client = models.ClientModel(
access_key=access_key,
Expand Down
28 changes: 28 additions & 0 deletions client/python/upbit/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,34 @@ def Order_cancel(self, **kwargs) -> dict:
future = self.__client.Order.Order_cancel(**kwargs)
return HTTPFutureExtractor.future_extraction(future)

def Order_cancel_all(self, side: str = None) -> dict:
args = {
"state": "wait"
}

result = []
while True:
waits = HTTPFutureExtractor.future_extraction(
self.__client.Order.Order_info_all(**args)
)["result"]

if len(waits) == 0:
break

for w in waits:
if side and w["side"] != side:
continue

HTTPFutureExtractor.future_extraction(
self.__client.Order.Order_cancel(uuid=w["uuid"])
)

result.append(w)

return {
"result": result
}


class Trade:
"""
Expand Down