Author

Topic: Rbitcoinica (Read 2412 times)

full member
Activity: 175
Merit: 100
November 26, 2013, 05:01:55 PM
#7
donator
Activity: 848
Merit: 1078
April 04, 2012, 07:49:51 PM
#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.
hero member
Activity: 532
Merit: 500
February 01, 2012, 06: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.
donator
Activity: 2058
Merit: 1007
Poor impulse control.
February 01, 2012, 05:46:45 AM
#4
So this interface could be used by an R tradebot? Sweet!
hero member
Activity: 532
Merit: 500
February 01, 2012, 05: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
hero member
Activity: 532
Merit: 500
January 30, 2012, 07:22:21 AM
#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"
hero member
Activity: 532
Merit: 500
January 30, 2012, 07:11:26 AM
#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.

password <- "yourpassword"">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
Jump to: