Bitcoin Forum
April 26, 2024, 07:55:09 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: for those who have coinbase and btcchina account  (Read 2714 times)
chenchunyu88 (OP)
Full Member
***
Offline Offline

Activity: 126
Merit: 100



View Profile WWW
November 12, 2013, 03:33:12 AM
 #1

#realtime price difference between coinbase and btcchina with chart
#programmed in R
#please install R and required package before running the code

Code:
library(rjson)
library(RCurl)
require(tcltk)
n=10 #number of BTC you are trading
wu_fee=30 #fee that use western union to transfer money from China to US
diffs<-c()
count<-0
while(TRUE)
{


count=count+1
result = tryCatch({
tt<-fromJSON(getURL("https://coinbase.com/api/v1/prices/buy")) #get real time trading data
bc<-fromJSON(getURL("https://vip.btcchina.com/bc/ticker"))
}, warning = function(w) {
print("internet problem")
}, error = function(e) {
print("internet problem")
})
  

buy_price<-as.numeric(tt$subtotal$amount)
tx_fee<-as.numeric(tt$fees[[1]]$coinbase$amount)
bank_fee<-as.numeric(tt$fees[[2]]$bank$amount)

buy_total<-buy_price*n+tx_fee*n+bank_fee



sell_price<-as.numeric(bc$ticker$buy)
ex_rate=6.1
bank_fee_sell=0.01

total_sell<-sell_price*n*(1-bank_fee_sell)/ex_rate
diff<-total_sell-buy_total-wu_fee
print(diff)
if(diff>300) #alert trade if diff is greater than 300 USD, change it yourself as needed
{
ReturnVal <- tkmessageBox(title = "Trade Now",
   message = "Trade Now", icon = "info", type = "ok")
}
if(count>=500)
{
count=0
diffs=diffs[-c(1:400)]
}
diffs<-c(diffs,diff)
plot(diffs,type="l")
}

1714118109
Hero Member
*
Offline Offline

Posts: 1714118109

View Profile Personal Message (Offline)

Ignore
1714118109
Reply with quote  #2

1714118109
Report to moderator
1714118109
Hero Member
*
Offline Offline

Posts: 1714118109

View Profile Personal Message (Offline)

Ignore
1714118109
Reply with quote  #2

1714118109
Report to moderator
The Bitcoin network protocol was designed to be extremely flexible. It can be used to create timed transactions, escrow transactions, multi-signature transactions, etc. The current features of the client only hint at what will be possible in the future.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714118109
Hero Member
*
Offline Offline

Posts: 1714118109

View Profile Personal Message (Offline)

Ignore
1714118109
Reply with quote  #2

1714118109
Report to moderator
1714118109
Hero Member
*
Offline Offline

Posts: 1714118109

View Profile Personal Message (Offline)

Ignore
1714118109
Reply with quote  #2

1714118109
Report to moderator
1714118109
Hero Member
*
Offline Offline

Posts: 1714118109

View Profile Personal Message (Offline)

Ignore
1714118109
Reply with quote  #2

1714118109
Report to moderator
Vycid
Sr. Member
****
Offline Offline

Activity: 336
Merit: 250


♫ the AM bear who cares ♫


View Profile
November 12, 2013, 03:36:48 AM
 #2

#realtime price difference between coinbase and btcchina with chart
#programmed in R
#please install R and required package before running the code

Code:
library(rjson)
library(RCurl)
require(tcltk)
n=10 #number of BTC you are trading
wu_fee=30 #fee that use western union to transfer money from China to US
diffs<-c()
count<-0
while(TRUE)
{


count=count+1
result = tryCatch({
tt<-fromJSON(getURL("https://coinbase.com/api/v1/prices/buy")) #get real time trading data
bc<-fromJSON(getURL("https://vip.btcchina.com/bc/ticker"))
}, warning = function(w) {
print("internet problem")
}, error = function(e) {
print("internet problem")
})
  

buy_price<-as.numeric(tt$subtotal$amount)
tx_fee<-as.numeric(tt$fees[[1]]$coinbase$amount)
bank_fee<-as.numeric(tt$fees[[2]]$bank$amount)

buy_total<-buy_price*n+tx_fee*n+bank_fee



sell_price<-as.numeric(bc$ticker$buy)
ex_rate=6.1
bank_fee_sell=0.01

total_sell<-sell_price*n*(1-bank_fee_sell)/ex_rate
diff<-total_sell-buy_total-wu_fee
print(diff)
if(diff>300) #alert trade if diff is greater than 300 USD, change it yourself as needed
{
ReturnVal <- tkmessageBox(title = "Trade Now",
   message = "Trade Now", icon = "info", type = "ok")
}
if(count>=500)
{
count=0
diffs=diffs[-c(1:400)]
}
diffs<-c(diffs,diff)
plot(diffs,type="l")
}

I'm a little confused about this line:

Code:
wu_fee=30 #fee that use western union to transfer money from China to US

Is this really possible? I didn't realize it was so easy to send money out of China, especially if you're a US resident.

genuise
Sr. Member
****
Offline Offline

Activity: 379
Merit: 250


View Profile WWW
November 12, 2013, 11:42:51 AM
 #3

Hi, cannot understand how do you suggest to normalie CNY and USD? what conversion rate do you use for comparison?

mvidetto
Sr. Member
****
Offline Offline

Activity: 462
Merit: 250


View Profile
November 12, 2013, 08:42:43 PM
 #4

Hi, cannot understand how do you suggest to normalie CNY and USD? what conversion rate do you use for comparison?

I would guess .16 dollar = 1 yuan.  Either way its still a pain in the ass to exploit the arbitrage.
fone-btc
Newbie
*
Offline Offline

Activity: 7
Merit: 0


View Profile
November 14, 2013, 07:39:28 AM
 #5

More and more traders are watching the BTC China price translated to USD. This app just added a real-time BTC China feed translated to USD in its in-app purchase version. I used it to get notification that the $400 level was crossed yesterday.  https://play.google.com/store/apps/details?id=com.softmachines.android.bitcoinalerts
grbox2001
Member
**
Offline Offline

Activity: 119
Merit: 100


View Profile
December 02, 2013, 12:41:37 PM
 #6

I tried to run this on windows with R and the installed packages. It kept saying this, "[1] "internet problem"
Error: object 'tt' not found"

I would be interested in any script, website, that could chart and compare coinbase and btcchina if anyone knows of others or could tell me why this doesn't run.
chenchunyu88 (OP)
Full Member
***
Offline Offline

Activity: 126
Merit: 100



View Profile WWW
December 02, 2013, 11:06:51 PM
 #7

I have no problem with the code. Internet problem means the program cannot get the price from coinbase server or btcchina server.

I'll put the monitoring service online in the few days.

I tried to run this on windows with R and the installed packages. It kept saying this, "[1] "internet problem"
Error: object 'tt' not found"

I would be interested in any script, website, that could chart and compare coinbase and btcchina if anyone knows of others or could tell me why this doesn't run.

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!