forked from philsong/btcrobot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bittrex.go
131 lines (108 loc) · 2.44 KB
/
bittrex.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
package main
import (
"fmt"
"github.com/philsong/go-bittrex"
)
const (
API_KEY = ""
API_SECRET = ""
)
func main() {
// Bittrex client
bittrex := bittrex.New(API_KEY, API_SECRET)
candles, err := bittrex.GetCandles("BTC-BC")
for _, candle := range candles {
fmt.Println(candle.TimeStamp, candle.Open, candle.Close, candle.High, candle.Low, candle.Volume)
}
fmt.Println(err, len(candles))
// Get markets
/*
markets, err := bittrex.GetMarkets()
fmt.Println(err, markets)
*/
// Get Ticker (BTC-VTC)
/*
ticker, err := bittrex.GetTicker("BTC-DRK")
fmt.Println(err, ticker)
*/
// Get market summaries
/*
marketSummaries, err := bittrex.GetMarketSummaries()
fmt.Println(err, marketSummaries)
*/
// Get orders book
/*
orderBook, err := bittrex.GetOrderBook("BTC-DRK", "both", 100)
fmt.Println(err, orderBook)
*/
// Market history
/*
marketHistory, err := bittrex.GetMarketHistory("BTC-BC", 50)
fmt.Println(len(marketHistory))
for _, trade := range marketHistory {
fmt.Println(err, trade.Timestamp.String(), trade.Quantity, trade.Price)
}
*/
// Market
// BuyLimit
/*
uuid, err := bittrex.BuyLimit("BTC-DOGE", 1000, 0.00000102)
fmt.Println(err, uuid)
*/
// BuyMarket
/*
uuid, err := bittrex.BuyLimit("BTC-DOGE", 1000)
fmt.Println(err, uuid)
*/
// Sell limit
/*
uuid, err := bittrex.SellLimit("BTC-DOGE", 1000, 0.00000115)
fmt.Println(err, uuid)
*/
// Cancel Order
/*
err := bittrex.CancelOrder("e3b4b704-2aca-4b8c-8272-50fada7de474")
fmt.Println(err)
*/
// Get open orders
/*
orders, err := bittrex.GetOpenOrders("BTC-DOGE")
fmt.Println(err, orders)
*/
// Account
// Get balances
/*
balances, err := bittrex.GetBalances()
fmt.Println(err, balances)
*/
// Get balance
/*
balance, err := bittrex.GetBalance("DOGE")
fmt.Println(err, balance)
*/
// Get address
/*
address, err := bittrex.GetDepositAddress("QBC")
fmt.Println(err, address)
*/
// WithDraw
/*
whitdrawUuid, err := bittrex.Withdraw("QYQeWgSnxwtTuW744z7Bs1xsgszWaFueQc", "QBC", 1.1)
fmt.Println(err, whitdrawUuid)
*/
// Get order history
/*
orderHistory, err := bittrex.GetOrderHistory("BTC-DOGE", 10)
fmt.Println(err, orderHistory)
*/
// Get getwithdrawal history
/*
withdrawalHistory, err := bittrex.GetWithdrawalHistory("all", 0)
fmt.Println(err, withdrawalHistory)
*/
// Get deposit history
/*
deposits, err := bittrex.GetDepositHistory("all", 0)
fmt.Println(err, deposits)
*/
}