forked from bitcoincoltd/bitexthai
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.php
133 lines (129 loc) · 3.37 KB
/
example.php
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
132
133
<?php
include_once('bitexthai.php');
$bitexthai = new bitexthai('your-api-key','your-api-secret','2FA code is enabled');
$test = 'option_history';
switch($test){
case 'order':
if($bitexthai->order(1, 'buy', .0589, 0.0024)){ // Currency Pairing ID, Buy/Sell, Amount, Rate
$order_id = $bitexthai->msg;
echo 'Order has been placed! Order ID: '.$order_id;
}else{
echo 'Order failed: '.$bitexthai->msg;
}
break;
case 'cancel':
if($bitexthai->cancel(1, 11)){ // Currency Pairing ID, Order ID
echo 'Order Cancel';
}else{
echo 'Failed: '.$bitexthai->msg;
}
break;
case 'balance':
if($balance = $bitexthai->balance()){
print_r($balance);
}else{
echo 'Failed: '.$bitexthai->msg;
}
break;
case 'getorders':
if($orders = $bitexthai->getorders(array('type' => 'buy'))){
print_r($orders);
}else{
echo 'Failed: '.$bitexthai->msg;
}
break;
case 'history':
if($history = $bitexthai->history()){
print_r($history);
}else{
echo 'Failed: '.$bitexthai->msg;
}
break;
case 'deposit':
if($address = $bitexthai->deposit('BTC',true)){
echo $address;
}else{
echo 'Failed: '.$bitexthai->msg;
}
break;
case 'withdraw':
if($withdraw = $bitexthai->withdraw('BTC',.59546, '14oPLjoUQ2NrKgKbnaZZkLcky2d5UuhBKd')){ // Currency, Amount, Address
echo 'Done, withdrawal ID: '.$withdraw;
}else{
echo 'Failed: '.$bitexthai->msg;
}
break;
case 'issue':
if($issue = $bitexthai->issue_option(10000, 1, 100, 1, 'call', date("Y-m-d",strtotime("Next Friday")),3)){ // Issue a call for 10,000THB per 1BTC with a price of 100THB
echo 'Option IDs: ';
print_r($issue);
}else{
echo 'Failed: '.$bitexthai->msg;
}
break;
case 'cancel_option':
if($bitexthai->cancel_option(32)){
echo 'Option Cancelled ';
}else{
echo 'Failed: '.$bitexthai->msg;
}
break;
case 'get_issues':
$issues = $bitexthai->get_issues(1,'2014-11-07',''); // Get issues for pairing ID 1 (BTC/THB)
print_r($issues);
break;
case 'bid_option':
if($bid = $bitexthai->bid_option(33,100,3)){ // Bid on 3 options like option_id 33 for a price of 100 (THB)
echo 'Bid entered';
print_r($bid);
}else{
echo 'Failed: '.$bitexthai->msg;
}
break;
case 'get_bids':
$bids = $bitexthai->get_bids(1,'2014-11-07',''); // Get bids for pairing ID 1 (BTC/THB)
print_r($bids);
break;
case 'get_options':
$options = $bitexthai->get_options(1,'2014-11-07',''); // Get bids for pairing ID 1 (BTC/THB)
print_r($options);
break;
case 'sell_option':
if($sell = $bitexthai->sell_option(32, 150)){ // Sell option 32 for 150THB
echo 'Sell success:';
print_r($sell);
}else{
echo 'Failed: '.$bitexthai->msg;
}
break;
case 'exercise_option':
if($bitexthai->exercise_option(32)){ // Exercise option ID 32
echo 'Option was successfully exercised';
}else{
echo 'Failed: '.$bitexthai->msg;
}
break;
case 'option_history':
if($history = $bitexthai->option_history(2)){ // Get history for pairing ID 1 (THB/BTC)
echo 'History:';
print_r($history);
}else{
echo 'Failed: '.$bitexthai->msg;
}
break;
case 'list_billers':
if($billers = $bitexthai->listBillers()){
print_r($billers);
}else{
echo 'Failed: '.$bitexthai->msg;
}
break;
case 'bill_pay':
if($billers = $bitexthai->billPayment(2,50,'0868911218')){ // Topup Happy DTAC 50baht to phone 0868911218
print_r($billers);
}else{
echo 'Failed: '.$bitexthai->msg;
}
break;
}
?>