3
$\begingroup$

I have been working with TeaFile from discreteLogic and I'm strugling to understand how i can insert data inside a file.

Let's take this example:

using (var tf = TeaFile<Tick>.OpenWrite(filename))
  {
    tf.Write(new Tick { Time = t, Price = p });
    tf.Write(new Tick { Price = 15, Time = DateTime.Now, Volume = 1700 }); 
  }

If you want to use this function one time only, the following line:

tf.Write(new Tick { Price = 15, Time = DateTime.Now, Volume = 1700 });

will write all the information inside the file, so it works fine!

But if you have data coming from any data provider you need to use this other function where t and p obviously change all the time:

tf.Write(new Tick { Time = t, Price = p });

The problem is that inside the file you will find only the latest value and not a list, it it overwriting the latest value every time without creating a list.

So the question is how can I insert one after the other, creating a list of values instead of overwriting the same row all the time? Into the website (http://discretelogics.com/teafiles/) there are examples that are considering the most simple scenario obviously.

Thanks!

$\endgroup$
3
  • $\begingroup$ I'm voting to close this question as off-topic because this seems to be a programming issue $\endgroup$
    – Attack68
    Feb 14 '20 at 18:19
  • $\begingroup$ Attack68 maybe you need to read why TeaFile has been created, the nature of the application and what it is used for, that would defintely help you to understand that you can not do finance without programming. I'm struggling to understand how you could have wrote that this is off-topic. Pls study a bit it will help you out! ;-) $\endgroup$
    – SimAzz
    May 22 '20 at 7:46
  • $\begingroup$ I certainly will take your advice and study a bit, thank you kindly. If I may also impart some helpful advice: stack overflow provides excellent responses to programming questions which are relevant to all kinds of industries, including finance. $\endgroup$
    – Attack68
    May 22 '20 at 8:09
0
$\begingroup$
 using (var tf = TeaFile<Tick>.OpenWrite(filename))

creates and opens the file. the using directive and the brackets mean that at the cloing bracket the file is closed. so if you want to capture data from a provider you open the file oncy for the lifetime of the application and then all tf.Write for every tick.

Before the app closes you close the file as well. Or maybe earlier, that is the design of your app.

$\endgroup$
1
  • $\begingroup$ Thanks! i will keep it in mind. $\endgroup$
    – SimAzz
    Jan 15 '20 at 17:59

Not the answer you're looking for? Browse other questions tagged or ask your own question.