Bitcoin Forum
December 06, 2016, 10:14:39 PM *
News: To be able to use the next phase of the beta forum software, please ensure that your email address is correct/functional.
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: Rbitcoinica  (Read 2208 times)
stochastic
Hero Member
*****
Offline Offline

Activity: 532


View Profile
January 30, 2012, 12:11:26 PM
 #1

Motivated by my inability to understand python to use the Bitcoinica API with Python.  I coded some functions to use in R.

Get it on Git

NOTE:  This is still in development but if anyone uses this and finds any bugs let me know.

Usage is simple.  First have R installed.  This has only been tested in version 2.14. 

On Ubuntu I did:

Code:
$ sudo apt get- install R

In Mac they have a package to do the hard work for you.

In Windows I have no idea.

Then open it up install the necessary packages.  They are all available on CRAN so just install like:

Code:
install.packages("RCurl","rjson","xts")

First you need to have your username and password on there.

username <- "yourusername"
password <- "yourpassword"


You can then paste all the functions in there.  The only one not really working is for canceling orders.

Then call the function

Code:
a = tick(pair="BTCUSD")
a
   buying   pair selling                Time  spread
1 5.54132 BTCUSD 5.59863 2012-01-30 11:33:53 0.05731

Output is in data frames.

One thing I added is a liquidate function.  ( position.liquidate ) So if you freak out you can just type position.liquidate() and your active position will be gone. 

If you found this useful please donate:  18DjCVYqbHo6vnEZvVkp9ZNNWHJFnHQoyw

Introducing constraints to the economy only serves to limit what can be economical.
1481062479
Hero Member
*
Offline Offline

Posts: 1481062479

View Profile Personal Message (Offline)

Ignore
1481062479
Reply with quote  #2

1481062479
Report to moderator
1481062479
Hero Member
*
Offline Offline

Posts: 1481062479

View Profile Personal Message (Offline)

Ignore
1481062479
Reply with quote  #2

1481062479
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1481062479
Hero Member
*
Offline Offline

Posts: 1481062479

View Profile Personal Message (Offline)

Ignore
1481062479
Reply with quote  #2

1481062479
Report to moderator
stochastic
Hero Member
*****
Offline Offline

Activity: 532


View Profile
January 30, 2012, 12:22:21 PM
 #2

The candlesticks function actually outputs the data in xts format.  This allows for indexed time series, which is required for the quantmod package.  I plan on modifying my current mtgoxUSD backtester with Bitcoinica's own data set using this function.

The other thing to fix is with the cancel order function.  Once I find out how to command a DELETE request then it will work.  I know how to get it done in R, but Bitcoinica uses a format _method=DELETE, and RCurl does not like that underscore in "method"

Introducing constraints to the economy only serves to limit what can be economical.
stochastic
Hero Member
*****
Offline Offline

Activity: 532


View Profile
February 01, 2012, 10:33:53 AM
 #3

v 0.2

A few bug fixes from coding in the middle of the night.

Also added the delete current order function.

https://github.com/ktdservices/Rbitcoinica

Quote
#############################################################################
# Rbitcoinica v 0.2
#############################################################################
# Dislcaimer: Use at your own risk. We make no gaurantees that this will work. Please
# be advised that bitcoin is highly volitile and you can lose money.
#
# Questions: Visit http://www.stochastically.com
# Donations: 18DjCVYqbHo6vnEZvVkp9ZNNWHJFnHQoyw
#
# This software is released under the GNU General Public License,
# version 3 (GPL-3.0)
# http://www.opensource.org/licenses/gpl-3.0.htmlthis
#
# Purpose: To utizilize the Bitcoinica API for utilization in R for statistical
# analysis and trading.
#
# R is a free software environemnt for statistical computing and graphics.
# It is platform independent. To download see http://www.r-project.org/
#
# Bitcoin is a peer-to-peer digital currency that enables instant payments to anyone.
# For more information see http://www.bitcoin.org
#
# Version Changes:
# v.0.1 - just mimic the Bitcoinica API with R functions
# v.0.2 - Minor bug fixes
          Added a function to delete an existing order
         
###############################################################################
#
# To run first download and/or load the 3 required R packages. You can do this by typing
install.packages("RCurl","rjson","xts")

# After that is completed enter your username and password into R
username = "yourusername"
password = "yourpassword"

# Then just copy and paste the functions into R.

# To run a function type the function name and any variables it has.

    y = tick(pair="BTCUSD")

# Most of the functions have output in data frames.

   buying pair selling Time spread
1 5.54132 BTCUSD 5.59863 2012-01-30 11:33:53 0.05731

#################################################################################
# QUESTIONS:
#
# If you are confused then feel free to contact me. I can be found on
# http://www.bitcointalk.org, username dropoutbox
#
# Donations: 18DjCVYqbHo6vnEZvVkp9ZNNWHJFnHQoyw

Introducing constraints to the economy only serves to limit what can be economical.
organofcorti
Donator
Legendary
*
Online Online

Activity: 1960


Poor impulse control.


View Profile WWW
February 01, 2012, 10:46:45 AM
 #4

So this interface could be used by an R tradebot? Sweet!

Bitcoin network and pool analysis 12QxPHEuxDrs7mCyGSx1iVSozTwtquDB3r
follow @oocBlog for new post notifications
stochastic
Hero Member
*****
Offline Offline

Activity: 532


View Profile
February 01, 2012, 11:13:40 AM
 #5

So this interface could be used by an R tradebot? Sweet!

Exactly.  Using quantmod and quantstrat with this can make quick trading platforms.  If I could order food on R my life would be complete.

Introducing constraints to the economy only serves to limit what can be economical.
Seal
Donator
Hero Member
*
Offline Offline

Activity: 833


View Profile WWW
April 05, 2012, 12:49:51 AM
 #6

Hey stochastic,

I was pointed this way from this post: https://bitcointalk.org/index.php?topic=74384.20;topicseen

I've written a handful of basic trading bots in PHP and am interested in learning something new that'll let me perform some kind of statistical analysis based upon the usual technical indicators.

Sorry if this is a little off topic to your OP but as you seem to know, can you give us your two cents on R and how it compares to the other languages?

Also is R powerful enough to automatically place trades or can it interface with some existing classes I have written in PHP to place the trades for me?
*edit* I had a look at your code in GIT and it does place trades...

... I'm just trying to get an idea of the language as a whole as I have the intention to invest a serious amount of time and effort into developing a new trading bot. I want to pick the right language to learn from the start.

MusX
Full Member
***
Offline Offline

Activity: 177


View Profile
November 26, 2013, 10:01:55 PM
 #7

anyone using R might be interested of it: https://bitcointalk.org/index.php?topic=343504

Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!