R programming for following / Estimate labour please

Discussion in 'App Development' started by jk90029, Jun 20, 2014.

  1. Hi

    I am a R users for many years, but had no API connection experience to brokers.

    Probably IB or Tradeking are possible choice.

    Please just send me a rough estimate for the labour to write R program for the 500 equities in SnP500, as follows


    1) a matrix with 5 rows and 501 columns for intraday quotes
    ( ) AA AAPL ..... ZZZ
    Open xxx xxx xxx
    High xxx xxx
    Low
    Close

    2) a matrix (1001rows and 501 columns) for 1000 daily closes for the 500

    3) If I prepare a matrix as follows, before real order / Some API will send the matrix to the server as soon as current prices hits. For example, there is 10 by 5 matrix (generated by my own software)

    MSFT BUY 25.0 23.0 100
    IBM BUY 85.0 83.0 10
    xxx xxx

    API shall send the total 10 contingent order (As soon as MSFT hits $25 then start real order 100 MSFT BUY at $23.)

    *******************************************************************************

    If someone had experience before, please help me to program with pay.
     
  2. I heard the 2) among the three can be done, without API, by using yahoo or google finance server.
     
  3. 2rosy

    2rosy

    9243 paid up front
     
  4. In us dollar or other currency?

    The three program is running good in Excel VBA now, and like to change its language from Excel to API with R.

    I can provide the VBA source code, if needed, that was running perfectly for more than five years.
     
  5. Interesting idea.

    A few questions.


    Why R? Why not Python, JS, C...?
    On 1 & 2 why use in memory matrices instead of a DB...?
    On 1- if the intraday quote is 5x501 do you only hold 1 candle worth for each stock?
    Why not Nrowsx5colsx501 ... Or add a 6 the column for ticker and have 6xnRows... ?


    If you already have 3) why not start by building 4) an API to one of those brokers... Instead of doing a rewrite, get the whole thing running first on the current excelVBA base and optimize later...?
     
  6. 2rosy

    2rosy

    kuwati dinar
     
  7. 1) Personally I have experience in R and MATLAB(similar to Python) many years. But no experience in JS and C. That is only reason.

    2 )I do NOT understand the "memory" and "DB". Please explain the difference precisely for me.

    3) Of course, 3-dimensional array with dimension c(2000, 4, 501) is already tried. But due to running speed, 4 pieces(OHLC) of matrices with 2000 rows and 501 columns was preferred.

    4) "4) an API to one of those brokers... " is also my choice. For example, if I pay > couple of hundreds (for API labour) at the time account opening, it might a possible good idea. Sometime the pay can be used to subsidize future brokerage. But I heard TradeKing will NOT do that, when I chat with TradeKing before opening a new account.

    If you know any broker, among the cheap fine security company like IB and TradeKing, who has professional staff to solve(convert from VB) it, please let me know.

    Thanks for the helpful advice.
     
  8. If someone has already experience in API for a particular brokerage company, he can be a good candidate for this project

    Also I hope he had VB experience too, for easy conversion. Actually the previous VB work for dynamic (intraday) data reception was written by my friend with pay, since I had almost NO prior knowledge in VB.

    But I should be open minded, for the JS and C selection in the future. I am a frequent flyer so that I can stop a big city like NY or LA, for spare daily visit to him, if he is close to the big city.
     
  9. 1) cool. R may not be the strongest system, but it makes it pretty easy to get everything up and running.

    2) if your dataset is small, then working with dataframes which are kept in RAM is ok; but once the data gets big it starts to slow things down. A database holds the data in the harddrive, and makes it easily available when you need it. So you don't need your program to hold every historic record on RAM while it is running, instead, it just requests what it needs when it needs it from the DB keeping RAM memory free. It also allows you to save results, like calculated indicators and stats, in a way that persists after you restart your system...
    There are several open source db's like SQLite, MySQL or PostgreSQL (my personal favorite) that are build to move big chunks of data around efficiently.
    this post talks about integrating R with sql: http://www.r-bloggers.com/make-r-speak-sql-with-sqldf/

    3) ahh, yes. see point 2).
    :)

    4) Well, some brokers like Ameritrade and IB have their API specs published online, and they use REST (basically URL requests and XML replies), which is pretty easy to setup (basically works like a webscrapper), you enter a URL that gives them a request for quotes, or a request for a new order to buy, or a cancellation... and you get your reply on an XML file.
    there are several URL, XML and REST API"s that could do the job on this link: http://cran.r-project.org/web/views/WebTechnologies.html Xpath is my personal favority for processing XML, takes a little getting used to it, but once you got it running is pretty smooth.
     
  10. vicirek

    vicirek

    jk

    Just to help you out since I do not have time for extra project now.

    First IB API lets you get 100 lines of real time data per account, TradeKing 60 requests per minute so the first question is what is the time period for populating matrix of 500 OHLC data which in any scenario would be out of sync otherwise you run into pacing violation which generates errors (you may overcome it in certain scenarios like requesting and cancelling requests but still there is a limit in number of messages per minute)

    Second matrix is not an issue.

    Now, if you know R then you are already there (http://cran.r-project.org/web/packages/IBrokers/IBrokers.pdf)

    It will connect you to IB and return data as requested. Putting returned data to matrices is trivial in R. Then you need to plug in your code to the source and populate 3rd matrix and submit results to IBrokers for sending to running IB application for execution (you do not connect to server, you connect to running program on your computer supplied by IB that sends it to their server).

    Contact the guy who is the author of the R package, maybe he will help you or direct to appropriate person or try R forums - maybe R finance blog or something similar.

    Memory is computer memory that CPU (computer "brain") can address at run time otherwise called RAM for random access memory; programs and programs data at run time reside in RAM for execution. DB is data base which is structured data store (like table or document store etc. depending on design that is why there are so many of them) with methods to store and query data and can reside in memory or disk or both.
     
    #10     Jun 21, 2014