Skip to content

Commit 42f82f7

Browse files
committed
update README.md with errors.
1 parent 6a0f844 commit 42f82f7

File tree

1 file changed

+23
-18
lines changed

1 file changed

+23
-18
lines changed

README.md

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,31 +28,32 @@ The package is built mirroring the names of the api paths. For example:
2828
The endpoints are mirrored from the paths too.
2929

3030
# GET /ver1/bots/pairs_black_list
31-
black_list_pairs = api.ver1.bots.get_pairs_black_list()
31+
error, black_list_pairs = api.ver1.bots.get_pairs_black_list()
3232

3333
# GET /v2/smart_trades/{id}
34-
smart_trades_list = api.v2.smart_trades.get_by_id(id=<your_smart_trade_id>)
34+
error, smart_trades_list = api.v2.smart_trades.get_by_id(id=<your_smart_trade_id>)
3535

3636

3737
You can get all bots with:
3838

39-
bots_list = api.ver1.bots.get()
39+
error, bots_list = api.ver1.bots.get()
4040

4141
Or a single bot with:
4242

43-
bot = api.ver1.bots.get_show_by_id(bot_id=<your_bot_id>)
43+
error, bot = api.ver1.bots.get_show_by_id(bot_id=<your_bot_id>)
4444

4545
Or a smart trade
4646

47-
smart_trade = api.v2.smart_trades.get_by_id(id=9993000)
47+
error, smart_trade = api.v2.smart_trades.get_by_id(id=9993000)
4848

4949
The endpoints return a dict object with added functionality. You can use the object like a normal dictionary
5050
(exactly how you receive from py3cw), or use the added functions.
5151
For example if you want to get the bot max_active_deals you can do both:
5252

53-
bot = api.ver1.bots.get_show_by_id(bot_id=9999999)
54-
max_active_deals = bot['max_active_deals']
55-
max_active_deals = bot.max_active_deals
53+
error, bot = api.ver1.bots.get_show_by_id(bot_id=9999999)
54+
if not error:
55+
max_active_deals = bot['max_active_deals']
56+
max_active_deals = bot.max_active_deals
5657

5758
### Websocket Streams
5859

@@ -117,23 +118,23 @@ Some numeric data fetched from the api is returned as string. For example in the
117118
Now you do not need to bother checking the type of the field and parsing it into the desired type.
118119
This library auto parses these fields:
119120

120-
bot = api.ver1.bots.get_show(9999999)
121+
error, bot = api.ver1.bots.get_show(9999999)
121122
# base_order_volume is a float
122123
base_order_volume = bot.get_base_order_volume()
123124

124125

125126
Parsing (except datetime fields) is done by default.
126127
If you do not want the field to be parsed, and you want the original string to be returned use parsed=False
127128

128-
bot = api.ver1.bots.get_show(9999999)
129+
error, bot = api.ver1.bots.get_show(9999999)
129130
# base_order_volume is a str
130131
base_order_volume = bot.parsed(False).base_order_volume
131132

132133

133134
Some fields like "created_at" are timestamps. You can parse these fields to a python datetime object.
134135
Timestamp fields are NOT parsed by default, only on demand:
135136

136-
account = api.ver1.accounts.get_by_id(8888888)
137+
error, account = api.ver1.accounts.get_by_id(8888888)
137138

138139
# the original string returned by the api
139140
created_at_str = account.created_at
@@ -148,7 +149,7 @@ In order to use the api you need to set the api key and secret. This could be do
148149
To set it globally you need to set the environment variables THREE_COMMAS_API_KEY and THREE_COMMAS_API_SECRET.
149150
To do it per request just pass them into the function:
150151

151-
account = api.ver1.accounts.get_by_id(8888888, api_key='my_key', api_secret='my_secret')
152+
error, account = api.ver1.accounts.get_by_id(8888888, api_key='my_key', api_secret='my_secret')
152153

153154
Request keys have priority. If both global and request keys are set, then the request keys will be used.
154155

@@ -158,18 +159,21 @@ You can set the forced mode globally or also per request.
158159
To set it globally set the environment variable THREE_COMMAS_FORCED_MODE to either paper or real.
159160
To use the forced mode per request pass it as an argument:
160161

161-
paper_deals = api.ver1.deals.get(forced_mode='paper')
162-
real_deals = api.ver1.deals.get(forced_mode='real')
162+
error, paper_deals = api.ver1.deals.get(forced_mode='paper')
163+
error, real_deals = api.ver1.deals.get(forced_mode='real')
163164

164165

165166
### Enums
166167

167168
Some enum fields have functionality.
168169

169-
accounts_list = api_v1.accounts.get_accounts()
170-
for account in accounts_list:
171-
if account.get_market_code().is_binance():
172-
# do stuff with the binance account.
170+
error, accounts_list = api_v1.accounts.get_accounts()
171+
if not error:
172+
for account in accounts_list:
173+
if account.get_market_code().is_binance():
174+
# do stuff with the binance account.
175+
else:
176+
# deal with error here
173177

174178
You can check what enums are available in the three_commas.model.generated_enums package
175179

@@ -226,6 +230,7 @@ You can also set the api key and secret directly in the code. This method is les
226230
}
227231

228232
error, smart_trade_response = api.v2.smart_trades.post(smart_trade)
233+
229234
#### Retrieving a smart trade
230235

231236
error, smart_trade = api.v2.smart_trades.get_by_id(13819196)

0 commit comments

Comments
 (0)