Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
/.idea/
/aster-connector-python.iml

*.pyc
9 changes: 8 additions & 1 deletion examples/rest_api/data_stream_listen_key/new_listen_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,17 @@
import logging
from aster.rest_api import Client
from aster.lib.utils import config_logging
from dotenv import load_dotenv
import os
load_dotenv()

from dotenv import load_dotenv
import os
load_dotenv()

config_logging(logging, logging.DEBUG)

key = ""
key = os.getenv("ASTER_KEY")

client = Client(key, base_url="https://fapi.asterdex.com")
logging.info(client.new_listen_key())
11 changes: 8 additions & 3 deletions examples/rest_api/trade/cancel_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,20 @@
from aster.lib.utils import config_logging
from aster.error import ClientError

from dotenv import load_dotenv
import os
load_dotenv()

config_logging(logging, logging.DEBUG)

key = ""
secret = ""
key = os.getenv("ASTER_KEY")
secret = os.getenv("ASTER_SECRET")
client_order_id = "387feb054fd5e2249f00f0fc02fd9f6b"

client = Client(key, secret, base_url="https://fapi.asterdex.com")

try:
response = client.cancel_order(symbol = "BTCUSDT", orderId=123456, recvWindow=2000)
response = client.cancel_order(symbol = "BTCUSDT", origClientOrderId=client_order_id, recvWindow=2000)
logging.info(response)
except ClientError as error:
logging.error(
Expand Down
8 changes: 6 additions & 2 deletions examples/rest_api/trade/get_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
from aster.lib.utils import config_logging
from aster.error import ClientError

from dotenv import load_dotenv
import os
load_dotenv()

config_logging(logging, logging.DEBUG)

key = ""
secret = ""
key = os.getenv("ASTER_KEY")
secret = os.getenv("ASTER_SECRET")

client = Client(key, secret, base_url="https://fapi.asterdex.com")

Expand Down
10 changes: 7 additions & 3 deletions examples/rest_api/trade/get_account_trades.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@
from aster.lib.utils import config_logging
from aster.error import ClientError

from dotenv import load_dotenv
import os
load_dotenv()

config_logging(logging, logging.DEBUG)

key = ""
secret = ""
key = os.getenv("ASTER_KEY")
secret = os.getenv("ASTER_SECRET")

client = Client(key, secret,base_url="https://fapi.asterdex.com")
client = Client(key,secret,base_url="https://fapi.asterdex.com")

try:
response = client.get_account_trades(symbol = "BTCUSDT", recvWindow=6000)
Expand Down
8 changes: 6 additions & 2 deletions examples/rest_api/trade/get_balance.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
from aster.lib.utils import config_logging
from aster.error import ClientError

from dotenv import load_dotenv
import os
load_dotenv()

config_logging(logging, logging.DEBUG)

key = ""
secret = ""
key = os.getenv("ASTER_KEY")
secret = os.getenv("ASTER_SECRET")

client = Client(key, secret,base_url="https://fapi.asterdex.com")

Expand Down
8 changes: 6 additions & 2 deletions examples/rest_api/trade/get_position_margin_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
from aster.lib.utils import config_logging
from aster.error import ClientError

from dotenv import load_dotenv
import os
load_dotenv()

config_logging(logging, logging.DEBUG)

key = ""
secret = ""
key = os.getenv("ASTER_KEY")
secret = os.getenv("ASTER_SECRET")

client = Client(key, secret,base_url="https://fapi.asterdex.com")
try:
Expand Down
8 changes: 6 additions & 2 deletions examples/rest_api/trade/get_position_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
from aster.lib.utils import config_logging
from aster.error import ClientError

from dotenv import load_dotenv
import os
load_dotenv()

config_logging(logging, logging.DEBUG)

key = ""
secret = ""
key = os.getenv("ASTER_KEY")
secret = os.getenv("ASTER_SECRET")

client = Client(key, secret, base_url="https://fapi.asterdex.com")

Expand Down
10 changes: 7 additions & 3 deletions examples/rest_api/trade/get_position_risk.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@
from aster.lib.utils import config_logging
from aster.error import ClientError

from dotenv import load_dotenv
import os
load_dotenv()

config_logging(logging, logging.DEBUG)

key = ""
secret = ""
key = os.getenv("ASTER_KEY")
secret = os.getenv("ASTER_SECRET")

client = Client(key, secret,base_url="https://fapi.asterdex.com")
client = Client(key,secret,base_url="https://fapi.asterdex.com")
try:
response = client.get_position_risk(recvWindow=6000)
logging.info(response)
Expand Down
10 changes: 7 additions & 3 deletions examples/rest_api/trade/new_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,19 @@
from aster.lib.utils import config_logging
from aster.error import ClientError

from dotenv import load_dotenv
import os
load_dotenv()

config_logging(logging, logging.DEBUG)

key = ""
secret = ""
key = os.getenv("ASTER_KEY")
secret = os.getenv("ASTER_SECRET")

client = Client(key, secret, base_url="https://fapi.asterdex.com")

try:
response = client.new_order(symbol="BTCUSDT", side = "SELL", type= "LIMIT", quantity= 0.001, timeInForce="GTC", price= 59808.02)
response = client.new_order(symbol="BTCUSDT", side = "BUY", type= "LIMIT", quantity= 0.001, timeInForce="GTC", price= 59808.0)
logging.info(response)
except ClientError as error:
logging.error(
Expand Down
24 changes: 24 additions & 0 deletions examples/rest_api_async/data_stream_listen_key/new_listen_key.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env python
import logging
import asyncio
from aster.rest_api import AsyncClient
from aster.lib.utils import config_logging

from dotenv import load_dotenv
import os

async def main():
load_dotenv()
config_logging(logging, logging.DEBUG)
key = os.getenv("ASTER_KEY")
client = AsyncClient(key, base_url="https://fapi.asterdex.com")
try:
logging.info(await client.new_listen_key())
finally:
await client.close()


if __name__ == "__main__":
asyncio.run(main())


11 changes: 8 additions & 3 deletions examples/websocket/user_data.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
import time
import logging
from aster.lib.utils import config_logging
from aster.rest_api import Futures as Client
from aster.rest_api import Client
from aster.websocket.client.stream import WebsocketClient

from dotenv import load_dotenv
import os
load_dotenv()

config_logging(logging, logging.DEBUG)

def message_handler(message):
print(message)

api_key = ""
api_key = os.getenv("ASTER_KEY")

client = Client(api_key)
response = client.new_listen_key()

Expand All @@ -24,7 +29,7 @@ def message_handler(message):
callback=message_handler,
)

time.sleep(30)
time.sleep(60)

logging.debug("closing ws connection")
ws_client.stop()
1 change: 1 addition & 0 deletions requirements/requirements-test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ flake8
tox
tox-pyenv
wheel
python-dotenv