chenchunyu88 (OP)
|
|
November 12, 2013, 03:33:12 AM |
|
#realtime price difference between coinbase and btcchina with chart #programmed in R #please install R and required package before running the 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") }
|
|
|
|
|
|
|
|
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.
|
|
|
|
Vycid
Sr. Member
Offline
Activity: 336
Merit: 250
♫ the AM bear who cares ♫
|
|
November 12, 2013, 03:36:48 AM |
|
#realtime price difference between coinbase and btcchina with chart #programmed in R #please install R and required package before running the 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: 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
|
|
November 12, 2013, 11:42:51 AM |
|
Hi, cannot understand how do you suggest to normalie CNY and USD? what conversion rate do you use for comparison?
|
|
|
|
mvidetto
|
|
November 12, 2013, 08:42:43 PM |
|
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.
|
|
|
|
|
grbox2001
Member
Offline
Activity: 119
Merit: 100
|
|
December 02, 2013, 12:41:37 PM |
|
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)
|
|
December 02, 2013, 11:06:51 PM |
|
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.
|
|
|
|
|