Skip to content
Prev 10775 / 15274 Next

Problem with updatePortf

getPrice looks for a price column and it only works if the xts object
has colnames.
Error in getPrice(USDCHF) :
  subscript out of bounds, no price was discernible from the data

You need to add colnames.
Last.Price
2005-09-01     1.2343
2005-09-02     1.2280
2005-09-05     1.2335
2005-09-06     1.2365
2005-09-07     1.2426
2005-09-08     1.2449
2005-09-09     1.2442
2005-09-12     1.2592
2005-09-13     1.2619
2005-09-14     1.2585
2005-09-15     1.2671
2005-09-16     1.2687
2005-09-19     1.2772
2005-09-20     1.2809
2005-09-21     1.2718
2005-09-22     1.2795
2005-09-23     1.2916
2005-09-26     1.2896
2005-09-27     1.2959
2005-09-28     1.2940

Although getPrice is not documented, you can look at its code to see
what it does.  If you do not provide a value for the "prefer"
argument, it looks for a column name that contains the word "price".
If it cannot find that, it looks for "trade".  Finally, it looks for
"close".  If your colnames don't contain any of those words, or if you
want to use a different column, you can specify that with the "prefer"
argument
Bid
2005-09-01 1.2558
2005-09-02 1.2368
2005-09-05 1.2344
2005-09-06 1.2404
2005-09-07 1.2444
2005-09-08 1.2470
2005-09-09 1.2470
2005-09-12 1.2597
2005-09-13 1.2640
2005-09-14 1.2613
2005-09-15 1.2696
2005-09-16 1.2729
2005-09-19 1.2815
2005-09-20 1.2818
2005-09-21 1.2825
2005-09-22 1.2809
2005-09-23 1.2918
2005-09-26 1.2965
2005-09-27 1.2998
2005-09-28 1.2984

Garrett
On Thu, Sep 20, 2012 at 9:30 PM, Worik Stanton <worik.stanton at gmail.com> wrote: