BookState is now called BookSeries
This commit is contained in:
1 parent
ba53543e43
commit
2740de913c
4 files changed
+29
-26
No files matched your search
+11
-11
@@ -6,9 +6,9 @@ using System.IO;
|
||||
|
||||
namespace bts.history{
|
||||
// all book states for a security, for the duration of a day
|
||||
class BookState{
|
||||
class BookSeries{
|
||||
private readonly List<BookEntry> _books = new List<BookEntry>();
|
||||
public BookState(string file_path){
|
||||
public BookSeries(string file_path){
|
||||
var pbooks = new List<ProcessedBook>();
|
||||
FileStream fs = new FileStream (file_path, FileMode.Open);
|
||||
while (fs.Position < fs.Length){
|
||||
@@ -28,7 +28,7 @@ namespace bts.history{
|
||||
public int count(){
|
||||
return _books.Count;
|
||||
}
|
||||
// returns all books values that exist in the timerange t
|
||||
// returns all book enties that exist in the timerange t
|
||||
// (note, these are not necassarily the updates in t
|
||||
// but the possible book values that existed in timerange t)
|
||||
public IEnumerable<BookEntry> find_books_in_time_range (Timerange t){
|
||||
@@ -52,15 +52,15 @@ namespace bts.history{
|
||||
// given a book, finds all co-existing books
|
||||
// in another book
|
||||
// source_book_ptr -> {t1,t2} -> books in {t1,t2}
|
||||
public IEnumerable<BookEntry> find_coexisting_books (
|
||||
public static IEnumerable<BookEntry> find_coexisting_books (
|
||||
BookEntry book,
|
||||
BookState b2_s){
|
||||
BookSeries b2_s){
|
||||
return b2_s.find_books_in_time_range(book.time_range);
|
||||
}
|
||||
public IEnumerable<Tuple<BookEntry,BookEntry>> find_coexisting_books (
|
||||
BookEntry book,
|
||||
BookState b2_s,
|
||||
BookState b3_s){
|
||||
BookSeries b2_s,
|
||||
BookSeries b3_s){
|
||||
var rv = new List<Tuple<BookEntry,BookEntry>>();
|
||||
var b2_coex = b2_s.find_books_in_time_range(book.time_range);
|
||||
foreach (BookEntry b2_e in b2_coex){
|
||||
@@ -72,7 +72,7 @@ namespace bts.history{
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
public void align_books_2(BookState bs_2,
|
||||
public void align_books_2(BookSeries bs_2,
|
||||
Action<BookEntry, BookEntry> on_book){
|
||||
foreach (var b in _books){
|
||||
var bs_2_coex = find_coexisting_books(b,bs_2);
|
||||
@@ -80,8 +80,8 @@ namespace bts.history{
|
||||
on_book(b,bs2_e);
|
||||
}
|
||||
}
|
||||
public void align_books_3(BookState bs_2,
|
||||
BookState bs_3,
|
||||
public void align_books_3(BookSeries bs_2,
|
||||
BookSeries bs_3,
|
||||
Action<BookEntry, BookEntry, BookEntry> on_book){
|
||||
foreach (var b in _books)
|
||||
foreach (var t in find_coexisting_books(b,bs_2,bs_3))
|
||||
@@ -90,7 +90,7 @@ namespace bts.history{
|
||||
#region static helpers
|
||||
public static Timestamp timestamp (ProcessedBook b){
|
||||
return b!=null?b.SendingTime:Timerange.max_timestamp();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -8,11 +8,11 @@ using bts.co2;
|
||||
|
||||
namespace bts.history{
|
||||
class MarketQueries{
|
||||
// works only for glbx
|
||||
static IEnumerable<BookMessage> get_synthetic_prices(
|
||||
string synthetic_text,
|
||||
SpreaderOrderDefinition synth,
|
||||
DateTime date){
|
||||
var synth = MarketQueriesHelper.parse_synthetic(synthetic_text);
|
||||
IEnumerable<BookState> book_states =
|
||||
IEnumerable<BookSeries> book_states =
|
||||
synth.Security.Synthetic.Legs.Select(
|
||||
l => MarketQueriesHelper.get_book_state(l.Security.Symbol,
|
||||
l.Security.Glbx.SecurityDesc,
|
||||
@@ -34,10 +34,15 @@ namespace bts.history{
|
||||
params BookEntry[] leg_books){
|
||||
bts.co2.BookMessage rv = new bts.co2.BookMessage();
|
||||
return rv;
|
||||
}
|
||||
static BookState get_book_state (string sec_txt,DateTime date){
|
||||
string book_path = BookAnalyzer.get_book_path(sec_txt,date);
|
||||
return null;
|
||||
}
|
||||
#region Alligning Books
|
||||
|
||||
public static IEnumerable<BookEntry> find_coexisting_books (
|
||||
BookSeries bser,
|
||||
BookEntry other_be){
|
||||
return bser.find_books_in_time_range(other_be.time_range);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -55,11 +55,11 @@ namespace bts.history{
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
public static BookState get_book_state (string symbol,
|
||||
public static BookSeries get_book_state (string symbol,
|
||||
string sec_txt,
|
||||
DateTime date){
|
||||
string book_path = BookAnalyzer.get_book_path(symbol, sec_txt,date);
|
||||
return new BookState(book_path);
|
||||
return new BookSeries(book_path);
|
||||
}
|
||||
public static string get_algo_input_path (string algo_name){
|
||||
return String.Format(@"{0}{1}/{2}/{3}/",
|
||||
|
||||
@@ -23,14 +23,12 @@ namespace bts.history{
|
||||
string output_file = sr.ReadLine ();
|
||||
IDictionary<string,SpreaderOrderDefinition> spread_map =
|
||||
new Dictionary<string,SpreaderOrderDefinition>();
|
||||
while (true){
|
||||
string spread_txt = sr.ReadLine();
|
||||
while (!spread_txt.is_null_or_empty()){
|
||||
// read spreads
|
||||
string spread_txt = sr.ReadLine();
|
||||
if(spread_txt.is_null_or_empty())
|
||||
break;
|
||||
SpreaderOrderDefinition spreader_ord =
|
||||
spread_map[spread_txt] =
|
||||
MarketQueriesHelper.parse_synthetic(spread_txt);
|
||||
spread_map[spread_txt] = spreader_ord;
|
||||
spread_txt = sr.ReadLine();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user