使用C#从日期,时间,价格创建OHLC数据 [英] create an OHLC data from Date, time, price using C#

查看:102
本文介绍了使用C#从日期,时间,价格创建OHLC数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何将这些数据系列数据,时间和价格转换为OHLC或开盘价,最高价,最低价,收盘价。



我正在从事一个比特币项目,希望将这些数据视为烛台图。我在库存溢出中看到了一些有关计算的线程,但是我不明白他们使用的脚本是 使用R从代码数据创建OHLC系列我指的是 Kevin的答案



在此处提供部分数据

  Date,strTime,dblTime,价格,体积,边体积
2014-06- 04,17:00:00.027,0.708333645833333,192575,1,1
2014-06-04,17:00:00.090,0.708334375,192575,1,1
2014-06-04,17: 00:00.178,0.708335393518519,192550,1,-1
2014-06-04,17:00:01.019,0.708345127314815,192575,1,1
2014-06-04,17:00:01.021 ,0.708345150462963,192575,1,1
2014-06-04,17:00:01.037,0.708345335648148,192575,3,3
2014-06-04,17:00:01.037,0.708345335648148,192575 ,3,3
2014-06-04,17:00:01.038,0.708345347222222,192575,1,1
2014-06-04,17:00:01.038,0.708345347222222,192575,10,10
2014-06-04,17:00: 01.038,0.708345347222222,192575,1,1
2014-06-04,17:00:01.038,0.708345347222222,192575,10,10
2014-06-04,17:00:01.038,0.708345347222222, 192575,1,1
2014-06-04,17:00:01.038,0.708345347222222,192575,1,1
2014-06-04,17:00:01.038,0.708345347222222,192575,1, 1
2014-06-04,17:00:01.038,0.708345347222222,192575,1,1
2014-06-04,17:00:01.039,0.708345358796296,192575,1,1
2014-06-04,17:00:01.039,0.708345358796296,192575,1,1
2014-06-04,17:00:01.039,0.708345358796296,192575,2,2
2014-06 -04,17:00:01.039,0.708345358796296,192575,1,1
2014-06-04,17:00:01.039,0.708345358796296,192575,1,1
2014-06-04,17 :00:01.039,0.708345358796296,192575,1,1
2014-06-04,17:00:01.039,0.708345358796296,192600,15,15

如何使用C#为OHLC计算这些数据?我正在使用SciChart制作烛台图。



问候。

解决方案

您拥有逐笔交易数据,每笔交易只有一行。要创建打开,低,高,关闭,您需要创建一个处理每个报价的逻辑。



每个报价:
-如果是第一个当日的价格变动,开盘价 =价格,低的价格=价格,高的价格=前一天的收盘价等于最后的价格。
-如果不是当天的第一个价格变动,则更新低价价格小于低价
-如果不是今天的第一个交易日,如果高价大于高价,则更新高价。



每天累积交易量的想法,这是一个非常重要的指标,因为如果您几乎没有交易量而价格有很大差异,则表明可能操纵市场。



从技术上讲,这只是CSV解析和简单的逻辑。如果您对逻辑有疑问,请告诉我。我认为您的问题是了解市场逻辑,而不是C#逻辑。


I'd like to know how you convert these data series Data, Time, and Price to OHLC or Open, High, Low, Close.

I am working on a bitcoin project and would like to see these data as a candlestick chart. I have seen some threads here in stockoverflow regarding the computation but I don't understand the script they were using "create an OHLC series from ticker data using R" I am referring to "Kevin"'s answer

Providing a partial data here

Date,      strTime,     dblTime,          Price, Volume,SideVolume
2014-06-04,17:00:00.027,0.708333645833333,192575,1,1
2014-06-04,17:00:00.090,0.708334375,192575,1,1
2014-06-04,17:00:00.178,0.708335393518519,192550,1,-1
2014-06-04,17:00:01.019,0.708345127314815,192575,1,1
2014-06-04,17:00:01.021,0.708345150462963,192575,1,1
2014-06-04,17:00:01.037,0.708345335648148,192575,3,3
2014-06-04,17:00:01.037,0.708345335648148,192575,3,3
2014-06-04,17:00:01.038,0.708345347222222,192575,1,1
2014-06-04,17:00:01.038,0.708345347222222,192575,10,10
2014-06-04,17:00:01.038,0.708345347222222,192575,1,1
2014-06-04,17:00:01.038,0.708345347222222,192575,10,10
2014-06-04,17:00:01.038,0.708345347222222,192575,1,1
2014-06-04,17:00:01.038,0.708345347222222,192575,1,1
2014-06-04,17:00:01.038,0.708345347222222,192575,1,1
2014-06-04,17:00:01.038,0.708345347222222,192575,1,1
2014-06-04,17:00:01.039,0.708345358796296,192575,1,1
2014-06-04,17:00:01.039,0.708345358796296,192575,1,1
2014-06-04,17:00:01.039,0.708345358796296,192575,2,2
2014-06-04,17:00:01.039,0.708345358796296,192575,1,1
2014-06-04,17:00:01.039,0.708345358796296,192575,1,1
2014-06-04,17:00:01.039,0.708345358796296,192575,1,1
2014-06-04,17:00:01.039,0.708345358796296,192600,15,15

how do you compute these data for OHLC using C#? I am using SciChart by the way for candlestick chart.

regards .

解决方案

You have the data "tick by tick" you have one line per trade. To create the Open, Low, High, Close, you need to create a logic that process each tick.

for each tick: - If is the first tick of the day, "open" price" = price, low = price, high = price. The close price of the previous day equals the last price. - If not first tick of the day, update low if the price is smaller than low. - If not first tick of the day, update high if the high price is greater than high.

Also, is a good idea to accumulate "Volume" for each day. It's a very important indicator, since if you have a big difference o prices with almost no volume, is a signal of possible market manipulation.

In technical terms, it's just CSV parsing and simple logic. If you have trouble with the logic, please, let me know. I'm suposing that your problem is to understand the market logic, not the C# logic.

这篇关于使用C#从日期,时间,价格创建OHLC数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