1 | _ = require 'lodash'
|
2 |
|
3 | default_config = require './config'
|
4 |
|
5 | module.exports = ( api_key, referral_id ) ->
|
6 |
|
7 | if not api_key
|
8 | console.warn "Warning: api_key is required in order to call 1Broker's API"
|
9 | return
|
10 |
|
11 | config = _.defaults { api_key, referral_id }, default_config
|
12 |
|
13 |
|
14 |
|
15 |
|
16 | api = ( file ) ->
|
17 | _.partial( require( "./api/#{file}"), config )
|
18 |
|
19 | client =
|
20 | user :
|
21 | details : api 'user/details'
|
22 | overview : api 'user/overview'
|
23 | bitcoin_deposit_address: api 'user/bitcoin_deposit_address'
|
24 | transaction_log : api 'user/transaction_log'
|
25 | quota_status : api 'user/quota_status'
|
26 |
|
27 | order :
|
28 | open : api 'order/open'
|
29 | create : api 'order/create'
|
30 | cancel : api 'order/cancel'
|
31 |
|
32 | position :
|
33 | open : api 'position/open'
|
34 | edit : api 'position/edit'
|
35 | close : api 'position/close'
|
36 | close_cancel : api 'position/close_cancel'
|
37 | history : api 'position/history'
|
38 |
|
39 | market :
|
40 | categories : api 'market/categories'
|
41 | list : api 'market/list'
|
42 | details : api 'market/details'
|
43 | quotes : api 'market/quotes'
|
44 | bars : api 'market/bars'
|
45 | ticks : api 'market/ticks'
|
46 |
|
47 |
|
48 |
|
49 | info : module.exports.info
|
50 | add : module.exports.add
|
51 | get : module.exports.get
|
52 | calculate : module.exports.calculate
|
53 |
|
54 |
|
55 |
|
56 |
|
57 | helper = ( file ) ->
|
58 | _.partial( require( "./helpers/#{file}"), client )
|
59 |
|
60 |
|
61 | client.long = helper 'long'
|
62 | client.short = helper 'short'
|
63 |
|
64 |
|
65 | return client
|
66 |
|
67 |
|
68 |
|
69 | module.exports.info =
|
70 | symbols : require './info/symbols'
|
71 | details : require './info/details'
|
72 |
|
73 | module.exports.add =
|
74 | points : require './helpers/add/points'
|
75 | percentage : require './helpers/add/percentage'
|
76 |
|
77 | module.exports.get =
|
78 | points : require './helpers/get/points'
|
79 | percentage : require './helpers/get/percentage'
|
80 |
|
81 | module.exports.calculate = require './helpers/calculate'
|