Skip to content

Commit cc28ae2

Browse files
author
AntonioFasano
committed
bloomr.build: mask sys and xlx funcs
1 parent 314bc58 commit cc28ae2

File tree

9 files changed

+56
-106
lines changed

9 files changed

+56
-106
lines changed

README.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,12 @@ <h3>More options and requirements</h3>
134134
</div>
135135
<div id="internet-connection" class="section level3">
136136
<h3>Internet connection</h3>
137-
<p>Since <code>bloomr.build.R</code> downloads resources from the net, therefore one problem you might face is a download error.</p>
137+
<p>Since <code>bloomr.build.R</code> downloads resources from the net, one problem you might face is a download error.</p>
138138
<p>Based on my experiences, the script does a good job in detecting download errors, despite it is always possible that a corrupted download is not identified.</p>
139-
<p>When a donwnload error is detected, <code>bloomr.build.R</code> make a second attempt. You can control this with:</p>
139+
<p>When a donwnload error is detected, <code>bloomr.build.R</code> makes a second attempt. You can control this with:</p>
140140
<pre><code>makeBloomR(&quot;path\to\workDir&quot;, ndown = n)</code></pre>
141-
<p>where <em>n</em> are the download attempts.</p>
142-
<p>When the maximum number of attempt is reached, the script exits deleting any incompleted file and emitting a message detailing the download error.<br />When you start over (hoping in a better connection), you might not want to download again every and each file, but only those affected by the errors. This is done with the option:</p>
141+
<p>where <em>n</em> are the download attempts.<br />When the maximum number of attempt is reached, the script exits deleting any incompleted file and emitting a message detailing the download error.</p>
142+
<p>When you start over (hoping in a better connection), you might not want to download again every and each file, but only those affected by the errors. This is done with the option:</p>
143143
<pre><code>makeBloomR(&quot;path\to\workDir&quot;, tight = TRUE)</code></pre>
144144
<!-- Local Variables: -->
145145
<!-- mode: markdown -->

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,17 +98,17 @@ If you want to find `BloomR.zip` too in your work directory use:
9898

9999
### Internet connection
100100

101-
Since `bloomr.build.R` downloads resources from the net, therefore one problem you might face is a download error.
101+
Since `bloomr.build.R` downloads resources from the net, one problem you might face is a download error.
102102

103103
Based on my experiences, the script does a good job in detecting download errors, despite it is always possible that a corrupted download is not identified.
104104

105-
When a donwnload error is detected, `bloomr.build.R` make a second attempt. You can control this with:
105+
When a donwnload error is detected, `bloomr.build.R` makes a second attempt. You can control this with:
106106

107107
makeBloomR("path\to\workDir", ndown = n)
108108

109-
where _n_ are the download attempts.
109+
where _n_ are the download attempts.
110+
When the maximum number of attempt is reached, the script exits deleting any incompleted file and emitting a message detailing the download error.
110111

111-
When the maximum number of attempt is reached, the script exits deleting any incompleted file and emitting a message detailing the download error.
112112
When you start over (hoping in a better connection), you might not want to download again every and each file, but only those affected by the errors. This is done with the option:
113113

114114

bloomr.R

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -438,11 +438,6 @@ store(last.day)
438438
store(day.us)
439439

440440

441-
## ----br.attach.test, opts.label='purlme'---------------------------------
442-
### this is just a test
443-
br.attach.test=function() print("attach.test")
444-
store(br.attach.test)
445-
446441
## ----attach, opts.label='purlme'-----------------------------------------
447442
### Make visible br.* in bloomr env and base ns
448443
attach(bloomr)

