类似于create an OHLC data from Date, time, price using Javascript,人们如何接受将基本交易数据转换为OHLC(或开盘价,最高价,最低价,收盘价)并将其应用于生成1分钟OHLC的理论?除此之外,我还无法通过提供的代码将纪元时间戳适应ISODate。
var data = [{
"tid": 283945,
"date": 2018-08-02T04:24:53Z,
"amount": "0.08180000",
"price": "501.30"
}, {
"tid": 283947,
"date": 2018-08-02T04:24:53Z,
"amount": "0.06110000",
"price": "490.66"
},
...
];
function convertToOHLC(data) {
// What goes here?
}
convertToOHLC(data);
以下是先前代码的小提琴:https://jsfiddle.net/5dfjhnLw/
答案 0 :(得分:0)
我创建了一个示例,根据您的要求如何将数据转换为ohlc:
TypeError Traceback (most recent call last)
<ipython-input-34-2b1cccfa091b> in <module>()
1 model.compile(optimizer=tf.train.AdamOptimizer(),
2 loss=myloss,
----> 3 metrics=['accuracy'])
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tensorflow/python/keras/engine/training.py in compile(self, optimizer, loss, metrics, loss_weights, sample_weight_mode, weighted_metrics, target_tensors, **kwargs)
172 `optimizer`, `loss`, `metrics` or `sample_weight_mode`.
173 """
--> 174 loss = loss or {}
175 if context.executing_eagerly() and not isinstance(
176 optimizer, (tf_optimizer_module.Optimizer, optimizers.TFOptimizer)):
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tensorflow/python/framework/ops.py in __bool__(self)
663 `TypeError`.
664 """
--> 665 raise TypeError("Using a `tf.Tensor` as a Python `bool` is not allowed. "
666 "Use `if t is not None:` instead of `if t:` to test if a "
667 "tensor is defined, and use TensorFlow ops such as "
TypeError: Using a `tf.Tensor` as a Python `bool` is not allowed. Use `if t is not None:` instead of `if t:` to test if a tensor is defined, and use TensorFlow ops such as tf.cond to execute subgraphs conditioned on the value of a tensor.