Bitcoin Forum
May 03, 2024, 10:57:07 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Rbitcoinica  (Read 2385 times)
stochastic (OP)
Hero Member
*****
Offline Offline

Activity: 532
Merit: 500


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.
1714777027
Hero Member
*
Offline Offline

Posts: 1714777027

View Profile Personal Message (Offline)

Ignore
1714777027
Reply with quote  #2

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

Posts: 1714777027

View Profile Personal Message (Offline)

Ignore
1714777027
Reply with quote  #2

1714777027
Report to moderator
stochastic (OP)
Hero Member
*****
Offline Offline

Activity: 532
Merit: 500


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 (OP)
Hero Member
*****
Offline Offline

Activity: 532
Merit: 500


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
*
Offline Offline

Activity: 2058
Merit: 1007


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 (OP)
Hero Member
*****
Offline Offline

Activity: 532
Merit: 500


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: 848
Merit: 1078


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.

DefiDive - Filter the noise
A clean crypto asset management terminal
MusX
Full Member
***
Offline Offline

Activity: 175
Merit: 100


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:  

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