bloomr.build.R

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ expand=function(){
285285
### Make BloomR directory tree
286286
bloomrTree=function(ndown){
287287

288-
message("Creating BloomR tree")
288+
message("\nCreating BloomR tree")
289289
existMake('bloomR', TRUE, FALSE, "main BloomR dir:")
290290

291291
## Copy R and make site direcory
@@ -364,11 +364,7 @@ initScripts=function(ndown){
364364
download.git("res/tickers.csv", "bloomR/mybloomr/tickers.csv", ,ndown)
365365
download.git("res/tickers.eqt.csv", "bloomR/mybloomr/tickers.eqt.csv", ,ndown)
366366
download.git("tryme.R", "bloomR/mybloomr/tryme.R", ,ndown)
367-
368-
369-
370-
371-
367+
372368
## Make R bootstrapper
373369
makeBoot(ndown)
374370

@@ -394,7 +390,7 @@ Run, main\\bin\\x64\\Rgui.exe --internet2 LANGUAGE=en
394390
download.git("bloomr.ico", to, ,ndown)
395391

396392
## Make exe
397-
cat("Making BloomR executable\n")
393+
cat("\nMaking BloomR executable\n")
398394
cd=normalizePath(ahkdir)
399395
cd= paste0('cd "', cd, '" &')
400396
run="Ahk2Exe.exe /in bloomr.run /icon bloomr.ico /bin \"Unicode 32-bit.bin\""
@@ -423,8 +419,12 @@ PROF=function(){ #Keep this on separate line
423419
library("rJava")
424420
library("Rbbg")
425421
source(paste0(R.home("share"), "/bloomr/bloomr.R"))
426-
source(paste0(R.home("share"), "/bloomr/bloomr.sys.R"))
427-
source(paste0(R.home("share"), "/bloomr/xlx.R"))
422+
423+
assign('bloomr.addons', new.env(parent=asNamespace("base")), envir=asNamespace("base"))
424+
source(paste0(R.home("share"), "/bloomr/bloomr.sys.R"), local=bloomr.addons)
425+
source(paste0(R.home("share"), "/bloomr/xlx.R"), local=bloomr.addons)
426+
attach(bloomr.addons)
427+
428428

429429
## end BloomR----------
430430
}
@@ -436,11 +436,12 @@ PROF=function(){ #Keep this on separate line
436436
makeExe=function(ask,ndown){
437437

438438
message('\nCreating BloomR.exe installer')
439-
to=makePath(G.work, "BloomR.exe")
439+
to=makePath(G.work, "Extract_BloomR.exe")
440440
if(is.path(to)) del.ask(to, ask, "already exists")
441441
del.path(to)
442442

443443
download.git("bloomr.nsi", "bloomr.nsi", ,ndown)
444+
message('Creating self-extracting executable Extract_BloomR.exe. \nThis may take a bit...')
444445
nsi=makePath(G.work, 'bloomr.nsi')
445446
nexe=makePath(G.work, paste0(G.nsiszip,'.d/App/NSIS/makensis.exe'))
446447
cmd=paste(wPath(nexe), "/v2", wPath(nsi))

bloomr.html

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -254,13 +254,6 @@ <h2>Demonstration</h2>
254254
<pre class="r"><code>con=NULL #Simulated mode: replace with con=br.open() on terminal</code></pre>
255255
<pre class="r"><code>data=br.bulk.csv(con, &quot;mybloomr/tickers.csv&quot;) </code></pre>
256256
<pre><code>## Processing Financial ...
257-
##
258-
## Attaching package: 'zoo'
259-
##
260-
## The following objects are masked from 'package:base':
261-
##
262-
## as.Date, as.Date.numeric
263-
##
264257
## Loading 3988 HK Equity
265258
## Loading C US Equity
266259
## Loading 601288 CH Equity
@@ -281,24 +274,27 @@ <h2>Demonstration</h2>
281274
<pre class="r"><code>data</code></pre>
282275
<pre><code>## $Financial
283276
## 3988 HK C US 601288 CH BAC US HSBA LN
284-
## 2015-02-28 NA NA 11.666 NA 10.116
285-
## 2015-03-01 NA 10.327 NA NA NA
286-
## 2015-03-02 10.723 NA 8.144 9.223 10.526
287-
## 2015-03-04 10.437 10.246 NA NA 9.512
277+
## 2015-02-28 NA 11.070 10.444 9.635 10.136
278+
## 2015-03-01 NA 11.749 9.367 NA 9.760
279+
## 2015-03-02 NA NA NA NA 12.508
280+
## 2015-03-03 8.851 NA 10.298 NA NA
281+
## 2015-03-04 9.510 NA NA 10.657 NA
288282
##
289283
## $Technology
290284
## QCOM US CSCO US 700 HK IBM US INTC US
291-
## 2015-02-28 9.264 11.006 NA 10.337 11.405
292-
## 2015-03-01 11.009 10.134 NA 8.566 NA
293-
## 2015-03-02 9.703 10.786 NA NA NA
294-
## 2015-03-03 NA 10.023 6.854 8.297 9.772
295-
## 2015-03-04 NA 8.852 NA 11.110 NA
285+
## 2015-02-28 NA 8.147 NA 10.543 NA
286+
## 2015-03-01 NA 8.834 8.866 NA NA
287+
## 2015-03-02 NA 10.034 8.984 10.006 NA
288+
## 2015-03-03 NA 9.750 NA 9.566 NA
289+
## 2015-03-04 10.397 NA 10.828 NA 9.817
296290
##
297291
## $Indices
298292
## DJI DJUSFN W1TEC
299-
## 2015-03-02 13.374 9.328 10.989
300-
## 2015-03-03 10.374 NA NA
301-
## 2015-03-04 10.180 NA 9.466</code></pre>
293+
## 2015-02-28 9.461 9.118 9.661
294+
## 2015-03-01 10.255 NA 11.603
295+
## 2015-03-02 9.847 10.425 NA
296+
## 2015-03-03 9.993 NA 9.687
297+
## 2015-03-04 8.082 9.797 8.453</code></pre>
302298
<p>Note:</p>
303299
<ul>
304300
<li><p>The name of the securities tickers is stored without the security type: “Equity”, “Index”, etc.<br />If this piece of info is significant for you, pass <code>showtype = TRUE</code>.</p></li>
@@ -468,10 +464,9 @@ <h2>Example</h2>
468464
<pre><code>## Loading MSFT US Equity
469465
## Loading AMZN US Equity</code></pre>
470466
<pre><code>## MSFT US AMZN US
471-
## 2015-02-28 9.980 NA
472-
## 2015-03-02 9.632 9.796
473-
## 2015-03-03 6.868 9.605
474-
## 2015-03-04 11.289 NA</code></pre>
467+
## 2015-03-01 NA 8.664
468+
## 2015-03-02 9.701 NA
469+
## 2015-03-04 11.072 NA</code></pre>
475470
<pre class="r"><code>br.close(con) # Use the token to release the connection</code></pre>
476471
</div>
477472
<div id="see-also" class="section level2">
@@ -699,9 +694,6 @@ <h2>Arguments</h2>
699694
<div id="details-6" class="section level2">
700695
<h2>Details</h2>
701696
<p>If <code>component</code> is <code>day</code>, <code>month</code> or <code>year</code>: <code>component(d)</code> returns the <em>component</em> of the date <code>d</code> as an integer; <code>component(d, n)</code> returns the date <code>d</code> with the <em>component</em> set to the integer <code>n</code>; <code>component(d)= n</code> sets to the <em>component</em> of the date <code>d</code> to the integer <code>n</code>.<br /><code>%+%</code> and <code>%-%</code> add and subtract months to a date.<br /><code>last.day</code> returns last day of the month as an integer. <code>day.us</code> calculates date differences with the US convention.</p>
702-
<pre class="r"><code>### this is just a test
703-
br.attach.test()</code></pre>
704-
<pre><code>## [1] &quot;attach.test&quot;</code></pre>
705697
<!-- Local Variables: -->
706698
<!-- mode: rmd -->
707699
<!-- End: -->

bloomr.md

Lines changed: 18 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ R topics documented:
2222

2323

2424

25-
2625
br.bdh{#br.bdh}
2726
===============
2827
*Historical data*
@@ -262,13 +261,6 @@ data=br.bulk.csv(con, "mybloomr/tickers.csv")
262261

263262
```
264263
## Processing Financial ...
265-
##
266-
## Attaching package: 'zoo'
267-
##
268-
## The following objects are masked from 'package:base':
269-
##
270-
## as.Date, as.Date.numeric
271-
##
272264
## Loading 3988 HK Equity
273265
## Loading C US Equity
274266
## Loading 601288 CH Equity
@@ -299,24 +291,27 @@ data
299291
```
300292
## $Financial
301293
## 3988 HK C US 601288 CH BAC US HSBA LN
302-
## 2015-02-28 NA NA 11.666 NA 10.116
303-
## 2015-03-01 NA 10.327 NA NA NA
304-
## 2015-03-02 10.723 NA 8.144 9.223 10.526
305-
## 2015-03-04 10.437 10.246 NA NA 9.512
294+
## 2015-02-28 NA 11.070 10.444 9.635 10.136
295+
## 2015-03-01 NA 11.749 9.367 NA 9.760
296+
## 2015-03-02 NA NA NA NA 12.508
297+
## 2015-03-03 8.851 NA 10.298 NA NA
298+
## 2015-03-04 9.510 NA NA 10.657 NA
306299
##
307300
## $Technology
308301
## QCOM US CSCO US 700 HK IBM US INTC US
309-
## 2015-02-28 9.264 11.006 NA 10.337 11.405
310-
## 2015-03-01 11.009 10.134 NA 8.566 NA
311-
## 2015-03-02 9.703 10.786 NA NA NA
312-
## 2015-03-03 NA 10.023 6.854 8.297 9.772
313-
## 2015-03-04 NA 8.852 NA 11.110 NA
302+
## 2015-02-28 NA 8.147 NA 10.543 NA
303+
## 2015-03-01 NA 8.834 8.866 NA NA
304+
## 2015-03-02 NA 10.034 8.984 10.006 NA
305+
## 2015-03-03 NA 9.750 NA 9.566 NA
306+
## 2015-03-04 10.397 NA 10.828 NA 9.817
314307
##
315308
## $Indices
316309
## DJI DJUSFN W1TEC
317-
## 2015-03-02 13.374 9.328 10.989
318-
## 2015-03-03 10.374 NA NA
319-
## 2015-03-04 10.180 NA 9.466
310+
## 2015-02-28 9.461 9.118 9.661
311+
## 2015-03-01 10.255 NA 11.603
312+
## 2015-03-02 9.847 10.425 NA
313+
## 2015-03-03 9.993 NA 9.687
314+
## 2015-03-04 8.082 9.797 8.453
320315
```
321316

322317
Note:
@@ -621,10 +616,9 @@ br.bulk.tiks(con, c("MSFT US", "AMZN US"), addtype=TRUE)
621616

622617
```
623618
## MSFT US AMZN US
624-
## 2015-02-28 9.980 NA
625-
## 2015-03-02 9.632 9.796
626-
## 2015-03-03 6.868 9.605
627-
## 2015-03-04 11.289 NA
619+
## 2015-03-01 NA 8.664
620+
## 2015-03-02 9.701 NA
621+
## 2015-03-04 11.072 NA
628622
```
629623

630624
```r
@@ -889,17 +883,6 @@ If `component` is `day`, `month` or `year`: `component(d)` returns the *componen
889883

890884

891885

892-
```r
893-
### this is just a test
894-
br.attach.test()
895-
```
896-
897-
```
898-
## [1] "attach.test"
899-
```
900-
901-
902-
903886

904887

905888

bloomr.pdf

-283 Bytes
Binary file not shown.

bloomr.rmd

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ knit_hooks$set(purl = hook_purl)
4444
```
4545

4646

47-
4847
```{r store, opts.label='purlme'}
4948
## Purl this first
5049
## Store br.* objects in bloomr env in base namespace
@@ -1198,16 +1197,6 @@ topics=function(){
11981197
}
11991198
```
12001199

1201-
```{r br.attach.test, opts.label='purlme'}
1202-
### this is just a test
1203-
br.attach.test=function() print("attach.test")
1204-
store(br.attach.test)
1205-
```
1206-
```{r br.attach.test.2, opts.label='demofull'}
1207-
### this is just a test
1208-
br.attach.test()
1209-
```
1210-
12111200

12121201
```{r attach, opts.label='purlme'}
12131202
### Make visible br.* in bloomr env and base ns
@@ -1216,16 +1205,7 @@ rm(store)
12161205
```
12171206

12181207
```{r build, purl=FALSE, eval=FALSE, include=FALSE}
1219-
require(knitr)
1220-
require(rmarkdown)
12211208
opts_chunk$set(tidy.opts=list(width.cutoff=60))
1222-
#knit("bloomr.rmd")
1223-
#purl("bloomr.rmd")
1224-
#topics()
1225-
#render("bloomr.md", html_document())
1226-
#render("bloomr.md", pdf_document())
1227-
#render("README.md", html_document())
1228-
12291209
knit2=function(file){
12301210
require(knitr); require(rmarkdown)
12311211
fse=tools:::file_path_sans_ext(file)
@@ -1241,7 +1221,6 @@ knit2=function(file){
12411221
knit2("bloomr.rmd")
12421222
12431223
1244-
12451224
## if with markdown lib, but topics needs rewrite
12461225
## shell("pandoc bloomr.md -o bloomr.pdf", shell=Sys.getenv("COMSPEC"))
12471226
## markdownToHTML("bloomr.md", "bloomr.html")

xlx.help.Rmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ Currently the script is not in package form so, after downloading it, just sour
121121
source('path\to\xlx.r')
122122

123123
```{r xlx.source, include=FALSE}
124-
source('xlx.r')
124+
source('xlx.R')
125125
```
126126

127127

0 commit comments

Comments
 (0)