小编Ste*_*gor的帖子

Quanstrat策略 - 错误

我的quanstrat策略返回一个错误,我还没有发现它正在讨论.

策略非常简单:计算给定时间段内的滚动总和.如果滚动金额超过某个阈值,请输入long并提交siultanesouly两个oco订单,止盈和止损在+/- 5%的距离.

代码是:

require("quantstrat")
from <- "2014-09-25"
to <- "2014-10-01"

rm(strategy.st)
try(rm("account.st","portfolio.st"),silent=TRUE)  

.blotter <- new.env()
.strategy <- new.env()

initDate <- as.character(as.Date(from) - 1)
currency("USD")
Sys.setenv(TZ = "UTC")   
symbols <- "data"
stock(symbols, currency = "USD", multiplier = 1)  # Initialisation of the instrument
tradeSize <- 1                                    # Initialisation of trade size
initEq <- 1000                                    # Initialisation of initial equity

strategy.st <- "btc"                              # Initialisation of the strategy
portfolio.st <- "btc"                             # Initialisation of the strategy, must be after strategy
account.st …
Run Code Online (Sandbox Code Playgroud)

r quantstrat

9
推荐指数
1
解决办法
357
查看次数

Windows上的Redis - 配置文件

我刚从这里在Windows上安装了redis服务器,并在没有指定配置文件的默认模式下运行服务器.

如何将配置文件(使用Windows)链接到服务器,如何指定保存dtb的文件夹?

该文件夹如下所示:

  • 文件夹:C:\ Program Files\Redis\conf - 有一些模板conf文件
  • 文件夹:C:\ Program Files\Redis\data - 为空
  • 文件夹:C:\ Program Files\Redis\logs - 为空
  • file:C:\ Program Files\Redis\redis-server.exe
  • file:C:\ Program Files\Redis\redis-cli.

redis

8
推荐指数
1
解决办法
2万
查看次数

麻烦在Ubuntu上安装"rgl"

看来我在Ubuntu上遇到麻烦了.跑步时

install.packages("rgl")
Run Code Online (Sandbox Code Playgroud)

我收到以下错误

checking for gcc... gcc -std=gnu99
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc -std=gnu99 accepts -g... yes
checking for gcc -std=gnu99 option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -std=gnu99 …
Run Code Online (Sandbox Code Playgroud)

r rgl

5
推荐指数
3
解决办法
6488
查看次数

R中的Websocket

我设法通过以下规范在R中建立了与Mtgox websocket的连接:

我使用了从https://github.com/zeenogee/R-Websockets下载的改进的R库“ websocket” :

require("websockets")
con = websocket("https://socketio.mtgox.com/mtgox?Currency=USD")
Run Code Online (Sandbox Code Playgroud)

并成功建立连接。但是,套接字似乎没有广播。我做了一个简单的功能f

  f = function(con) {
  Print("Test Test!", con)
}

set_callback("receive", f, con)

while(TRUE)
  {
  service(con)
  Sys.sleep(0.05)
  }
Run Code Online (Sandbox Code Playgroud)

每当从网络套接字接收到一些数据时,它应该打印一些文本。但是websocket似乎没有触发“接收”方法,并且什么也没有显示。代码以无限循环结束,没有输出。

我知道websocket正在运行,因此代码中肯定有错误。我是否必须以某种方式“ ping”套接字才能开始广播?任何人都有想法如何使其工作?谢谢!

r algorithmic-trading websocket

3
推荐指数
1
解决办法
1351
查看次数

File.exists() 不起作用

我必须要么盲目要么愚蠢,但我无法继续前进:

我有一个变量 sourceName 定义为:

sourceName = file.path(dataDatabase, dates[1], paste0(exchange, "_", ticker, "_trade.csv"))
Run Code Online (Sandbox Code Playgroud)

这是这个字符串:

 "/home/malejg/goxtrader/data/2014-12-12/Bitfinex_BTC_trade.csv"
Run Code Online (Sandbox Code Playgroud)

当我检查文件的存在性时,我得到以下结果:

> file.exists(sourceName)
> [1] TRUE
Run Code Online (Sandbox Code Playgroud)

所以该文件肯定存在。但是当我在 if 语句中使用上面的代码时:

 if(file.exists(sourceName)){
    some sample code here}
Run Code Online (Sandbox Code Playgroud)

它抛出一个错误:

 Error in if (file.exists(sourceName)) { : argument is of length zero
Run Code Online (Sandbox Code Playgroud)

这怎么可能?该代码在 Windows 上运行良好,那么是否存在一些与 Linux 相关的问题?

会议信息:

sessionInfo() R 版本 3.1.2 (2014-10-31) 平台:x86_64-pc-linux-gnu(64 位)

语言环境:[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 [ 7] LC_PAPER=en_US.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

附加的基础包:[1] 统计图形 grDevices utils
数据集方法基础

其他附加包:[1] data.table_1.9.4 xts_0.9-7 …

r

2
推荐指数
1
解决办法
4337
查看次数

串联R中的列表元素

我有一个列表,其中每个元素包含如下字符串:

[[1]] 
 [1] 
 "diane"    "bradbury"

[[2]] 
 [1] "diane"    "bradbury"

 [[3]] 
  [1] "derek" "legg"
Run Code Online (Sandbox Code Playgroud)

我需要获得的是这样的一列数据框:

"diane bradbury" 
"diane bradbury" 
"derek legg"
Run Code Online (Sandbox Code Playgroud)

你能给些建议么?谢谢。

string r list

1
推荐指数
1
解决办法
1494
查看次数

标签 统计

r ×5

algorithmic-trading ×1

list ×1

quantstrat ×1

redis ×1

rgl ×1

string ×1

websocket ×1