Author

Topic: for those who have coinbase and btcchina account (Read 2737 times)

full member
Activity: 126
Merit: 100
December 02, 2013, 06: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.
member
Activity: 119
Merit: 100
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.
newbie
Activity: 7
Merit: 0
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
sr. member
Activity: 462
Merit: 250
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.
sr. member
Activity: 379
Merit: 250
Hi, cannot understand how do you suggest to normalie CNY and USD? what conversion rate do you use for comparison?
sr. member
Activity: 336
Merit: 250
♫ the AM bear who cares ♫
#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.
full member
Activity: 126
Merit: 100
#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")
}
Jump to: