Introduction
Target audience of this document is those who are capable of writing proper program source code. This document contains examples that might put your assets in danger, even losing your assets. You need to fully understand descriptions and functionalities of the source code before run them. Use this API at your own risk and all kinds of outcomes of using this API is your responsibility. Please refer Terms of Service for DAYBIT API for details.
You need to generate an API key pair from DAYBIT before using DAYBIT API. An API key pair has multiple types of authorization - receiving Candle data or Order book, checking personal assets, trading personal assets, and withdrawal authorizations. Please refer Authorization for details of authorization.
There are two types of DAYBIT APIs. First one is an API Call - client sends a request and server responds accordingly. Usually this type of APIs is used for asset trading, deposit or withdraw. Second type is a API Subscription which allows you to subscribe to an API and keep getting a notification from DAYBIT API server. There are API subscriptions which includes price change of coins, information of one's wallet, result of one's order and so on.
DAYBIT APIs are implemented based on websocket connection and follow the format defined in Phoenix framework. DAYBIT also provides Pydaybit written in Python which allows users to easily use DAYBIT API.
If you are not familiar with programming, it would be better to take a look at examples of Pydaybit first.
Authorization
Before you are using DAYBIT APIs, you first need to generate API key pair with proper authorization. An API key pair has multiple types of authorization - receiving candle data or a order book, checking personal assets, trading personal assets, and withdrawal authorizations.
The usage of APIs is restricted by given right to each API key pair. You would get unauthenticated
response error_code if you called an API that is not accessible from your API key pair. Please look above for types of API key pair and details of it.
Type | Description |
---|---|
public_data | Authorized to access public data (ex, Market Summary, Order Book and so on). To get this authorization level from an API key, please include Market Inquiry at the API key pair creation. |
private_data | Authorized to access private data (ex, Asset and so on). To get this authorization level from an API key, please include Private Asset Inquiry at the API key pair creation. |
trade | Authorized to call trade related APIs (ex, Order, Trade and so on). To get this authorization level from an API key, please include Trading API at the API key pair creation. |
transaction | Authorized to call transaction related APIs (ex, Deposit, Withdrawal and so on). To get this authorization level from API key, please include Withdrawal API at the API key pair creation. |
You can generate maximum 5 API key pairs per account in API Keys tab in My Page. Each API Key pair can have following authorizations:
public_data
public_data
,private_data
,trade
public_data
,private_data
,transaction
public_data
,private_data
,trade
,transaction
Host address
- DAYBIT API endpoint : wss://api.daybit.com/v1/user_api_socket/websocket/
APIs
There are two types of DAYBIT's APIs. First one is an API Call - client sends a request and server responds accordingly. Usually this type of a call is used for asset trading, deposit or withdraw. Second type is a Subscription which allows you to subscribe to an API and keep getting a notification from the server. Based on type of the notification, it includes price change of coins, information of one's wallet, result of one's order and so on.
Channels
Channels are based on a simple idea of Phoenix that sending and receiving messages. Senders broadcast messages about topics. Receivers subscribe to a channel which has a specific topics so that they can get those messages. Senders and receivers can switch roles on the same topic at any time. For details, refer to Phoenix Documents.
Topics
Topics are string identifiers of channels that the various layers use in order to make sure messages end up in the right place. DAYBIT APIs are using following types of topics.
Events
Event is a string
representing specific actions of the channel. "phx_join"
is for joinning the channel and "phx_leave"
is for leaving the channel. DAYBIT API Calls include types of request in event.
Messages
Example of
create_wdrl
import asyncio
import logging
from pydaybit import Daybit
logger = logging.getLogger('pydaybit')
logger.setLevel(logging.DEBUG)
stream_handler = logging.StreamHandler()
stream_handler.setFormatter(logging.Formatter('%(message)s'))
logger.addHandler(stream_handler)
async def daybit_create_wdrl():
async with Daybit() as daybit:
await daybit.create_wdrl(coin='BTC', to_addr='ABTCADDRESS', amount='0.05')
asyncio.get_event_loop().run_until_complete(daybit_create_wdrl())
Output of the example
> {"join_ref": "1", "ref": "1", "topic": "/api", "event": "phx_join", "payload": {"timestamp": 1538739991045, "timeout": 3000}}
< {"topic":"/api","ref":"1","payload":{"status":"ok","response":{}},"event":"phx_reply"}
> {"join_ref": "1", "ref": "2", "topic": "/api", "event": "create_wdrl", "payload": {"to_addr": "ABTCADDRESS", "timestamp": 1538739991059, "coin": "BTC", "amount": "0.05", "timeout": 3000}}
< {"topic":"/api","ref":"2","payload":{"status":"ok","response":{"data":{"wdrl_to_tag":null,"wdrl_to_org":null,"wdrl_to_addr":"ABTCADDRESS","wdrl_status":"queued","type":"wdrl","txid":null,"tx_link_url":"https://live.blockcypher.com/btc/tx/","req_confirm":2,"id":5882,"deposit_status":null,"created_at":1538739991072,"confirm":0,"completed_at":null,"coin":"BTC","amount":"0.050000000000000000"}}},"event":"phx_reply"}
> {"join_ref": "1", "ref": "3", "topic": "/api", "event": "phx_leave", "payload": {"timestamp": 1538739991124, "timeout": 3000}}
< {"topic":"/api","ref":"3","payload":{"status":"ok","response":{}},"event":"phx_reply"}
< {"topic":"/api","ref":"1","payload":{},"event":"phx_close"}
Following properties is delivered in the format of JSON object. The example shows messages on the websocket between a client and DAYBIT API server when the client calls create_wdrl
.
topic
- The string identifier of a channel. for example"/api"
or"/subscription:coins"
event
- The string event name. for example"create_order"
,"cancel_order"
,"phx_join"
,"phx_leave"
, and so onpayload
- The message payloadref
- The unique string refjoin_ref
- ref of joinning the channel
API Calls
You may connect to DAYBIT API endpoint through a websocket and join /api
channel. Then you can call a API by sending message with proper event
among followings.
Channel of API Calls
All API calls should use /api
channel.
API Call List
In /api
channel, set event
property with a API name . Available API call list are following.
Request
create_wdrl
{"join_ref": "1", "ref": "2", "topic": "/api", "event": "create_wdrl", "payload": {"to_addr": "ABTCADDRESS", "timestamp": 1538739991059, "coin": "BTC", "amount": "0.05", "timeout": 3000}}
Response
{"topic":"/api","ref":"2","payload":{"status":"ok","response":{"data":{"wdrl_to_tag":null,"wdrl_to_org":null,"wdrl_to_addr":"ABTCADDRESS","wdrl_status":"queued","type":"wdrl","txid":null,"tx_link_url":"https://live.blockcypher.com/btc/tx/","req_confirm":2,"id":5882,"deposit_status":null,"created_at":1538739991072,"confirm":0,"completed_at":null,"coin":"BTC","amount":"0.050000000000000000"}}},"event":"phx_reply"}
Subscriptions
Example of
coins
import asyncio
import logging
from pydaybit import Daybit
logger = logging.getLogger('pydaybit')
logger.setLevel(logging.DEBUG)
stream_handler = logging.StreamHandler()
stream_handler.setFormatter(logging.Formatter('%(message)s'))
logger.addHandler(stream_handler)
async def daybit_coins():
async with Daybit() as daybit:
await daybit.coins()
asyncio.get_event_loop().run_until_complete(daybit_coins())
Output
> {"join_ref": "1", "ref": "1", "topic": "/subscription:coins", "event": "phx_join", "payload": {"timestamp": 1538740890363, "timeout": 3000}}
< {"topic":"/subscription:coins","ref":"1","payload":{"status":"ok","response":{}},"event":"phx_reply"}
> {"join_ref": "1", "ref": "2", "topic": "/subscription:coins", "event": "request", "payload": {"timestamp": 1538740890374, "timeout": 3000}}
< {"topic":"/subscription:coins","ref":"2","payload":{"status":"ok","response":{"data":[{"data":[{"wdrl_fee":"5.00000000","wdrl_enabled":true,"wdrl_confirm":2,"tradable":true,"tick_amount":"0.10000000","sym":"USDT","native_decimal_places":2,"name":"Tether","min_wdrl":"10.00000000","min_deposit":"10.00000000","has_tag":false,"has_org":false,"deposit_enabled":true,"deposit_confirm":2} ... ],"action":"init"}]}},"event":"phx_reply"}
> {"join_ref": "1", "ref": "3", "topic": "/subscription:coins", "event": "phx_leave", "payload": {"timestamp": 1538740890386, "timeout": 3000}}
< {"topic":"/subscription:coins","ref":"3","payload":{"status":"ok","response":{}},"event":"phx_reply"}
< {"topic":"/subscription:coins","ref":"1","payload":{},"event":"phx_close"}
For using API Subscriptions, first you need to join /subscription:<subtopic>
channel and send request
event. Once you are successfully subscribed by joinning a channel, DAYBIT API server sends notification
for any kind of updated data.
API Subscription Channels
Subscription Channels are following. The topic of each channels has /subscription:<subtopic>
format. For example, In case of the topic of coins
channel is /subscription:coins
.
coins
coin_prices
quote_coins
markets
market_summary_intvls
market_summaries
order_books
price_history_intvls
price_histories
trades
,my_users
my_assets
my_orders
my_trades
my_tx_summaries
my_airdrop_histories
trade_vols
day_avgs
div_plan
my_trade_vols
my_day_avgs
my_divs
Event of API Subscriptions
request
is a push event and notification
is a pull event. Message transported from client and server have request
and notification
events, respectively. When you subscribe to an API, i.e., joining the channel related to the API and sending a message with request
event, you will get either init
or upsert
action response from the channel. After that, you would get one of insert
, update
, upsert
, or delete
from the channel with notification
event. For more information of actions, please look following Action.
Rate Limit of API Subscriptions
Limit of messages which have request
event for every second.
Example of
coins
import asyncio
import logging
from pydaybit import Daybit
logger = logging.getLogger('pydaybit')
logger.setLevel(logging.DEBUG)
stream_handler = logging.StreamHandler()
stream_handler.setFormatter(logging.Formatter('%(message)s'))
logger.addHandler(stream_handler)
async def daybit_coins():
async with Daybit() as daybit:
await daybit.coins()
asyncio.get_event_loop().run_until_complete(daybit_coins())
Output
> {"join_ref": "1", "ref": "1", "topic": "/subscription:coins", "event": "phx_join", "payload": {"timestamp": 1538740890363, "timeout": 3000}}
< {"topic":"/subscription:coins","ref":"1","payload":{"status":"ok","response":{}},"event":"phx_reply"}
> {"join_ref": "1", "ref": "2", "topic": "/subscription:coins", "event": "request", "payload": {"timestamp": 1538740890374, "timeout": 3000}}
< {"topic":"/subscription:coins","ref":"2","payload":{"status":"ok","response":{"data":[{"data":[{"wdrl_fee":"5.00000000","wdrl_enabled":true,"wdrl_confirm":2,"tradable":true,"tick_amount":"0.10000000","sym":"USDT","native_decimal_places":2,"name":"Tether","min_wdrl":"10.00000000","min_deposit":"10.00000000","has_tag":false,"has_org":false,"deposit_enabled":true,"deposit_confirm":2} ... ],"action":"init"}]}},"event":"phx_reply"}
> {"join_ref": "1", "ref": "3", "topic": "/subscription:coins", "event": "phx_leave", "payload": {"timestamp": 1538740890386, "timeout": 3000}}
< {"topic":"/subscription:coins","ref":"3","payload":{"status":"ok","response":{}},"event":"phx_reply"}
< {"topic":"/subscription:coins","ref":"1","payload":{},"event":"phx_close"}
Rate limit
Each API has limit of calls for every second. You will get api_exceeded_rate_limit
error_code in response if you exceeded the limit.
Timestamp
All request takes timestamp
and timeout
to prevent unexpected calls because of network delay and so on.
timestamp
:unix_timestamp
timeout
(optional):ms
unit time ininteger
. Default value is3000
which means 3 seconds.
A request will be rejected in next condition: server time
- timestamp
> timeout
.
If there was a problem, below error_code will be returned in response.
api_invalid_timestamp_or_timeout
:timestamp
and/ortimeout
are not existed or they are notinteger
(unix timestamp in millisecond).api_timeout
: Rejected because of request time out.
Response format
There are two types of response formats. Based on the result of both API calls and subscriptions, you would get one of success or fail models. Please see success and fail response examples on right column. You can also find Error List in below.
Success
{
# plain json object with proper data
}
Fail
{
"error_code": 'string',
"message": 'string'
}
Libraries
DAYBIT is using Elixir language and built on Phoenix framework. DAYBIT API can be accessed from Phoenix client, which makes it easy to connect to Phoenix sockets. For now, DAYBIT officially provides a wrapper for Python language.
- PyDaybit(Python): https://github.com/daybit-exchange/pydaybit
For other languages, please refer below libraries to implement the features of DAYBIT API.
- Phoenix.js(Javascript): https://github.com/phoenixframework/phoenix
- SwiftPhoenixClient(Swift): https://github.com/davidstump/SwiftPhoenixClient
- PhoenixSharp(C#): https://github.com/Mazyod/PhoenixSharp
Error list
General
unauthenticated
: Unauthenticated user or actioninvalid_arguments
: Invalid arguments in requestresource_not_found
: Resource not found
Api
api_invalid_timestamp_or_timeout
:timestamp
and/ortimeout
of request is not validapi_timeout
: Timeout happens by requestedtimestamp
and/ortimeout
api_exceeded_rate_limit
: Rate limit exceededapi_invalid_param_types
: Invalid request parameter typeapi_required_params_not_provided
: Missing required parameterapi_invalid_event
: Invalid request event
Order
order_invalid_market
: Invalid market(quote
,base
)order_not_tradable_coin
: Coin trade suspendedorder_not_sellable_market
: Selling is suspended in the marketorder_not_buyable_market
: Buying is suspended in the marketorder_invalid_price
: Invalid priceorder_invalid_amount
: Invalid amountorder_only_both_role_can_be_cond
: Conditional order is available only whenrole
isboth
order_out_of_price_range
: Out of price range (Selling: 20% ~ 200%, Buying: 50% ~ 500%)order_exceeded_max_tstops
: Exceeded maximum Trailing Stop order count (currently 2 per market)order_suspended_due_to_frequent_canceling
: Order suspended due to frequent cancelingorder_exceeded_asset_values
: Order exceeded my asset valuesorder_already_closed
: Order already closedorder_exceeded_void_rate
: Order suspended for 10 minutes because invalid order rate exceeded specific value (currently 80%)order_exceeded_max_orders
: Order exceeded maximum number of outstanding orders (currently 100)order_violates_min_usd
: Order violates minimum of total USD exchanged amount (currently $10)order_unplaceable_maker_only
: Order didn't meet maker only conditionsorder_unplaceable_taker_only
: Order didn't meet taker only conditions
Wdrl
wdrl_suspended_coin
: Coin was Suspended to withdrawwdrl_precision_error
: Decimal place accuracy errorwdrl_under_min_amount
: One time withdrawal amount is less than minimumwdrl_over_daily_wdrl_limit
: Withdrawal amount exceeded daily limitwdrl_exceeds_my_asset_values
: Withdrawal amount exceeded my assetwdrl_needs_to_tag
: Missingto_tag
parameterwdrl_invalid_addr
: Invalid address
Action
When you subscribe an API, a message from the server holds action
which helps you to understand how to handle the data.
init
: Dump all previous local data and initialize everything with data reponsedinsert
: Add responsed data to local data setupdate
: Search in local data set and replace if it was found.upsert
: Search in data set and replace if it was found, or insert if there's no matching data.delete
: Search in data set and remove if it was found.
Types
Integer
integer
type.
123
20181010
Decimal
Decimal number. This is string
data type to precisely express the exact amount of number which can't be expressed in ordinary decimal number types.
"880.524"
"59.55000000000000000"
String
string
.
"string"
"bitcoin"
"DAYBIT"
Boolean
boolean
.
true
false
Unix Timestamp
millisecond
unit Unix timestamp.
1528269989516
CSV
comma separated values expressed in string
.
"1, 2, 3"
Models
Below are generic data models.
Coin
identifier: sym
Name | Type | Description |
---|---|---|
sym | string | Coin symbol |
native_decimal_point | integer | Withdrawal amount decimal restriction |
amount_decimal_point | integer | Order amount decimal point restriction |
tick_amount | decimal | Order amount unit |
deposit_confirm | integer | Number of confirms required for deposit completion |
wdrl_confirm | integer | Number of confirms required for withdrawal completion |
public | boolean | Listed on the exchange (true ) or not (false ) |
name | string | Name of coin (locale applied) |
tradable | boolean | Tradable or not |
deposit_enabled | boolean | Deposit enabled or not |
wdrl_enabled | boolean | Withdrawal enabled or not |
wdrl_fee | decimal | Withdrawal fee |
min_deposit | decimal | Minimum deposit amount |
min_wdrl | decimal | Minimum withdrawal amount |
has_tag | boolean | to_tag required or not for deposit/withdrawal |
has_org | boolean | to_org required or not for deposit/withdrawal |
Coin price
identifier: sym
Name | Type | Description |
---|---|---|
sym | string | Coin symbol |
usd_price | decimal | USD exchanged price |
Quote coin
identifier: sym
Name | Type | Description |
---|---|---|
sym | string | Coin symbol |
Market
identifier: quote
, base
Name | Type | Description |
---|---|---|
quote | string | Quote coin |
base | string | Base coin |
tick_price | decimal | Order price unit |
sellable | boolean | Sellable or not |
buyable | boolean | Buyable or not |
tick_levels | integer | Number of levels for order book existence per tick_price . Order book is increased ten times for each level. ex) tick_price = 0.01, order book intvl = 0.01, 0.1, 1, 10, 100 |
Market summary interval
identifier: seconds
Name | Type | Description |
---|---|---|
seconds | integer | Interval unit of Market Summary |
Market summary
identifier: quote
, base
, seconds
Name | Type | Description |
---|---|---|
quote | string | Quote coin |
base | string | Base coin |
seconds | integer | Time unit |
open | decimal | Opening price |
close | decimal | Closing price |
high | decimal or null | Highest price |
low | decimal or null | Lowest price |
volatility | decimal | Price volatility |
quote_vol | decimal or null | Trading volume per quote coin |
base_vol | decimal or null | Trading volume per base coin |
Order book
identifier: quote
, base
, intvl
, min_price
Name | Type | Description |
---|---|---|
quote | string | Quote coin |
base | string | Base coin |
intvl | decimal | Price interval unit |
min_price | decimal | Minimum price |
max_price | decimal | Maximum price |
sell_vol | decimal | Selling volume |
buy_vol | decimal | Buying volume |
Price history interval
identifier: seconds
Name | Type | Description |
---|---|---|
seconds | integer | Interval unit of Price history |
Price history
identifier: quote
, base
, intvl
, start_time
Name | Type | Description |
---|---|---|
quote | string | Quote coin |
base | string | Base coin |
intvl | integer | Time interval |
start_time | unix_timestamp | Start time of price history |
end_time | unix_timestamp | End time of price history |
open | decimal | Opening price |
close | decimal | Closing price |
high | decimal | Highest price |
low | decimal | Lowest price |
base_vol | decimal | Trading volume per base coin |
quote_vol | decimal | Trading volume per quote coin |
User
identifier: -
Name | Type | Description |
---|---|---|
maker_fee_rate | decimal | Maker fee rate |
taker_fee_rate | decimal | Taker fee rate |
one_day_wdrl_usd_limit | decimal | Withdrawal limit for 24 hours in USD |
Asset
identifier: coin
Name | Type | Description |
---|---|---|
coin | string | Coin symbol |
total | decimal | Total amount |
reserved | decimal | Reserved amount for order and so on |
available | decimal | Availalbe amount for order |
investment_usd | decimal | Total investment in USD |
Order
identifier: id
Name | Type | Description |
---|---|---|
id | integer | id |
sell | boolean | Selling (true ) or buying (false ) |
quote | string | Quote coin |
base | string | Base coin |
price | decimal | Price |
role | string | Order role. "both" , "maker_only" , "taker_only" |
cond_type | string | Conditional order type. "none" , "le" , "ge" , "fall_from_top" , "rise_from_bottom" |
cond_arg1 | decimal or null | First conditional order value |
cond_arg2 | decimal or null | Second conditional order value |
coin_fee | decimal | Fee |
amount | decimal | Order amount |
filled | decimal | Order filled (per base at selling) |
filled_quote | decimal | Order filled (per quote at buying) |
unfilled | decimal | Order unfilled |
received_at | unix_timestamp | Order received time |
placed_at | unix_timestamp or null | Order placed time (to order book) |
closed_at | unix_timestamp or null | Order closed time |
status | string | Order status ("received" , "placed" , "closed" ) |
close_type | string | Closing type ("rejected" , "filled" , "canceled" ) |
cancel_reason | string | Cancel reason ("user" , "conflicting_self_order" , "expired" , "no_placed_amount" , "partially_filled_taker_only" , "maintenance" , "admin" ,) |
Trade
identifier: id
Name | Type | Description |
---|---|---|
id | integer | id |
quote | string | Quote coin |
base | string | Base coin |
quote_amount | decimal | Quote coin trade amount |
base_amount | decimal | Base coin trade amount |
price | decimal | Trade closing price |
taker_sold | boolean | Taker is seller (true ) or buyer (false ) |
exec_at | unix_timestamp | Execution time |
Below are only available from my_trades | ||
order_id | integer | Trade order id |
fee | decimal | Fee |
sell | boolean | Selling (true ) or buying (false ) |
counterpart | string | ("user" , "daybit" , "project" ), The counterparty of the trade. "daybit" and "project" means DAYBIT exchange and another coin project team, respectively. |
Transaction Summary
identifier: id
Name | Type | Description |
---|---|---|
id | integer | id |
coin | string | Transaction coin |
type | string | Type of the transaction ("wdrl" , "deposit" ) |
amount | decimal | Transaction amount |
txid | string or null | Withdrawal transaction id |
confirm | integer | Confirm count |
req_confirm | integer | |
deposit_status | string | Deposit status |
wdrl_status | string or null | Withdrawal status |
wdrl_to_addr | string or null | Withdrawal receiving address |
wdrl_to_tag | string or null | Withdrawal tag |
wdrl_to_org | string or null | Withdrawal organization |
created_at | unix_timestamp | Transaction created time |
completed_at | unix_timestamp or null | Transaction completed time |
tx_link_url | string |
Airdrop
identifier: id
Name | Type | Description |
---|---|---|
id | integer | id |
coin | string | coin symbol |
amount | decimal | Airdrop amount |
description | string | Airdrop description |
airdropped_at | unix_timestamp | Airdrop time |
Trade Volume
identifier: start_time
Name | Type | Description |
---|---|---|
start_time | unix_timestamp | Start Time |
end_time | unix_timestamp | End Time |
usd_amount | decimal | Aggregated volume between start_time and end_time |
Day Average
identifier: start_time
Name | Type | Description |
---|---|---|
start_time | unix_timestamp | Start Time |
end_time | unix_timestamp | End Time |
avg | decimal | Average of total volume of distributed DAY as rewards between start_time and end_time |
Div Plan
identifier: end_time
Name | Type | Description |
---|---|---|
start_time | unix_timestamp | Start Time |
end_time | unix_timestamp | End Time |
div_count | integer | The number of BTC reward receivers |
div_btc | decimal | Total BTC rewards |
Pydaybit
Pydaybit is an API wrapper for DAYBIT exchange written in Python. The code is available in Pydaybit Repository.
Disclaimer
USE THE SOFTWARE AT YOUR OWN RISK. THE AUTHORS AND ALL AFFILIATES ASSUME NO RESPONSIBILITY FOR YOUR TRADING RESULTS.
Installation
Pydaybit installation
$ pip3 install --upgrade pydaybit
For the installation, please look right column.
API Key Pair
You need to generate a API key pair to use Pydaybit. Please refer Authorization.
Environment Variables
bash example
# ~/.bash_profile
export DAYBIT_API_KEY="YOUR_OWN_API_KEY"
export DAYBIT_API_SECRET="YOUR_OWN_API_SECRET"
You can set generated key pair as environment variable.
DAYBIT_API_KEY
: Generated API KEYDAYBIT_API_SECRET
: Generated API SECRET
Without Environment Variables
without environment settings
import asyncio
from pydaybit import Daybit, PARAM_API_KEY, PARAM_API_SECRET
async def daybit_example():
async with Daybit(params={PARAM_API_KEY: "YOUR_OWN_API_KEY",
PARAM_API_SECRET: "YOUR_OWN_API_SECRET"}) as daybit:
pass
asyncio.get_event_loop().run_until_complete(daybit_example())
For using the key pair without settings them in environment variable, please refer the example.
get_server_time()
Example Request
import asyncio
from pprint import pprint
from pydaybit import Daybit
async def daybit_get_server_time():
async with Daybit() as daybit:
pprint(await daybit.get_server_time())
asyncio.get_event_loop().run_until_complete(daybit_get_server_time())
Example Response
1537418605426 # unix_timestamp
Get current time of DAYBIT API server in Unix miliseconds timestamp format.
Topic:
/api
Event:
get_server_time
Rate limit: 10
create_order()
Example Request
import asyncio
from contextlib import suppress
from decimal import Decimal
from pprint import pprint
from pydaybit import Daybit
from pydaybit.exceptions import OrderAlreadyClosed
async def current_price(daybit, quote, base):
summary_intvl = sorted((await daybit.market_summary_intvls()).keys())[0]
price = (await (daybit.market_summaries / summary_intvl)())['{}-{}'.format(quote, base)]['close']
return Decimal(price)
async def daybit_create_order_sell():
async with Daybit() as daybit:
quote = 'USDT'
base = 'BTC'
tick_price = Decimal((await daybit.markets())['{}-{}'.format(quote, base)]['tick_price'])
tick_amount = Decimal((await daybit.coins())[base]['tick_amount'])
# amount * price should be greater than 10 USDT.
price = ((await current_price(daybit, quote, base)) * Decimal(1.2)).quantize(tick_price)
amount = (Decimal(10.5) / price).quantize(tick_amount)
response = await daybit.create_order(
sell=True,
role='both',
quote=quote,
base=base,
price=price,
amount=amount,
cond_type='none',
)
pprint(response)
with suppress(OrderAlreadyClosed):
await daybit.cancel_order(response['id'])
asyncio.get_event_loop().run_until_complete(daybit_create_order_sell())
Example Response
{
'amount': '0.00200000',
'base': 'BTC',
'cancel_reason': None,
'close_type': None,
'closed_at': None,
'cond_arg1': None,
'cond_arg2': None,
'cond_type': 'none',
'filled': '0.00000000',
'filled_quote': '0.00000000',
'id': 53026865,
'placed_amount': '0.00200000',
'placed_at': 1537419310682,
'price': '6961.00000000',
'quote': 'USDT',
'received_at': 1537419310639,
'role': 'both',
'sell': True,
'status': 'placed',
'unfilled': '0.00200000'
}
Create a order to sell or buy coin. There are five types of orders you can request to DAYBIT API server - Limit order, Taker Order, Maker Order, Stop Limit Order, and Trailling Stop Order.
The conditions of invalid order (void order) are,
- rejected order
- order cancellation by user
- order cancellation by self order
- auto cancellation of old order
sell
, quote
, base
, amount
, role
, cond_type
are always required.
Topic:
/api
Event:
create_order
Rate limit: -
Response: Order
Parameter | Type | Required | Description |
---|---|---|---|
sell | boolean | Required | True for selling and False for buying. |
quote | string | Required | Quote coin symbol. ex) "BTC" |
base | string | Required | Base coin symbol. ex) "ETH" |
amount | decimal | Required | Order amount. |
role | string | Required | Role of order. ("both" , "maker_only" , "taker_only" ) |
cond_type | string | Required | Conditional types of the order. ("none" , "le" , "ge" , "down_from_high" , "up_from_low" ) |
price | decimal | Optional | Asking price. |
cond_arg1 | decimal | Optional | First conditional argument of the order. |
cond_arg2 | decimal | Optional | Second conditional argument of the order. |
Limit Order
Example Limit Order
await daybit.create_order(
sell=True, # True for selling, False for buying.
role='both',
quote=quote,
base=base,
price=price,
amount=amount,
cond_type='none',
)
If the order was placed, it is regarded as a taker order. and if remain amount of the order exists, it is regarded as a maker order.
Parameter | Type | Required | Description |
---|---|---|---|
sell | boolean | Required | True for selling and False for buying. |
role | string | Required | "both" |
quote | string | Required | Quote coin symbol. ex) "BTC" |
base | string | Required | Base coin symbol. ex) "ETH" |
price | decimal | Required | Asking price in terms of price = base / quote . |
amount | decimal | Required | Required amount of quote . |
cond_type | string | Required | "none" |
Taker Order
Example Taker Order
await daybit.create_order(
sell=True, # True for selling, False for buying.
role='taker_only',
quote=quote,
base=base,
price=price,
amount=amount,
cond_type='none',
)
If the order was placed, before your orders are going on the order book, these are called as "taker". These trades are called as "taker" because it is "taking" the volume in the order book. This order is taking only volumes in the order book.
Parameter | Type | Required | Description |
---|---|---|---|
sell | boolean | Required | True for selling and False for buying. |
role | string | Required | "taker_only" |
quote | string | Required | Quote coin symbol. |
base | string | Required | Base coin symbol. |
price | decimal | Required | Asking price in terms of price = base / quote . |
amount | decimal | Required | Required amount of quote . |
cond_type | string | Required | "none" |
Maker Order
Example Maker Order
await daybit.create_order(
sell=True, # True for selling, False for buying.
role='maker_only',
quote=quote,
base=base,
price=price,
amount=amount,
cond_type='none',
)
If the order was placed, after your orders filled the order book. these are called as "maker" because it is "making" the market. This order is only valid when it fills the volume in the order book.
Parameter | Type | Required | Description |
---|---|---|---|
sell | boolean | Required | True for selling and False for buying. |
role | string | Required | "maker_only" |
quote | string | Required | Quote coin symbol. |
base | string | Required | Base coin symbol. |
price | decimal | Required | Asking price in terms of price = base / quote . |
amount | decimal | Required | Required amount of quote . |
cond_type | string | Required | "none" |
Stop Limit Order
Example Stop Limit Order
await daybit.create_order(
sell=True, # True for selling, False for buying.
role='both',
quote=quote,
base=base,
price=price,
amount=amount,
cond_type='ge', # cond_type could be 'ge' or 'le'.
cond_arg1=price * Decimal(1.5)
)
When current price is equal or greater/less than cond_arg1
, it places Limit Order.
If you sent request with
cond_type
="le"
, it places Limit Order for the price ofprice
when it becomescurrent_price
≤conditional_price
(=cond_arg1
).If you sent request with
cond_type
="ge"
, it places Limit Order for the price ofprice
when it becomescurrent_price
≥conditional_price
(=cond_arg1
).
Parameter | Type | Required | Description |
---|---|---|---|
sell | boolean | Required | True for selling and False for buying. |
role | string | Required | "both" |
quote | string | Required | Quote coin symbol. |
base | string | Required | Base coin symbol. |
price | decimal | Required | Asking price in terms of price = base / quote . |
amount | decimal | Required | Required amount of quote . |
cond_type | string | Required | "le" or "ge" |
cond_arg1 | decimal | Required | conditional_price of the order. This value is compared with current_price . |
Trailing Stop Order
Example Trailing Stop Order
await daybit.create_order(
sell=True, # True for 'down_from_high', False for 'up_from_low'.
role='both',
quote='USDT',
base='BTC',
amount=Decimal('0.1'),
cond_type='down_from_high', # cond_type could be 'down_from_high' or 'up_from_low'.
cond_arg1=Decimal('-0.01'),
cond_arg2=Decimal('-0.005'),
)
You can place trailing stop order to sell the coin, with certain rate of discount compared with current price, when the price has dropped at specific rate compared with highest price. Likewise, you can also buy the coin, with certain rate of extra charge compared with current price, when the price has risen at specific rate compared with lowest price, by placing trailing stop order.
For example, let say you placed a trailing stop order with (sell
=True, role
='both', quote
='BTC', base
='USDT', amount
='0.1', cond_type
='down_from_high', cond_arg1
='-0.01', cond_arg2
='-0.005'). After the trailing stop order has placed, if the price has dropped since it reached highest price at 10,000 USDT, it will be triggered at 9,000 USDT (= 10,000 USDT * (1 + cond_arg1
)) and place a limit order at the price of 8,955 USDT (= 9,000 USDT * (1 + cond_arg2
)).
In Down From High case, when
current_price
≤top_price
* (1 +cond_arg1
), it places a selling limit order for the price ofcurrent_price
* (1 +cond_arg2
).In Up From Low case, when
current_price
≥bottom_price
* (1 +cond_arg1
), it places a buying limit order for the price ofcurrent_price
* (1 +cond_arg2
).
Parameter | Type | Required | Description |
---|---|---|---|
sell | boolean | Required | true for "down_from_high" and false for "up_from_low" . |
role | string | Required | "both" |
quote | string | Required | Quote coin symbol. |
base | string | Required | Base coin symbol. |
amount | decimal | Required | Order amount. |
cond_type | string | Required | "down_from_high" or "up_from_low" . |
cond_arg1 | decimal | Required | In Down From High case, price discount rate compared with top price In Up From Low case, price rise rate compared with bottom price. |
cond_arg2 | decimal | Required | When the condition as above is meet, it places a limit order for the price of current_price * (1 + cond_arg2 ). |
cancel_order()
Example Request
import asyncio
from pprint import pprint
from pydaybit import Daybit
async def daybit_cancel_order():
async with Daybit() as daybit:
pprint(await daybit.cancel_order(53216861))
asyncio.get_event_loop().run_until_complete(daybit_cancel_order())
Example Response
{
'amount': '0.00200000',
'base': 'BTC',
'cancel_reason': 'user',
'close_type': 'canceled',
'closed_at': 1537421465336,
'cond_arg1': None,
'cond_arg2': None,
'cond_type': 'none',
'filled': '0.00000000',
'filled_quote': '0.00000000',
'id': 53216861,
'placed_amount': '0.00200000',
'placed_at': 1537421443079,
'price': '6595.00000000',
'quote': 'USDT',
'received_at': 1537421443074,
'role': 'both',
'sell': False,
'status': 'closed',
'unfilled': '0.00200000'
}
Cancel placed order. You must pass valid id
to cancel the order.
Topic:
/api
Event:
cancel_order
Rate limit: -
Response: Order
Arguments
Parameter | Type | Required | Description |
---|---|---|---|
order_id | integer | Required | id of order supposed to be canceled. |
cancel_orders()
Example Request
import asyncio
from pprint import pprint
from pydaybit import Daybit
async def daybit_cancel_orders():
async with Daybit() as daybit:
my_orders = await daybit.my_orders()
open_orders = ([my_orders[key]['id'] for key in my_orders if my_orders[key]['status'] == 'placed'])
pprint(open_orders)
pprint(await daybit.cancel_orders(open_orders))
asyncio.get_event_loop().run_until_complete(daybit_cancel_orders())
Example Response
{
'num_canceled_orders': 5
}
Cancel multiple orders. If one or more of order_ids
are invalid, the API simply ignores it and cancels only valid ones. You can check number of canceled ids from num_canceled_orders
in response.
Topic:
/api
Event:
cancel_orders
Rate limit: 1
Arguments
Parameter | Type | Required | Description |
---|---|---|---|
order_ids | array | Required | ids of order supposed to be canceled. |
Response
Field | Description |
---|---|
num_canceled_orders | Number of successfully canceled orders. |
cancel_all_my_orders()
Example Request
import asyncio
from pprint import pprint
from pydaybit import Daybit
async def daybit_cancel_all_my_orders():
async with Daybit() as daybit:
response = await daybit.cancel_all_my_orders()
pprint(response)
asyncio.get_event_loop().run_until_complete(daybit_cancel_all_my_orders())
Example Response
{
'num_canceled_orders': 2
}
Cancel all my orders.
Topic:
/api
Event:
cancel_all_my_orders
Rate limit: 1
Response
Field | Description |
---|---|
num_canceled_orders | Number of successfully canceled orders. |
create_wdrl()
Example Request
import asyncio
from pprint import pprint
from pydaybit import Daybit
async def daybit_create_wdrl():
async with Daybit() as daybit:
pprint(await daybit.create_wdrl(coin='BTC', to_addr='<YOUR BTC ADDRESS>', amount='0.01'))
asyncio.get_event_loop().run_until_complete(daybit_create_wdrl())
Example Response
{
'amount': '0.01000000',
'coin': 'BTC',
'completed_at': None,
'confirm': 0,
'created_at': 1538639363972,
'deposit_status': None,
'id': 5294,
'req_confirm': 10,
'tx_link_url': 'https://live.blockcypher.com/btc/tx/',
'txid': None,
'type': 'wdrl',
'wdrl_status': 'queued',
'wdrl_to_addr': '<YOUR BTC ADDRESS>',
'wdrl_to_org': None,
'wdrl_to_tag': None
}
Request withdraw to to_addr
for amount
of coin
.
Topic:
/api
Event:
create_wdrl
Rate limit: 50
Response: Transaction summary
Arguments
Parameter | Type | Required | Description |
---|---|---|---|
coin | string | Required | Withdraw coin. |
to_addr | string | Required | Withdraw receiving address. |
to_tag | string | Optional | Withdraw tag. Used by XRP and so on. |
amount | decimal | Required | Amount to withdraw. |
coins()
Example Request
import asyncio
from pprint import pprint
from pydaybit import Daybit
async def daybit_coins():
async with Daybit() as daybit:
pprint(await daybit.coins())
asyncio.get_event_loop().run_until_complete(daybit_coins())
Example Response
{
'ADA': {
'deposit_confirm': 3,
'deposit_enabled': True,
'has_org': False,
'has_tag': False,
'min_deposit': '100.00000000',
'min_wdrl': '100.00000000',
'name': 'Ada',
'native_decimal_places': 8,
'sym': 'ADA',
'tick_amount': '2.00000000',
'tradable': False,
'wdrl_confirm': 10,
'wdrl_enabled': True,
'wdrl_fee': '50.00000000'
},
# ...
'ZRX': {
'deposit_confirm': 3,
'deposit_enabled': True,
'has_org': False,
'has_tag': False,
'min_deposit': '13.00000000',
'min_wdrl': '13.00000000',
'name': '0x Protocol',
'native_decimal_places': 4,
'sym': 'ZRX',
'tick_amount': '0.20000000',
'tradable': True,
'wdrl_confirm': 10,
'wdrl_enabled': True,
'wdrl_fee': '6.30000000'
}
}
Subscribe to get coin data.
Topic:
/subscription:coins
Request:
init
Notification:
insert
,update
Rate limit: 3
Response: Coin
Sort: -
coin_prices()
Example Request
import asyncio
from pprint import pprint
from pydaybit import Daybit
# For every coin
async def daybit_coin_prices():
async with Daybit() as daybit:
pprint(await daybit.coin_prices())
# For specific coin
async def daybit_coin_prices_with_sym(sym='ETH'):
async with Daybit() as daybit:
pprint(await (daybit.coin_prices / sym)())
asyncio.get_event_loop().run_until_complete(daybit_coin_prices())
# asyncio.get_event_loop().run_until_complete(daybit_coin_prices_with_sym())
Example Response
# If you didn't specify the coin
{
'ADA': {
'sym': 'ADA',
'usd_price': '0.09000000'
},
# ...
'ZRX': {
'sym': 'ZRX',
'usd_price': '0.67047870'
}
}
# If you specified the coin
{
'ETH': {
'sym': 'ETH',
'usd_price': '291.88000000'
}
}
coin_prices()
Coin to USD exchange rate for every coin. You will get notification
event whenever price of any coin gets changed. Please note that only updated coin price will be returned.
Topic:
/subscription:coin_prices
Request:
init
Notification:
update
Rate limit: 3
Response: Coin price
Sort: -
(coin_prices / <sym>
)()
Coin to USD exchange rate for specific coin. You will get notification
event whenever price of the specified coin gets changed.
Topic:
/subscription:coin_prices;<sym>
Request:
init
Notification:
update
Rate limit: 3
Response: Coin price
Sort: -
quote_coins()
Example Request
import asyncio
from pprint import pprint
from pydaybit import Daybit
async def daybit_quote_coins():
async with Daybit() as daybit:
pprint(await daybit.quote_coins())
asyncio.get_event_loop().run_until_complete(daybit_quote_coins())
Example Response
{
'BTC': {
'sym': 'BTC'
},
'ETH': {
'sym': 'ETH'
},
'USDT': {
'sym': 'USDT'
}
}
Subscribe to get quote coin list.
Topic:
/subscription:quote_coins
Request:
init
Notification:
insert
,update
,delete
Rate limit: 3
Response: Quote coin
Sort: -
markets()
Example Request
import asyncio
from pprint import pprint
from pydaybit import Daybit
async def daybit_markets():
async with Daybit() as daybit:
pprint(await daybit.markets())
asyncio.get_event_loop().run_until_complete(daybit_markets())
Example Response
{
'BTC-ADA': {
'base': 'ADA',
'buyable': True,
'quote': 'BTC',
'sellable': True,
'tick_levels': 5,
'tick_price': '0.00000001'
},
# ...
'USDT-ETH': {
'base': 'ETH',
'buyable': True,
'quote': 'USDT',
'sellable': True,
'tick_levels': 5,
'tick_price': '0.02000000'
}
}
Subscribe to get basic market data.
Topic:
/subscription:markets
Request:
init
Notification:
insert
,update
,delete
Rate limit: 3
Response: Market
Sort: -
market_summary_intvls()
Example Request
import asyncio
from pprint import pprint
from pydaybit import Daybit
async def daybit_market_summary_intvls():
async with Daybit() as daybit:
pprint(await daybit.market_summary_intvls())
asyncio.get_event_loop().run_until_complete(daybit_market_summary_intvls())
Example Response
{
30: {
'seconds': 30
},
# ...
1440: {
'seconds': 1440
}
}
Subscribe to time intervals of a market price whose unit in second. Each time interval can be used for input of Market summaries.
Topic:
/subscription:market_summary_intvls
Request:
init
Notification:
insert
,update
,delete
Rate limit: 3
Response: Market summary interval
Sort: by
seconds
indesc
market_summaries()
Example Request
import asyncio
from pprint import pprint
from pydaybit import Daybit
async def daybit_market_summaries():
async with Daybit() as daybit:
intvls = sorted((await daybit.market_summary_intvls()).keys())
pprint(await (daybit.market_summaries / intvls[0])())
asyncio.get_event_loop().run_until_complete(daybit_market_summaries())
Example Response
{
'BTC-AMO': {
'base': 'AMO',
'base_vol': '141900.000',
'close': '0.00000046',
'high': '0.00000046',
'low': '0.00000046',
'open': '0.00000046',
'quote': 'BTC',
'quote_vol': '0.065',
'seconds': 30,
'volatility': '0.0000'
},
# ...
'USDT-ETH': {
'base': 'ETH',
'base_vol': '0.275',
'close': '291.82',
'high': '291.82',
'low': '291.82',
'open': '291.82',
'quote': 'USDT',
'quote_vol': '80.251',
'seconds': 30,
'volatility': '0.0000'
}
}
Subscribe to market summaries. For the valid seconds
, please refer Market summary intervals.
Topic:
/subscription:market_summaries;<market_summary_intvl>
Request:
init
Notification:
init
Rate limit: 3
Response: Market summary
Sort: -
order_books()
Example Request
import asyncio
from decimal import Decimal
from pprint import pprint
from pydaybit import Daybit
async def daybit_order_books():
async with Daybit() as daybit:
quote = 'USDT'
base = 'BTC'
multiple = 10
assert multiple in [1, 10, 100, 1000]
price_intvl = Decimal((await daybit.markets())['{}-{}'.format(quote, base)]['tick_price']) * multiple
pprint(await (daybit.order_books / quote / base / price_intvl)())
asyncio.get_event_loop().run_until_complete(daybit_order_books())
Example Response
{
'6475.00000000-6480.00000000': {
'base': 'BTC',
'buy_vol': '0.02086000',
'intvl': '5.00000000',
'max_price': '6480.00000000',
'min_price': '6475.00000000',
'quote': 'USDT',
'sell_vol': '0.00000000'
},
# ...
'7640.00000000-7645.00000000': {
'base': 'BTC',
'buy_vol': '0.00000000',
'intvl': '5.00000000',
'max_price': '7645.00000000',
'min_price': '7640.00000000',
'quote': 'USDT',
'sell_vol': '0.01060000'
}
}
Subscribe to order book by unit price. In the data of order book, there's no id
so you need to compare it with min_price
or max_price
to identify the order book. sell_vol
is aggregated volumes of the range (min_price
, max_price
] and buy_vol
is aggregated volumes of the range [min_price
, max_price
). There is not more than one range that both sell_vol
and buy_vol
are larger than zero.
Valid price_intvl
s is one of [1, 10, 100, 1000] × tick_price
of a market.
Topic:
/subscription:order_books;<quote>;<base>;<price_intvl>
Request:
init
Notification:
init
,upsert
Rate limit: 3
Response: Order book
Sort: by
min_price
indesc
price_history_intvls()
Example Request
import asyncio
from pprint import pprint
from pydaybit import Daybit
async def daybit_price_history_intvls():
async with Daybit() as daybit:
pprint(await daybit.price_history_intvls())
asyncio.get_event_loop().run_until_complete(daybit_price_history_intvls())
Example Response
{
60: {
'seconds': 60
},
# ...
86400: {
'seconds': 86400
}
}
Subscribe to valid time intervals of market price data whose unit are in seconds. A time interval can be used for input of Price histories.
Topic:
/subscription:price_history_intvls
Request:
init
Notification: - (nothing to be reported)
Rate limit: 3
Response: Price history interval
Sort:
seconds
inasc
price_histories()
Example Request
import asyncio
import time
from pprint import pprint
from pydaybit import Daybit
async def daybit_price_histories():
async with Daybit() as daybit:
quote = 'USDT'
base = 'BTC'
intvl = sorted((await daybit.price_history_intvls()).keys())[0]
pprint(
await (daybit.price_histories / quote / base / intvl)(from_time=int(time.time() * 1000 - intvl * 10 * 1000),
to_time=int(time.time() * 1000)))
asyncio.get_event_loop().run_until_complete(daybit_price_histories())
Example Response
{
'USDT-BTC-60-1537351080000': {
'base': 'BTC',
'base_vol': '0',
'close': '6833.00000000',
'end_time': 1537351140000,
'high': '6833.00000000',
'intvl': 60,
'low': '6833.00000000',
'open': '6833.00000000',
'quote': 'USDT',
'quote_vol': '0',
'start_time': 1537351080000
},
# ...
'USDT-BTC-60-1537351680000': {
'base': 'BTC',
'base_vol': '0',
'close': '6833.00000000',
'end_time': 1537351740000,
'high': '6833.00000000',
'intvl': 60,
'low': '6833.00000000',
'open': '6833.00000000',
'quote': 'USDT',
'quote_vol': '0',
'start_time': 1537351680000
}
}
Subscribe to market price data. For the valid intvl
, please refer Price history intervals.
Topic:
/subscription:price_histories;<quote>;<base>;<intvl>
Request:
upsert
Notification:
insert
,update
Rate limit: 8
Response: Price history
Sort: -
Arguments
Parameter | Type | Required | Description |
---|---|---|---|
from_time | unix_timestamp | Required | Start time of the price history range. |
to_time | unix_timestamp | Required | End time of the price history range. |
trades()
Example Request
import asyncio
from pprint import pprint
from pydaybit import Daybit
async def daybit_trades():
async with Daybit() as daybit:
quote = 'USDT'
base = 'BTC'
pprint(await (daybit.trades / quote / base)(size=10))
asyncio.get_event_loop().run_until_complete(daybit_trades())
Example Response
{
40810689: {
'base': 'BTC',
'base_amount': '0.00266000',
'exec_at': 1537350775639,
'id': 40810689,
'price': '6833.00000000',
'quote': 'USDT',
'quote_amount': '18.17578000',
'taker_sold': True
},
# ...
40811438: {
'base': 'BTC',
'base_amount': '0.00458000',
'exec_at': 1537352156105,
'id': 40811438,
'price': '6833.00000000',
'quote': 'USDT',
'quote_amount': '31.29514000',
'taker_sold': True
}
}
Subscribe the trade data of a market.
Topic:
/subscription:trades;<quote>;<base>
Request:
init
Notification:
insert
Rate limit: 3
Response: Trade
Sort: by
id
indesc
Arguments
Parameter | Type | Required | Description |
---|---|---|---|
num_trades | integer | Required | Trade count for retrieving. |
my_users()
Example Request
import asyncio
from pprint import pprint
from pydaybit import Daybit
async def daybit_my_users():
async with Daybit() as daybit:
pprint(await daybit.my_users())
asyncio.get_event_loop().run_until_complete(daybit_my_users())
Example Response
[
{
'maker_fee_rate': '0.001000',
'one_day_wdrl_usd_limit': '5000.00000000',
'pay_fee_with_day': True,
'taker_fee_rate': '0.001000'
}
]
Subscribe to get information of my account.
Topic:
/subscription:my_users
Request:
init
Notification:
init
Rate limit: 3
Response: User
Sort: -
my_assets()
Example Request
import asyncio
from pprint import pprint
from pydaybit import Daybit
async def daybit_my_assets():
async with Daybit() as daybit:
pprint(await daybit.my_assets())
asyncio.get_event_loop().run_until_complete(daybit_my_assets())
Example Response
{
'ADA': {
'available': '700000.000000000000000000',
'coin': 'ADA',
'investment_usd': '0.000000000000000000',
'reserved': '0.000000000000000000',
'total': '700000.000000000000000000',
'visible': True
},
# ...
'ZRX': {
'available': '90000.000000000000000000',
'coin': 'ZRX',
'investment_usd': '0.000000000000000000',
'reserved': '0.000000000000000000',
'total': '90000.000000000000000000',
'visible': True
}
}
Subscribe to get information of my assets.
Topic:
/subscription:my_assets
Request:
init
Notification:
insert
,update
Rate limit: 3
Response: Asset
Sort: -
my_orders()
Example Request
import asyncio
from pprint import pprint
from pydaybit import Daybit
async def daybit_my_orders():
async with Daybit() as daybit:
pprint(await daybit.my_orders(closed=False))
asyncio.get_event_loop().run_until_complete(daybit_my_orders())
Example Response
{
81133319: {
'amount': '0.00020000',
'base': 'BTC',
'cancel_reason': 'user',
'close_type': 'canceled',
'closed_at': 1537339108567,
'cond_arg1': None,
'cond_arg2': None,
'cond_type': 'none',
'filled': '0.00000000',
'filled_quote': '0.00000000',
'id': 81133319,
'placed_amount': '0.00020000',
'placed_at': 1537339108540,
'price': '6040.50000000',
'quote': 'USDT',
'received_at': 1537339108516,
'role': 'both',
'sell': True,
'status': 'closed',
'unfilled': '0.00020000'
},
# ...
82722801: {
'amount': '0.00020000',
'base': 'BTC',
'cancel_reason': None,
'close_type': 'filled',
'closed_at': 1537347509954,
'cond_arg1': None,
'cond_arg2': None,
'cond_type': 'none',
'filled': '0.00020000',
'filled_quote': '1.41820000',
'id': 82722801,
'placed_amount': '0.00020000',
'placed_at': 1537347483279,
'price': '7091.00000000',
'quote': 'USDT',
'received_at': 1537347483275,
'role': 'both',
'sell': False,
'status': 'closed',
'unfilled': '0.00000000'
}
}
Subscribe to get information of my orders.
Topic:
/subscription:my_orders
Request:
upsert
Notification:
insert
,update
Rate limit: 3
Response: Order
Sort: by
id
indesc
Arguments
Parameter | Type | Required | Description |
---|---|---|---|
quote | string | Optional | Quote coin symbol. ex) "BTC" |
base | string | Optional | Base coin symbol. ex) "ETH" |
to_id | integer | Optional | Get my orders that are id is smaller than to_id . |
size | integer | Optional | Order count for retrieving. size ≤ 30. |
sell | boolean | Optional | true for selling order and false for buying order. |
closed | boolean | Optional | Conditions of status to retrieve. false will retrieve orders in received and placed status. true will retrieve orders in closed status. |
my_trades()
Example Request
import asyncio
from pprint import pprint
from pydaybit import Daybit
async def daybit_my_trades():
async with Daybit() as daybit:
pprint(await daybit.my_trades(sell=True, quote='USDT'))
asyncio.get_event_loop().run_until_complete(daybit_my_trades())
Example Response
{
40807547: {
'base': 'BTC',
'base_amount': '0.00020000',
'coin_fee': '0.00141820',
'counterpart': 'user',
'day_fee': '0.00000000',
'exec_at': 1537347408941,
'id': 40807547,
'order_id': 82707048,
'price': '7091.00000000',
'quote': 'USDT',
'quote_amount': '1.41820000',
'sell': True,
'taker_sold': True
},
# ...
40807691: {
'base': 'BTC',
'base_amount': '0.00020000',
'coin_fee': '0.00000000',
'counterpart': 'user',
'day_fee': '0.04415411',
'exec_at': 1537347509915,
'id': 40807691,
'order_id': 82722801,
'price': '7091.00000000',
'quote': 'USDT',
'quote_amount': '1.41820000',
'sell': False,
'taker_sold': True
}
}
Subscribe to get information of my trade data.
Topic:
/subscription:my_trades
Request:
upsert
Notification:
insert
Rate limit: 3
Response: Trade
Sort: by
id
indesc
Arguments
Parameter | Type | Required | Description |
---|---|---|---|
quote | string | Optional | Quote coin symbol. ex) "BTC" |
base | string | Optional | Base coin symbol. ex) "ETH" |
to_id | integer | Optional | Get my orders that are id is smaller than to_id . |
size | integer | Optional | Order count for retrieving. size ≤ 30. |
sell | boolean | Optional | true for selling order and false for buying order. |
my_tx_summaries()
Example Request
import asyncio
from pprint import pprint
from pydaybit import Daybit
async def daybit_my_tx_summaries():
async with Daybit() as daybit:
pprint(await daybit.my_tx_summaries(type='deposit'))
pprint(await daybit.my_tx_summaries(type='wdrl'))
asyncio.get_event_loop().run_until_complete(daybit_my_tx_summaries())
Example Response
# response of daybit.my_tx_summaries(type='deposit')
{
47283: {
'amount': '1.2977',
'coin': 'LTC',
'completed_at': 1537417829032,
'confirm': 3847,
'created_at': 1537417829029,
'deposit_status': 'completed',
'id': 47283,
'req_confirm': 3,
'tx_link_url': 'https://live.blockcypher.com/ltc/tx/a809a19d194d48967f1c8b6aa1dae33d412ece2570fe8d9b751d63a703e15183',
'txid': 'a809a19d194d48967f1c8b6aa1dae33d412ece2570fe8d9b751d63a703e15183',
'type': 'deposit',
'wdrl_status': None,
'wdrl_to_addr': None,
'wdrl_to_org': None,
'wdrl_to_tag': None
},
# ...
47287: {
'amount': '0.01448502',
'coin': 'BTC',
'completed_at': 1537417829091,
'confirm': 955,
'created_at': 1537417829087,
'deposit_status': 'completed',
'id': 47287,
'req_confirm': 3,
'tx_link_url': 'https://live.blockcypher.com/btc/tx/af9648f4c1622b3872649019d4391248d9c93bdd9630e16128431d475d2263a4',
'txid': 'af9648f4c1622b3872649019d4391248d9c93bdd9630e16128431d475d2263a4',
'type': 'deposit',
'wdrl_status': None,
'wdrl_to_addr': None,
'wdrl_to_org': None,
'wdrl_to_tag': None
}
}
# example of daybit.my_tx_summaries(type='wdrl')
{
47291: {
'amount': '100.00000000',
'coin': 'ADA',
'completed_at': None,
'confirm': 0,
'created_at': 1537419011126,
'deposit_status': None,
'id': 47291,
'req_confirm': 10,
'tx_link_url': None,
'txid': None,
'type': 'wdrl',
'wdrl_status': 'queued',
'wdrl_to_addr': '0x2b7cd7f27d21da93395a4c19aea80f8467f93596',
'wdrl_to_org': None,
'wdrl_to_tag': None
}
}
Subscribe to get my transaction summaries.
Topic:
/subscription:my_tx_summaries
Request:
upsert
Notification:
insert
,update
Rate limit: 3
Response: Transaction Summary
Sort: by
id
indesc
Arguments
Parameter | Type | Required | Description |
---|---|---|---|
type | string | Required | One of deposit or wdrl per your purpose. |
to_id | integer | Optional | Get your transactions that are id is smaller than to_id . |
size | integer | Optional | The count of your transactions for retrieving. size ≤ 30. |
my_airdrop_histories()
Example Request
import asyncio
from pprint import pprint
from pydaybit import Daybit
async def daybit_my_airdrop_histories():
async with Daybit() as daybit:
pprint(await daybit.my_airdrop_histories())
asyncio.get_event_loop().run_until_complete(daybit_my_airdrop_histories())
Example Response
{10: {'amount': '200.00000000',
'category': 'project',
'coin': 'DAY',
'exec_at': 1539148862461,
'id': 10}}
Subscribe the history of my airdrops.
Topic:
/subscription:my_airdrop_histories
Request:
upsert
Notification:
insert
Sort: by
id
indesc
Response: Airdrop
arguments
Parameter | Type | Required | Description |
---|---|---|---|
to_id | integer | Optional | Get your airdrop histories that are id is smaller than to_id . |
size | integer | Optional | The count of your airdrop histories for retrieving. size ≤ 30. |
trade_vols()
Example Request
import asyncio
from pprint import pprint
from pydaybit import Daybit
async def daybit_trade_vols():
async with Daybit() as daybit:
pprint(await daybit.trade_vols(size=5))
asyncio.get_event_loop().run_until_complete(daybit_trade_vols())
Example Response
{1542412800000: {'end_time': 1542499200000,
'start_time': 1542412800000,
'usd_amount': '0'},
1542499200000: {'end_time': 1542585600000,
'start_time': 1542499200000,
'usd_amount': '0'},
1542585600000: {'end_time': 1542672000000,
'start_time': 1542585600000,
'usd_amount': '0'},
1542672000000: {'end_time': 1542758400000,
'start_time': 1542672000000,
'usd_amount': '23340096.41952102'},
1542758400000: {'end_time': 1542844800000,
'start_time': 1542758400000,
'usd_amount': '2970733.71822306'}}
Subscribe the volume of Daybit in USD.
Topic:
/subscription:trade_vols
Request:
upsert
Notification:
upsert
Sort: by
start_time
indesc
Response: TradeVolume
arguments
Parameter | Type | Required | Description |
---|---|---|---|
size | integer | Optional | TradeVolume s for retrieving. size ≤ 30. |
day_avgs()
Example Request
import asyncio
from pprint import pprint
from pydaybit import Daybit
async def daybit_day_avgs():
async with Daybit() as daybit:
pprint(await daybit.day_avgs())
asyncio.get_event_loop().run_until_complete(daybit_day_avgs())
Example Response
{1542844800000: {'avg': '63115476.62825952',
'end_time': 1542931200000,
'start_time': 1542844800000}}
Example of Day Contriubtion
import asyncio
from datetime import datetime
from decimal import Decimal
from pydaybit import Daybit
async def daybit_day_contribution():
async with Daybit() as daybit:
day_avgs = (await daybit.day_avgs())[0]
my_day_avgs = (await daybit.my_day_avgs())[0]
start_time = my_day_avgs['start_time']
end_time = my_day_avgs['end_time']
day_avg = Decimal(day_avgs['avg'])
my_day_avg = Decimal(my_day_avgs['avg'])
print('[{} - {}] Estimated My Contribution : {}'.format(datetime.fromtimestamp(start_time / 1000),
datetime.fromtimestamp(end_time / 1000),
(my_day_avg / day_avg).quantize(
Decimal('0.0001'))))
asyncio.get_event_loop().run_until_complete(daybit_day_contribution())
# Output
[2018-11-23 09:00:00 - 2018-11-24 09:00:00] Estimated My Contribution : 0.0001
Subscribe the average of the total volume of distributed DAY as rewards response to a unit period. You would use to calculate your own DAY contribution. See Example of Day Contriubtion
example.
Topic:
/subscription:day_avgs
Request:
upsert
Notification:
upsert
Sort: -
Response: DayAverage
div_plans()
Example Request
import asyncio
from pprint import pprint
from pydaybit import Daybit
async def daybit_div_plans():
async with Daybit() as daybit:
pprint(await daybit.div_plans())
asyncio.get_event_loop().run_until_complete(daybit_div_plans())
Example Response
{1540339200000: {'div_btc': '21.31789479',
'div_count': 1128,
'end_time': 1540425600000,
'start_time': 1540339200000},
...
1542844800000: {'div_btc': '3.83510361',
'div_count': 417,
'end_time': 1542931200000,
'start_time': 1542844800000}}
Subscribe BTC rewards.
Topic:
/subscription:div_plans
Request:
upsert
Notification:
insert
,upsert
Sort: by
end_time
indesc
Response: DivPlan
arguments
Parameter | Type | Required | Description |
---|---|---|---|
size | integer | Optional | The number of DivPlan for retrieving. size ≤ 30. |
to_end_time | unix_timestamp | Optional | a limit respond to end_time . |
my_trade_vols()
Example Request
import asyncio
from pprint import pprint
from pydaybit import Daybit
async def daybit_my_trade_vols():
async with Daybit() as daybit:
pprint(await daybit.my_trade_vols())
asyncio.get_event_loop().run_until_complete(daybit_my_trade_vols())
Example Response
[{'end_time': 1543017600000, 'start_time': 1542931200000, 'usd_amount': '0'}]
Subscribe my trade volume in USD.
Topic:
/subscription:my_trade_vols
Request:
init
Notification:
init
Sort: -
Response: TradeVolume
my_day_avgs()
Example Request
import asyncio
from pprint import pprint
from pydaybit import Daybit
async def daybit_my_day_avgs():
async with Daybit() as daybit:
pprint(await daybit.my_day_avgs())
asyncio.get_event_loop().run_until_complete(daybit_my_day_avgs())
Example Response
[{'avg': '200.00000000',
'end_time': 1543017600000,
'start_time': 1542931200000}]
Subscribe the average of my DAY volume response to a unit period. You would use to calculate your own DAY contribution. See Example of Day Contriubtion
example.
Topic:
/subscription:my_day_avgs
Request:
init
Notification:
init
Sort: -
Response: DayAverage
my_divs()
Example Request
import asyncio
from pprint import pprint
from pydaybit import Daybit
async def daybit_my_divs():
async with Daybit() as daybit:
pprint(await daybit.my_divs())
asyncio.get_event_loop().run_until_complete(daybit_my_divs())
Example Response
{}
Subscribe my BTC rewards.
Topic:
/subscription:my_divs
Request:
upsert
Notification:
insert
,upsert
Sort: by
end_time
indesc
Response: DivPlan
arguments
Parameter | Type | Required | Description |
---|---|---|---|
size | integer | Optional | The number of DivPlan for retrieving. size ≤ 30. |
to_end_time | unix_timestamp | Optional | a limit respond to end_time . |