moving code around
This commit is contained in:
1 parent
0b8b68e6e6
commit
a2e1cf8dd5
9 files changed
+796
-818
No files matched your search
@@ -0,0 +1,17 @@
|
||||
|
||||
namespace bts.history
|
||||
{
|
||||
public class OrderOrFill
|
||||
{
|
||||
public OrderOrFill(OrderStatus ord)
|
||||
{
|
||||
this.order = ord;
|
||||
}
|
||||
public OrderOrFill(FillEntry fil)
|
||||
{
|
||||
this.fill = fil;
|
||||
}
|
||||
public OrderStatus order { get; }
|
||||
public FillEntry fill { get; }
|
||||
}
|
||||
}
|
||||
@@ -1,343 +0,0 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {
|
||||
"scrolled": true
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Invalid: Command: #r C:/Users/darby/.nuget/packages/google.protobuf/3.6.1/lib/netstandard1.0/Google.Protobuf.dllInvalid: Command: #r C:/Users/darby/.nuget/packages/newtonsoft.json/12.0.3/lib/netstandard2.0/Newtonsoft.Json.dllInvalid: Command: #r C:/Users/darby/.nuget/packages/system.linq.dynamic.core/1.0.19/lib/netstandard2.0/System.Linq.Dynamic.Core.dllInvalid: Command: #r C:/Users/darby/.nuget/packages/mongodb.driver/2.9.3/lib/netstandard1.5/MongoDB.Driver.dllInvalid: Command: #r C:/Users/darby/.nuget/packages/mongodb.driver.core/2.9.3/lib/netstandard1.5/MongoDB.Driver.Core.dllInvalid: Command: #r C:/Users/darby/.nuget/packages/mongodb.bson/2.9.3/lib/netstandard1.5/MongoDB.Bson.dll"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"//#r \"nuget:Google.Protobuf, 3.6.1\"\n",
|
||||
"#r \"C:/Users/darby/.nuget/packages/google.protobuf/3.6.1/lib/netstandard1.0/Google.Protobuf.dll\"\n",
|
||||
"//#r \"nuget:Microsoft.CSharp, 4.5.0\"\n",
|
||||
"//#r \"C:/Users/darby/.nuget/packages/microsoft.netcore.app.runtime.linux-x64/3.0.0/runtimes/linux-x64/lib/netcoreapp3.0/Microsoft.CSharp.dll\" \n",
|
||||
"//#r \"nuget:Newtonsoft.Json, 12.0.3\"\n",
|
||||
"#r \"C:/Users/darby/.nuget/packages/newtonsoft.json/12.0.3/lib/netstandard2.0/Newtonsoft.Json.dll\"\n",
|
||||
"//#r \"nuget:System.Linq.Dynamic, 1.0.7\"\n",
|
||||
"#r \"C:/Users/darby/.nuget/packages/system.linq.dynamic.core/1.0.19/lib/netstandard2.0/System.Linq.Dynamic.Core.dll\"\n",
|
||||
"//#r \"nuget:MongoDB.Driver, 2.9.3\"\n",
|
||||
"#r \"C:/Users/darby/.nuget/packages/mongodb.driver/2.9.3/lib/netstandard1.5/MongoDB.Driver.dll\" \n",
|
||||
"#r \"C:/Users/darby/.nuget/packages/mongodb.driver.core/2.9.3/lib/netstandard1.5/MongoDB.Driver.Core.dll\"\n",
|
||||
"//#r \"nuget:MongoDB.Bson, 2.9.3\"\n",
|
||||
"#r \"C:/Users/darby/.nuget/packages/mongodb.bson/2.9.3/lib/netstandard1.5/MongoDB.Bson.dll\" "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"scrolled": true
|
||||
},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"metadata": {
|
||||
"scrolled": true
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Invalid: Command: #r c:/code/bts/spark/build/Debug/bin/netstandard2.0/spark_historical.dll"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"#r \"c:/code/bts/spark/build/Debug/bin/netstandard2.0/spark_historical.dll\" \n",
|
||||
"using bts.history;\n",
|
||||
"using MongoDB.Driver;\n",
|
||||
"using MongoDB.Driver.Linq;\n",
|
||||
"using Google.Protobuf.WellKnownTypes;\n",
|
||||
"using static bts.history.Query;\n",
|
||||
"using MathNet.Numerics.Statistics;\n",
|
||||
"using mbts.co2;\n",
|
||||
"\n",
|
||||
"bts.BTS.init();\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 9,
|
||||
"metadata": {
|
||||
"scrolled": true
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"var q = new Query(\"10Y_201911_W4\", \"bigblue\");"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 10,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"var c1 = q.collection<HistoryRow>(\"ZNZ9\");\n",
|
||||
"var c2 = q.collection<HistoryRow>(\"ZNH0\");\n",
|
||||
"var c3 = q.collection<HistoryRow>(\"ZNZ9-ZNH0\");\n",
|
||||
"\n",
|
||||
" "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"scrolled": true
|
||||
},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"scrolled": true
|
||||
},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 11,
|
||||
"metadata": {
|
||||
"scrolled": true
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"var begin = DateTime.SpecifyKind(new DateTime(2019, 11, 25, 10, 0, 0), DateTimeKind.Utc);\n",
|
||||
"var end = DateTime.SpecifyKind(new DateTime(2019, 11, 25, 23, 59, 59), DateTimeKind.Utc);\n",
|
||||
"var c1t = q.timeseries<HistoryRow>(c1, begin, end).OrderBy(x => x.sending_time);\n",
|
||||
"var c2t = q.timeseries<HistoryRow>(c2, begin, end).OrderBy(x => x.sending_time);\n",
|
||||
"var c3t = q.timeseries<HistoryRow>(c3, begin, end).OrderBy(x => x.sending_time);\n",
|
||||
"\n",
|
||||
"//local copy so we don't beat up the database\n",
|
||||
"var c1f = local(c1t).ToArray();\n",
|
||||
"var c2f = local(c2t).ToArray();\n",
|
||||
"var c3f = local(c3t).ToArray();"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 12,
|
||||
"metadata": {
|
||||
"scrolled": true
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"913591"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"517775"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"494994"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"display(c1f.Count());\n",
|
||||
"display(c2f.Count());\n",
|
||||
"display(c3f.Count());\n",
|
||||
"//display(c1t.Count());\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 13,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"class AlgoReport\n",
|
||||
"{\n",
|
||||
" readonly AlgoResults _res;\n",
|
||||
" public string security_desc => _res.security_desc;\n",
|
||||
" public string transact_time => _res.data?.transact_time.ToString(\"yyyy-MM-dd HH:mm:ss.ffffff\");\n",
|
||||
" public MarketBook market_book { get;}\n",
|
||||
" public MarketTrade market_trade { get;} \n",
|
||||
" public OurOrder our_order { get; }\n",
|
||||
" public OurFill our_fill { get; } \n",
|
||||
" public AlgoReport(AlgoResults res)\n",
|
||||
" {\n",
|
||||
" _res = res;\n",
|
||||
" if(res.book != null)\n",
|
||||
" market_book = new MarketBook(_res); \n",
|
||||
" if(res.trade != null)\n",
|
||||
" market_trade = new MarketTrade(_res);\n",
|
||||
" if(res.order != null)\n",
|
||||
" our_order = new OurOrder(_res);\n",
|
||||
" if(res.fill != null)\n",
|
||||
" our_fill = new OurFill(_res);\n",
|
||||
" }\n",
|
||||
" \n",
|
||||
" internal class MarketBook\n",
|
||||
" {\n",
|
||||
" AlgoResults _res;\n",
|
||||
" public MarketBook(AlgoResults res) { _res = res; }\n",
|
||||
" \n",
|
||||
" public uint? market_book_bid_size => _res.book?.Bids?[0].Size; \n",
|
||||
" public double? market_book_bid => \n",
|
||||
" NativePriceHelpers.to_double(_res.book?.Bids?[0].Mantissa ?? 0, (sbyte)(_res.book?.Bids?[0].Exponent ?? 0)); \n",
|
||||
" public double? market_book_ask => \n",
|
||||
" NativePriceHelpers.to_double(_res.book?.Asks?[0].Mantissa ?? 0, (sbyte)(_res.book?.Asks?[0].Exponent ?? 0)); \n",
|
||||
" public uint? market_book_ask_size => _res.book?.Asks?[0].Size; \n",
|
||||
" } \n",
|
||||
" \n",
|
||||
" internal class MarketTrade\n",
|
||||
" {\n",
|
||||
" AlgoResults _res;\n",
|
||||
" public MarketTrade(AlgoResults res) { _res = res; }\n",
|
||||
" public string market_trade_side => _res.trade?.AggressorSide.ToString();\n",
|
||||
" public double? market_trade_price => \n",
|
||||
" NativePriceHelpers.to_double(_res.trade?.Mantissa ?? 0, (sbyte)(_res.trade?.Exponent ?? 0));\n",
|
||||
" public uint? market_trade_size => _res.trade?.Size; \n",
|
||||
" }\n",
|
||||
"\n",
|
||||
" internal class OurOrder\n",
|
||||
" {\n",
|
||||
" AlgoResults _res;\n",
|
||||
" public OurOrder(AlgoResults res) { _res = res; }\n",
|
||||
" public string security_desc => _res.security_desc;\n",
|
||||
" public string our_order_time => _res.order?.last_change.ToDateTime().ToString(\"yyyy-MM-dd HH:mm:ss.ffffff\"); \n",
|
||||
" public string our_order_side => _res.order?.side.ToString();\n",
|
||||
" public string our_order_status => _res.order?.state.Status.ToString();\n",
|
||||
" public double? our_order_price => _res.order?.state.Price;\n",
|
||||
" public uint? our_order_size => _res.order?.state.Quantity;\n",
|
||||
" public uint? our_order_filled => _res.order?.state.FilledQuantity;\n",
|
||||
" }\n",
|
||||
" \n",
|
||||
" internal class OurFill\n",
|
||||
" {\n",
|
||||
" AlgoResults _res;\n",
|
||||
" public OurFill(AlgoResults res) { _res = res; }\n",
|
||||
" public string our_fill_time => _res.fill?.timestamp.ToDateTime().ToString(\"yyyy-MM-dd HH:mm:ss.ffffff\"); \n",
|
||||
" public string our_fill_side => _res.fill?.side.ToString();\n",
|
||||
" public double? our_fill_price => _res.fill?.price;\n",
|
||||
" public ulong? our_fill_size => _res.fill?.size;\n",
|
||||
" public int? our_fill_piq => _res.fill?.piq; \n",
|
||||
" public string tag => _res.fill?.tag;\n",
|
||||
" }\n",
|
||||
"}"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 15,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"var security_list = new [] {\"ZNH0\",\"ZNZ9-ZNH0\", \"ZNZ9\"};\n",
|
||||
"//quotes the last leg\n",
|
||||
"var algo_type = typeof(RoundTrip);\n",
|
||||
"var algo_params = \"size=10;tick_size=0.015625,0.0078125,0.015625;hedge_factors=1,1,-1\";\n",
|
||||
"\n",
|
||||
"//var algo = AlgoFactory.algo_factory(typeof(RoundTrip), sink, security_list, algo_params);"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 16,
|
||||
"metadata": {
|
||||
"scrolled": true
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"var sink = new FIFOModel(new Bucket(0, 1));\n",
|
||||
"var stream = run_algo<HistoryRow,AlgoReport>(algo_type, sink, algo_params,\n",
|
||||
" bts.api.Side.Undefined, 0.0, 10, security_list, \n",
|
||||
" new[] {c2f, c3f, c1f}, x => x.Select(xx => new AlgoReport(xx)) );\n",
|
||||
"\n",
|
||||
"var streamlocal = stream.ToArray();\n",
|
||||
"\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 21,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<table><thead><tr><th><i>index</i></th><th>security_desc</th><th>transact_time</th><th>market_book</th><th>market_trade</th><th>our_order</th><th>our_fill</th></tr></thead><tbody><tr><td>0</td><td>ZNZ9</td><td>2019-11-25 15:00:00.000011</td><td>{ Submission#14+AlgoReport+MarketBook: market_book_bid_size: 1976, market_book_bid: 129.53125, market_book_ask: 129.546875, market_book_ask_size: 1324 }</td><td>{ Submission#14+AlgoReport+MarketTrade: market_trade_side: Sell, market_trade_price: 129.53125, market_trade_size: 8 }</td><td>{ Submission#14+AlgoReport+OurOrder: security_desc: ZNZ9, our_order_time: 2019-11-25 15:00:00.252817, our_order_side: Sell, our_order_status: Canceled, our_order_price: 129.5859375, our_order_size: 10, our_order_filled: 0 }</td><td><null></td></tr><tr><td>1</td><td>ZNZ9</td><td>2019-11-25 15:00:00.000011</td><td>{ Submission#14+AlgoReport+MarketBook: market_book_bid_size: 1976, market_book_bid: 129.53125, market_book_ask: 129.546875, market_book_ask_size: 1324 }</td><td>{ Submission#14+AlgoReport+MarketTrade: market_trade_side: Sell, market_trade_price: 129.53125, market_trade_size: 8 }</td><td>{ Submission#14+AlgoReport+OurOrder: security_desc: ZNZ9, our_order_time: 2019-11-25 15:00:00.252817, our_order_side: Buy, our_order_status: Completed, our_order_price: 129.53125, our_order_size: 8, our_order_filled: 10 }</td><td><null></td></tr><tr><td>2</td><td>ZNZ9</td><td>2019-11-25 15:00:00.000011</td><td>{ Submission#14+AlgoReport+MarketBook: market_book_bid_size: 1976, market_book_bid: 129.53125, market_book_ask: 129.546875, market_book_ask_size: 1357 }</td><td>{ Submission#14+AlgoReport+MarketTrade: market_trade_side: Sell, market_trade_price: 129.53125, market_trade_size: 8 }</td><td>{ Submission#14+AlgoReport+OurOrder: security_desc: ZNZ9, our_order_time: 2019-11-25 15:00:00.253025, our_order_side: Sell, our_order_status: Canceled, our_order_price: 129.5859375, our_order_size: 10, our_order_filled: 0 }</td><td><null></td></tr><tr><td>3</td><td>ZNZ9</td><td>2019-11-25 15:00:00.000011</td><td>{ Submission#14+AlgoReport+MarketBook: market_book_bid_size: 1976, market_book_bid: 129.53125, market_book_ask: 129.546875, market_book_ask_size: 1357 }</td><td>{ Submission#14+AlgoReport+MarketTrade: market_trade_side: Sell, market_trade_price: 129.53125, market_trade_size: 8 }</td><td>{ Submission#14+AlgoReport+OurOrder: security_desc: ZNZ9, our_order_time: 2019-11-25 15:00:00.253025, our_order_side: Buy, our_order_status: Completed, our_order_price: 129.53125, our_order_size: 8, our_order_filled: 10 }</td><td><null></td></tr><tr><td>4</td><td>ZNZ9</td><td>2019-11-25 15:00:00.000011</td><td>{ Submission#14+AlgoReport+MarketBook: market_book_bid_size: 546, market_book_bid: 129.546875, market_book_ask: 129.5625, market_book_ask_size: 2594 }</td><td>{ Submission#14+AlgoReport+MarketTrade: market_trade_side: Sell, market_trade_price: 129.546875, market_trade_size: 6 }</td><td>{ Submission#14+AlgoReport+OurOrder: security_desc: ZNZ9, our_order_time: 2019-11-25 15:01:30.512226, our_order_side: Sell, our_order_status: Canceled, our_order_price: 129.5859375, our_order_size: 10, our_order_filled: 0 }</td><td><null></td></tr><tr><td>5</td><td>ZNZ9</td><td>2019-11-25 15:00:00.000011</td><td>{ Submission#14+AlgoReport+MarketBook: market_book_bid_size: 546, market_book_bid: 129.546875, market_book_ask: 129.5625, market_book_ask_size: 2594 }</td><td>{ Submission#14+AlgoReport+MarketTrade: market_trade_side: Sell, market_trade_price: 129.546875, market_trade_size: 6 }</td><td>{ Submission#14+AlgoReport+OurOrder: security_desc: ZNZ9, our_order_time: 2019-11-25 15:01:30.512226, our_order_side: Buy, our_order_status: Completed, our_order_price: 129.53125, our_order_size: 8, our_order_filled: 10 }</td><td><null></td></tr><tr><td>6</td><td>ZNZ9</td><td>2019-11-25 15:00:00.000011</td><td>{ Submission#14+AlgoReport+MarketBook: market_book_bid_size: 556, market_book_bid: 129.546875, market_book_ask: 129.5625, market_book_ask_size: 2614 }</td><td>{ Submission#14+AlgoReport+MarketTrade: market_trade_side: Sell, market_trade_price: 129.546875, market_trade_size: 6 }</td><td>{ Submission#14+AlgoReport+OurOrder: security_desc: ZNZ9, our_order_time: 2019-11-25 15:01:30.512278, our_order_side: Sell, our_order_status: Canceled, our_order_price: 129.5859375, our_order_size: 10, our_order_filled: 0 }</td><td><null></td></tr><tr><td>7</td><td>ZNZ9</td><td>2019-11-25 15:00:00.000011</td><td>{ Submission#14+AlgoReport+MarketBook: market_book_bid_size: 556, market_book_bid: 129.546875, market_book_ask: 129.5625, market_book_ask_size: 2614 }</td><td>{ Submission#14+AlgoReport+MarketTrade: market_trade_side: Sell, market_trade_price: 129.546875, market_trade_size: 6 }</td><td>{ Submission#14+AlgoReport+OurOrder: security_desc: ZNZ9, our_order_time: 2019-11-25 15:01:30.512278, our_order_side: Buy, our_order_status: Completed, our_order_price: 129.53125, our_order_size: 8, our_order_filLine truncated
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"var fills = streamlocal.Where(x => x.our_fill != null || x.our_order != null).OrderBy(x => x.transact_time);\n",
|
||||
"display(fills.Take(1000));\n",
|
||||
"\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 10,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": ".NET (C#)",
|
||||
"language": "C#",
|
||||
"name": ".net-csharp"
|
||||
},
|
||||
"language_info": {
|
||||
"file_extension": ".cs",
|
||||
"mimetype": "text/x-csharp",
|
||||
"name": "C#",
|
||||
"pygments_lexer": "csharp",
|
||||
"version": "8.0"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 2
|
||||
}
|
||||
+31
-41
@@ -55,6 +55,19 @@
|
||||
"text": [
|
||||
"Invalid: Command: #r c:/code/bts/spark/build/Debug/bin/netstandard2.0/spark_historical.dll"
|
||||
]
|
||||
},
|
||||
{
|
||||
"ename": "Unhandled Exception",
|
||||
"evalue": "Unable to reach server http://sparkvm:8000/config/",
|
||||
"output_type": "error",
|
||||
"traceback": [
|
||||
"Unhandled Exception",
|
||||
"Unable to reach server http://sparkvm:8000/config/",
|
||||
" at bts.BTS.init() in c:\\code\\bts\\spark\\src\\client\\spark_api\\utils\\BTS.cs:line 21",
|
||||
" at Submission#3.<<Initialize>>d__0.MoveNext()",
|
||||
"--- End of stack trace from previous location where exception was thrown ---",
|
||||
" at Microsoft.CodeAnalysis.Scripting.ScriptExecutionState.RunSubmissionsAsync[TResult](ImmutableArray`1 precedingExecutors, Func`2 currentExecutor, StrongBox`1 exceptionHolderOpt, Func`2 catchExceptionOpt, CancellationToken cancellationToken)"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
@@ -96,16 +109,16 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 59,
|
||||
"execution_count": 5,
|
||||
"metadata": {
|
||||
"scrolled": true
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"var begin = DateTime.SpecifyKind(new DateTime(2019, 11, 25, 13, 30, 0), DateTimeKind.Utc);\n",
|
||||
"var end = DateTime.SpecifyKind(new DateTime(2019, 11, 25, 14, 0, 0), DateTimeKind.Utc);\n",
|
||||
"//var begin = DateTime.SpecifyKind(new DateTime(2019, 11, 25, 0, 0, 0), DateTimeKind.Utc);\n",
|
||||
"//var end = DateTime.SpecifyKind(new DateTime(2019, 11, 25, 23, 59, 59), DateTimeKind.Utc);\n",
|
||||
"//var begin = DateTime.SpecifyKind(new DateTime(2019, 11, 25, 13, 30, 0), DateTimeKind.Utc);\n",
|
||||
"//var end = DateTime.SpecifyKind(new DateTime(2019, 11, 25, 14, 0, 0), DateTimeKind.Utc);\n",
|
||||
"var begin = DateTime.SpecifyKind(new DateTime(2019, 11, 25, 0, 0, 0), DateTimeKind.Utc);\n",
|
||||
"var end = DateTime.SpecifyKind(new DateTime(2019, 11, 25, 23, 59, 59), DateTimeKind.Utc);\n",
|
||||
"\n",
|
||||
"var z9t = q.timeseries_cached<HistoryRow>(z9, begin, end);\n",
|
||||
"var h0t = q.timeseries_cached<HistoryRow>(h0, begin, end);\n",
|
||||
@@ -121,7 +134,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 60,
|
||||
"execution_count": 6,
|
||||
"metadata": {
|
||||
"scrolled": true
|
||||
},
|
||||
@@ -181,7 +194,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 55,
|
||||
"execution_count": 7,
|
||||
"metadata": {
|
||||
"scrolled": true
|
||||
},
|
||||
@@ -213,7 +226,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 56,
|
||||
"execution_count": 8,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -224,13 +237,15 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 57,
|
||||
"metadata": {},
|
||||
"execution_count": 9,
|
||||
"metadata": {
|
||||
"scrolled": true
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"2"
|
||||
"100"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
@@ -239,7 +254,7 @@
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"2"
|
||||
"35"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
@@ -248,7 +263,7 @@
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<table><thead><tr><th><i>index</i></th><th>order</th><th>fill</th></tr></thead><tbody><tr><td>0</td><td>{ bts.history.Display+OrderDisplay: order_id: 1000265, security_desc: ZNH0, our_order_sendingtime: "2019-11-25T13:30:00.654558700Z", our_order_transacttime: "2019-11-25T13:30:00.654508700Z", our_order_side: Sell, our_order_status: Working, our_order_price: 129.40625, our_order_size: 10, our_order_filled: 0 }</td><td><null></td></tr><tr><td>1</td><td>{ bts.history.Display+OrderDisplay: order_id: 1000266, security_desc: ZNH0, our_order_sendingtime: "2019-11-25T13:30:00.654558700Z", our_order_transacttime: "2019-11-25T13:30:00.654508700Z", our_order_side: Buy, our_order_status: Working, our_order_price: 129.359375, our_order_size: 10, our_order_filled: 0 }</td><td><null></td></tr><tr><td>2</td><td>{ bts.history.Display+OrderDisplay: order_id: 1000265, security_desc: ZNH0, our_order_sendingtime: "2019-11-25T13:30:15.423407500Z", our_order_transacttime: "2019-11-25T13:30:15.423357500Z", our_order_side: Sell, our_order_status: Working, our_order_price: 129.390625, our_order_size: 10, our_order_filled: 0 }</td><td><null></td></tr><tr><td>3</td><td>{ bts.history.Display+OrderDisplay: order_id: 1000266, security_desc: ZNH0, our_order_sendingtime: "2019-11-25T13:30:15.423407500Z", our_order_transacttime: "2019-11-25T13:30:15.423357500Z", our_order_side: Buy, our_order_status: Working, our_order_price: 129.34375, our_order_size: 10, our_order_filled: 0 }</td><td><null></td></tr><tr><td>4</td><td>{ bts.history.Display+OrderDisplay: order_id: 1000265, security_desc: ZNH0, our_order_sendingtime: "2019-11-25T13:30:15.432881500Z", our_order_transacttime: "2019-11-25T13:30:15.432831500Z", our_order_side: Sell, our_order_status: Working, our_order_price: 129.40625, our_order_size: 10, our_order_filled: 0 }</td><td><null></td></tr><tr><td>5</td><td>{ bts.history.Display+OrderDisplay: order_id: 1000266, security_desc: ZNH0, our_order_sendingtime: "2019-11-25T13:30:15.432881500Z", our_order_transacttime: "2019-11-25T13:30:15.432831500Z", our_order_side: Buy, our_order_status: Working, our_order_price: 129.359375, our_order_size: 10, our_order_filled: 0 }</td><td><null></td></tr><tr><td>6</td><td>{ bts.history.Display+OrderDisplay: order_id: 1000265, security_desc: ZNH0, our_order_sendingtime: "2019-11-25T13:31:08.553445200Z", our_order_transacttime: "2019-11-25T13:31:08.553395200Z", our_order_side: Sell, our_order_status: Working, our_order_price: 129.421875, our_order_size: 10, our_order_filled: 0 }</td><td><null></td></tr><tr><td>7</td><td>{ bts.history.Display+OrderDisplay: order_id: 1000266, security_desc: ZNH0, our_order_sendingtime: "2019-11-25T13:31:08.554332600Z", our_order_transacttime: "2019-11-25T13:31:08.554282600Z", our_order_side: Buy, our_order_status: Working, our_order_price: 129.375, our_order_size: 10, our_order_filled: 0 }</td><td><null></td></tr><tr><td>8</td><td>{ bts.history.Display+OrderDisplay: order_id: 1000265, security_desc: ZNH0, our_order_sendingtime: "2019-11-25T13:31:08.575899900Z", our_order_transacttime: "2019-11-25T13:31:08.575849900Z", our_order_side: Sell, our_order_status: Working, our_order_price: 129.40625, our_order_size: 10, our_order_filled: 0 }</td><td><null></td></tr><tr><td>9</td><td>{ bts.history.Display+OrderDisplay: order_id: 1000266, security_desc: ZNH0, our_order_sendingtime: "2019-11-25T13:31:08.575899900Z", our_order_transacttime: "2019-11-25T13:31:08.575849900Z", our_order_side: Buy, our_order_status: Working, our_order_price: 129.359375, our_order_size: 10, our_order_filled: 0 }</td><td><null></td></tr><tr><td>10</td><td>{ bts.history.Display+OrderDisplay: order_id: 1000265, security_desc: ZNH0, our_order_sendingtime: "2019-11-25T13:31:08.633398700Z", our_order_transacttime: "2019-11-25T13:31:08.633348700Z", our_order_side: Sell, our_order_status: Working, our_order_price: 129.421875, our_order_size: 10, our_order_filled: 0 }</td><td><null></td></tr><tr><td>11</td><td>{ bts.history.Display+OrderDisplay: order_id: 1000266, security_desc: ZNH0, our_order_sendingtime: "2019-11-25T13:31:08.633398700Z", our_order_transacttime: "2019-11-25T13:31:08.633348700Z", our_order_side: Buy, our_order_status: Working, our_order_price: 129.375, our_order_size: 10, our_order_filled: 0 }</td><td><null></td></tr><tr><td>12</td><td>{ bts.history.Display+OrderDisplay: order_id: 1000265, security_desc: ZNH0, our_order_sendingtime: "2019-11-25T13:31:08.638645400Z", our_order_transacttime: "2019-11-25T13:31:08.638595400Z", our_order_side: Sell, our_order_status: Working, our_order_price: 129.40625, our_order_size: 10, our_order_filled: 0 }</td><td><null></Line truncated
|
||||
"<table><thead><tr><th><i>index</i></th><th>order</th><th>fill</th></tr></thead><tbody><tr><td>0</td><td>{ bts.history.Display+OrderDisplay: order_id: 1000001, security_desc: ZNH0, our_order_sendingtime: "2019-11-25T00:01:10.777871200Z", our_order_transacttime: "2019-11-25T00:01:10.777821200Z", our_order_side: Sell, our_order_status: Working, our_order_price: 129.46875, our_order_size: 10, our_order_filled: 0 }</td><td><null></td></tr><tr><td>1</td><td>{ bts.history.Display+OrderDisplay: order_id: 1000002, security_desc: ZNH0, our_order_sendingtime: "2019-11-25T00:01:10.777871200Z", our_order_transacttime: "2019-11-25T00:01:10.777821200Z", our_order_side: Buy, our_order_status: Working, our_order_price: 129.421875, our_order_size: 10, our_order_filled: 0 }</td><td><null></td></tr><tr><td>2</td><td>{ bts.history.Display+OrderDisplay: order_id: 1000001, security_desc: ZNH0, our_order_sendingtime: "2019-11-25T00:01:10.787706300Z", our_order_transacttime: "2019-11-25T00:01:10.787656300Z", our_order_side: Sell, our_order_status: Working, our_order_price: 129.484375, our_order_size: 10, our_order_filled: 0 }</td><td><null></td></tr><tr><td>3</td><td>{ bts.history.Display+OrderDisplay: order_id: 1000002, security_desc: ZNH0, our_order_sendingtime: "2019-11-25T00:01:10.788590500Z", our_order_transacttime: "2019-11-25T00:01:10.788540500Z", our_order_side: Buy, our_order_status: Working, our_order_price: 129.4375, our_order_size: 10, our_order_filled: 0 }</td><td><null></td></tr><tr><td>4</td><td>{ bts.history.Display+OrderDisplay: order_id: 1000001, security_desc: ZNH0, our_order_sendingtime: "2019-11-25T00:01:10.789026900Z", our_order_transacttime: "2019-11-25T00:01:10.788976900Z", our_order_side: Sell, our_order_status: Working, our_order_price: 129.46875, our_order_size: 10, our_order_filled: 0 }</td><td><null></td></tr><tr><td>5</td><td>{ bts.history.Display+OrderDisplay: order_id: 1000002, security_desc: ZNH0, our_order_sendingtime: "2019-11-25T00:01:10.789026900Z", our_order_transacttime: "2019-11-25T00:01:10.788976900Z", our_order_side: Buy, our_order_status: Working, our_order_price: 129.421875, our_order_size: 10, our_order_filled: 0 }</td><td><null></td></tr><tr><td>6</td><td>{ bts.history.Display+OrderDisplay: order_id: 1000001, security_desc: ZNH0, our_order_sendingtime: "2019-11-25T00:01:10.789093800Z", our_order_transacttime: "2019-11-25T00:01:10.789043800Z", our_order_side: Sell, our_order_status: Working, our_order_price: 129.484375, our_order_size: 10, our_order_filled: 0 }</td><td><null></td></tr><tr><td>7</td><td>{ bts.history.Display+OrderDisplay: order_id: 1000001, security_desc: ZNH0, our_order_sendingtime: "2019-11-25T00:01:10.789321200Z", our_order_transacttime: "2019-11-25T00:01:10.789271200Z", our_order_side: Sell, our_order_status: Working, our_order_price: 129.46875, our_order_size: 10, our_order_filled: 0 }</td><td><null></td></tr><tr><td>8</td><td>{ bts.history.Display+OrderDisplay: order_id: 1000001, security_desc: ZNH0, our_order_sendingtime: "2019-11-25T00:01:10.790255800Z", our_order_transacttime: "2019-11-25T00:01:10.790205800Z", our_order_side: Sell, our_order_status: Working, our_order_price: 129.484375, our_order_size: 10, our_order_filled: 0 }</td><td><null></td></tr><tr><td>9</td><td>{ bts.history.Display+OrderDisplay: order_id: 1000002, security_desc: ZNH0, our_order_sendingtime: "2019-11-25T00:01:10.790255800Z", our_order_transacttime: "2019-11-25T00:01:10.790205800Z", our_order_side: Buy, our_order_status: Working, our_order_price: 129.4375, our_order_size: 10, our_order_filled: 0 }</td><td><null></td></tr><tr><td>10</td><td>{ bts.history.Display+OrderDisplay: order_id: 1000001, security_desc: ZNH0, our_order_sendingtime: "2019-11-25T00:03:09.773164900Z", our_order_transacttime: "2019-11-25T00:03:09.773114900Z", our_order_side: Sell, our_order_status: Working, our_order_price: 129.5, our_order_size: 10, our_order_filled: 0 }</td><td><null></td></tr><tr><td>11</td><td>{ bts.history.Display+OrderDisplay: order_id: 1000002, security_desc: ZNH0, our_order_sendingtime: "2019-11-25T00:03:09.773164900Z", our_order_transacttime: "2019-11-25T00:03:09.773114900Z", our_order_side: Buy, our_order_status: Working, our_order_price: 129.453125, our_order_size: 10, our_order_filled: 0 }</td><td><null></td></tr><tr><td>12</td><td>{ bts.history.Display+OrderDisplay: order_id: 1000002, security_desc: ZNH0, our_order_sendingtime: "2019-11-25T00:03:09.773510Z", our_order_transacttime: "2019-11-25T00:03:09.773460Z", our_order_side: Buy, our_order_status: Working, our_order_price: 129.4375, our_order_size: 10, our_order_filled: 0 }</td><td><null></td></tr><Line truncated
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
@@ -293,34 +308,9 @@
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
" public class MBODisplay \n",
|
||||
" {\n",
|
||||
" MBOMessage _res;\n",
|
||||
" public MBODisplay(MBOMessage res)\n",
|
||||
" {\n",
|
||||
" _res = res;\n",
|
||||
" }\n",
|
||||
" \n",
|
||||
" public string OrderUpdateAction => _res.OrderUpdateAction.ToString();\n",
|
||||
" public ulong OrderId => _res.OrderId;\n",
|
||||
" public string SecurityDesc => _res.SecurityDesc;\n",
|
||||
" public ulong MdOrderPriority => _res.MdOrderPriority;\n",
|
||||
" public double MdEntryPx => _res.MdEntryPx;\n",
|
||||
" public uint MdPriceLevel => _res.MdPriceLevel;\n",
|
||||
" public ulong MdDisplayQty => _res.MdDisplayQty;\n",
|
||||
" public uint LastQty =>_res.LastQty;\n",
|
||||
" public string MdEntryType => _res.MdEntryType.ToString(); \n",
|
||||
" public string TradeDate => _res.TradeDate.ToString();\n",
|
||||
" public uint MsgSeqNum => _res.MsgSeqNum;\n",
|
||||
" public string SendingTime => _res.SendingTime.ToString();\n",
|
||||
" public string TransactTime => _res.TransactTime.ToString();\n",
|
||||
" \n",
|
||||
" public MDEntry MdEntry => _res.MdEntry;\n",
|
||||
" public OrderIDEntry OrderEntry => _res.OrderEntry;\n",
|
||||
" \n",
|
||||
" }\n",
|
||||
"\n",
|
||||
"//display(exchange_orders.Skip(20000).Take(100));\n",
|
||||
"display(exchange_orders.Where(x => x.OrderId == 846784119686).Select(x => new MBODisplay(x)));"
|
||||
"display(exchange_orders.Where(x => x.OrderId == 846784119686).Select(x => new Display.MBODisplay(x)));"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -383,7 +373,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 58,
|
||||
"execution_count": 17,
|
||||
"metadata": {
|
||||
"scrolled": true
|
||||
},
|
||||
|
||||
@@ -0,0 +1,310 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {
|
||||
"scrolled": true
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Invalid: Command: #r C:/Users/darby/.nuget/packages/google.protobuf/3.6.1/lib/netstandard1.0/Google.Protobuf.dllInvalid: Command: #r C:/Users/darby/.nuget/packages/newtonsoft.json/12.0.3/lib/netstandard2.0/Newtonsoft.Json.dllInvalid: Command: #r C:/Users/darby/.nuget/packages/system.linq.dynamic.core/1.0.19/lib/netstandard2.0/System.Linq.Dynamic.Core.dllInvalid: Command: #r C:/Users/darby/.nuget/packages/mongodb.driver/2.9.3/lib/netstandard1.5/MongoDB.Driver.dllInvalid: Command: #r C:/Users/darby/.nuget/packages/mongodb.driver.core/2.9.3/lib/netstandard1.5/MongoDB.Driver.Core.dllInvalid: Command: #r C:/Users/darby/.nuget/packages/mongodb.bson/2.9.3/lib/netstandard1.5/MongoDB.Bson.dllInvalid: Command: #r C:/Users/darby/.nuget/packages/protobuf-net/2.3.2/lib/netstandard1.3/protobuf-net.dll"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"//#r \"nuget:Google.Protobuf, 3.6.1\"\n",
|
||||
"#r \"C:/Users/darby/.nuget/packages/google.protobuf/3.6.1/lib/netstandard1.0/Google.Protobuf.dll\"\n",
|
||||
"//#r \"nuget:Microsoft.CSharp, 4.5.0\"\n",
|
||||
"//#r \"C:/Users/darby/.nuget/packages/microsoft.netcore.app.runtime.linux-x64/3.0.0/runtimes/linux-x64/lib/netcoreapp3.0/Microsoft.CSharp.dll\" \n",
|
||||
"//#r \"nuget:Newtonsoft.Json, 12.0.3\"\n",
|
||||
"#r \"C:/Users/darby/.nuget/packages/newtonsoft.json/12.0.3/lib/netstandard2.0/Newtonsoft.Json.dll\"\n",
|
||||
"//#r \"nuget:System.Linq.Dynamic, 1.0.7\"\n",
|
||||
"#r \"C:/Users/darby/.nuget/packages/system.linq.dynamic.core/1.0.19/lib/netstandard2.0/System.Linq.Dynamic.Core.dll\"\n",
|
||||
"//#r \"nuget:MongoDB.Driver, 2.9.3\"\n",
|
||||
"#r \"C:/Users/darby/.nuget/packages/mongodb.driver/2.9.3/lib/netstandard1.5/MongoDB.Driver.dll\" \n",
|
||||
"#r \"C:/Users/darby/.nuget/packages/mongodb.driver.core/2.9.3/lib/netstandard1.5/MongoDB.Driver.Core.dll\"\n",
|
||||
"//#r \"nuget:MongoDB.Bson, 2.9.3\"\n",
|
||||
"#r \"C:/Users/darby/.nuget/packages/mongodb.bson/2.9.3/lib/netstandard1.5/MongoDB.Bson.dll\"\n",
|
||||
"//#r \"nuget:protobuf-net, 2.3.2.0\"\n",
|
||||
"#r \"C:/Users/darby/.nuget/packages/protobuf-net/2.3.2/lib/netstandard1.3/protobuf-net.dll\" "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"scrolled": true
|
||||
},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"metadata": {
|
||||
"scrolled": true
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Invalid: Command: #r c:/code/bts/spark/build/Debug/bin/netstandard2.0/spark_historical.dll"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"#r \"c:/code/bts/spark/build/Debug/bin/netstandard2.0/spark_historical.dll\" \n",
|
||||
"using bts.history;\n",
|
||||
"using MongoDB.Driver;\n",
|
||||
"using MongoDB.Driver.Linq;\n",
|
||||
"using Google.Protobuf.WellKnownTypes;\n",
|
||||
"using static bts.history.Query;\n",
|
||||
"using MathNet.Numerics.Statistics;\n",
|
||||
"using mbts.co2;\n",
|
||||
"\n",
|
||||
"bts.BTS.init();\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"metadata": {
|
||||
"scrolled": true
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"var q = new Query(\"HE_20191121\", \"bigblue\");"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 20,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"//var c1 = q.collection<HistoryRow>(\"HEZ9-HEG0\");\n",
|
||||
"//var c2 = q.collection<HistoryRow>(\"HEG0-HEV0\");\n",
|
||||
"//var c3 = q.collection<HistoryRow>(\"HEZ9-HEV0\");\n",
|
||||
"\n",
|
||||
"var s1 = \"HEZ9-HEG0\";\n",
|
||||
"var s2 = \"HEG0-HEV0\";\n",
|
||||
"var s3 = \"HEZ9-HEV0\";\n",
|
||||
"\n",
|
||||
"var c1 = q.collection<HistoryRow>(s1);\n",
|
||||
"var c2 = q.collection<HistoryRow>(s2);\n",
|
||||
"var c3 = q.collection<HistoryRow>(s3);\n",
|
||||
"\n",
|
||||
" "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 21,
|
||||
"metadata": {
|
||||
"scrolled": true
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"var begin = DateTime.SpecifyKind(new DateTime(2019, 11, 21, 0, 0, 0), DateTimeKind.Utc);\n",
|
||||
"var end = DateTime.SpecifyKind(new DateTime(2019, 11, 21, 23, 59, 59), DateTimeKind.Utc);\n",
|
||||
"\n",
|
||||
"var c1t = await q.timeseries_cached<HistoryRow>(c1, begin, end);\n",
|
||||
"var c2t = await q.timeseries_cached<HistoryRow>(c2, begin, end);\n",
|
||||
"var c3t = await q.timeseries_cached<HistoryRow>(c3, begin, end);\n",
|
||||
"\n",
|
||||
"//await Task.WhenAll(new[] {z9t, h0t, spdt} );\n",
|
||||
"\n",
|
||||
"//local copy so we don't beat up the database\n",
|
||||
"var c1f = c1t.Where(x => x.Book != null && (x.Book.Bids.Count > 0 || x.Book.Asks.Count > 0));\n",
|
||||
"var c2f = c2t.Where(x => x.Book != null && (x.Book.Bids.Count > 0 || x.Book.Asks.Count > 0));\n",
|
||||
"var c3f = c3t.Where(x => x.Book != null && (x.Book.Bids.Count > 0 || x.Book.Asks.Count > 0));"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 22,
|
||||
"metadata": {
|
||||
"scrolled": true
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"35655"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"7706"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"1268"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"display(c1f.Count()); display(c2f.Count()); display(c3f.Count());"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 23,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"var c1top = c1f.AsEnumerable().Select(x => new GetTopOfBook(x)).OrderBy(x => x.sending_time);\n",
|
||||
"var c2top = c2f.AsEnumerable().Select(x => new GetTopOfBook(x)).OrderBy(x => x.sending_time);\n",
|
||||
"var c3top = c3f.AsEnumerable().Select(x => new GetTopOfBook(x)).OrderBy(x => x.sending_time);"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 24,
|
||||
"metadata": {
|
||||
"scrolled": true
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"var synth = create_synthetic_top( new []{c1top, c2top, c3top}, new[] {1.0, 1.0, -1.0}, new[] {1.0, 1.0, -1.0}, \n",
|
||||
" x => x.TopBook.Bid.price() > 0.0 || x.TopBook.Ask.price() < 0.0, \n",
|
||||
" (legs, synth)=> new TopDisplay<GetTopOfBook>(legs, synth));"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 25,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<table><thead><tr><th><i>index</i></th><th>seq_num</th><th>trade_date</th><th>sending_time</th><th>transact_time</th><th>bidsize</th><th>bid</th><th>ask</th><th>asksize</th><th>legbids</th><th>legasks</th></tr></thead><tbody><tr><td>0</td><td>5716175</td><td>2019-11-21</td><td>2019-11-21 14:46:53.991789</td><td>2019-11-21 14:46:53.991622</td><td>1</td><td>-475</td><td>-11000</td><td>0</td><td>5716153 1 -7275.00 |5715803 1 -4050.00 |5716175 0 0.00 |</td><td>5716153 3 -7250.00 |5715803 1 -3750.00 |5716175 2 -10850.00 |</td></tr><tr><td>1</td><td>5727722</td><td>2019-11-21</td><td>2019-11-21 14:47:41.431609</td><td>2019-11-21 14:47:41.431335</td><td>1</td><td>-500</td><td>-11100</td><td>0</td><td>5727697 4 -7425.00 |5726767 1 -4025.00 |5727722 0 0.00 |</td><td>5727697 3 -7350.00 |5726767 1 -3750.00 |5727722 2 -10950.00 |</td></tr><tr><td>2</td><td>5745097</td><td>2019-11-21</td><td>2019-11-21 14:49:07.039873</td><td>2019-11-21 14:49:07.038347</td><td>1</td><td>-525</td><td>-11375</td><td>0</td><td>5745095 1 -7375.00 |5745096 1 -4275.00 |5745097 0 0.00 |</td><td>5745095 2 -7350.00 |5745096 1 -4025.00 |5745097 2 -11125.00 |</td></tr><tr><td>3</td><td>5745119</td><td>2019-11-21</td><td>2019-11-21 14:49:07.040215</td><td>2019-11-21 14:49:07.038521</td><td>1</td><td>-550</td><td>-11375</td><td>0</td><td>5745119 3 -7400.00 |5745096 1 -4275.00 |5745097 0 0.00 |</td><td>5745119 2 -7350.00 |5745096 1 -4025.00 |5745097 2 -11125.00 |</td></tr><tr><td>4</td><td>5745119</td><td>2019-11-21</td><td>2019-11-21 14:49:07.040215</td><td>2019-11-21 14:49:07.038521</td><td>1</td><td>-550</td><td>-11375</td><td>0</td><td>5745119 3 -7400.00 |5745096 1 -4275.00 |5745097 0 0.00 |</td><td>5745119 2 -7350.00 |5745096 1 -4025.00 |5745097 2 -11125.00 |</td></tr><tr><td>5</td><td>5745124</td><td>2019-11-21</td><td>2019-11-21 14:49:07.040277</td><td>2019-11-21 14:49:07.038560</td><td>1</td><td>-550</td><td>-11375</td><td>0</td><td>5745119 3 -7400.00 |5745124 1 -4275.00 |5745097 0 0.00 |</td><td>5745119 2 -7350.00 |5745124 1 -4025.00 |5745097 2 -11125.00 |</td></tr><tr><td>6</td><td>5745124</td><td>2019-11-21</td><td>2019-11-21 14:49:07.040277</td><td>2019-11-21 14:49:07.038560</td><td>1</td><td>-550</td><td>-11375</td><td>0</td><td>5745119 3 -7400.00 |5745124 1 -4275.00 |5745097 0 0.00 |</td><td>5745119 2 -7350.00 |5745124 1 -4025.00 |5745097 2 -11125.00 |</td></tr><tr><td>7</td><td>5745157</td><td>2019-11-21</td><td>2019-11-21 14:49:07.040776</td><td>2019-11-21 14:49:07.039250</td><td>1</td><td>-550</td><td>-11375</td><td>0</td><td>5745157 3 -7400.00 |5745124 1 -4275.00 |5745097 0 0.00 |</td><td>5745157 1 -7350.00 |5745124 1 -4025.00 |5745097 2 -11125.00 |</td></tr><tr><td>8</td><td>5747196</td><td>2019-11-21</td><td>2019-11-21 14:49:12.635871</td><td>2019-11-21 14:49:12.632905</td><td>1</td><td>-600</td><td>-11425</td><td>0</td><td>5747194 4 -7375.00 |5747165 1 -4350.00 |5747196 0 0.00 |</td><td>5747194 1 -7325.00 |5747165 2 -4100.00 |5747196 2 -11125.00 |</td></tr><tr><td>9</td><td>5747199</td><td>2019-11-21</td><td>2019-11-21 14:49:12.635905</td><td>2019-11-21 14:49:12.632932</td><td>1</td><td>-250</td><td>-11425</td><td>0</td><td>5747194 4 -7375.00 |5747165 1 -4350.00 |5747199 0 0.00 |</td><td>5747194 1 -7325.00 |5747165 2 -4100.00 |5747199 2 -11475.00 |</td></tr><tr><td>10</td><td>5747203</td><td>2019-11-21</td><td>2019-11-21 14:49:12.635946</td><td>2019-11-21 14:49:12.632965</td><td>1</td><td>-250</td><td>-11425</td><td>0</td><td>5747194 4 -7375.00 |5747165 1 -4350.00 |5747203 0 0.00 |</td><td>5747194 1 -7325.00 |5747165 2 -4100.00 |5747203 2 -11475.00 |</td></tr><tr><td>11</td><td>5747266</td><td>2019-11-21</td><td>2019-11-21 14:49:12.636993</td><td>2019-11-21 14:49:12.633635</td><td>1</td><td>-250</td><td>-11425</td><td>0</td><td>5747194 4 -7375.00 |5747266 1 -4350.00 |5747203 0 0.00 |</td><td>5747194 1 -7325.00 |5747266 2 -4100.00 |5747203 2 -11475.00 |</td></tr><tr><td>12</td><td>5747266</td><td>2019-11-21</td><td>2019-11-21 14:49:12.636993</td><td>2019-11-21 14:49:12.633635</td><td>1</td><td>-250</td><td>-11425</td><td>0</td><td>5747194 4 -7375.00 |5747266 1 -4350.00 |5747203 0 0.00 |</td><td>5747194 1 -7325.00 |5747266 2 -4100.00 |5747203 2 -11475.00 |</td></tr><tr><td>13</td><td>5747274</td><td>2019-11-21</td><td>2019-11-21 14:49:12.637123</td><td>2019-11-21 14:49:12.633695</td><td>1</td><td>-250</td><td>-11475</td><td>0</td><td>5747194 4 -7375.00 |5747274 1 -4350.00 |5747203 0 0.00 |</td><td>5747194 1 -7325.00 |5747274 2 -4150.00 |5747203 2 -11475.00 |</td></tr><tr><td>14</td><td>5747274</td><td>2019-11-21</td><td>2019-11-21 14:49:12.637123</td><td>2019-11-21 14:49:12.633707</td><td>1</td><td>-250</td><td>-11475</td><td>0</td><td>5747194 4 -7375.00 |5747274 1 -4350.00 |5747203 0 0.00 |</td><td>5747194 1 -7325.00 |5747274 2 -4150.00 |5747203 2 -11475.00 |</td></tr><tr><td>15</td><td>5747295</td><td>2019-11-21</td><td>2019-11-21 14:49:12.637433</td><td>2019-11-21 14:49:12.633978</td><td>1</td><td>-250</td><td>-11475</tLine truncated
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"display(synth.OrderBy(x => x.sending_time));"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 10,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 11,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"scrolled": true
|
||||
},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 13,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 16,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"scrolled": true
|
||||
},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": ".NET (C#)",
|
||||
"language": "C#",
|
||||
"name": ".net-csharp"
|
||||
},
|
||||
"language_info": {
|
||||
"file_extension": ".cs",
|
||||
"mimetype": "text/x-csharp",
|
||||
"name": "C#",
|
||||
"pygments_lexer": "csharp",
|
||||
"version": "8.0"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 2
|
||||
}
|
||||
@@ -63,7 +63,22 @@
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"ename": "Unhandled Exception",
|
||||
"evalue": "Could not load file or assembly 'protobuf-net, Version=2.3.2.0, Culture=neutral, PublicKeyToken=257b51d87d2e4d67'. The system cannot find the file specified.",
|
||||
"output_type": "error",
|
||||
"traceback": [
|
||||
"Unhandled Exception",
|
||||
"Could not load file or assembly 'protobuf-net, Version=2.3.2.0, Culture=neutral, PublicKeyToken=257b51d87d2e4d67'. The system cannot find the file specified.",
|
||||
" at mbts.config.Configuration.get[T]()",
|
||||
" at bts.history.Query..ctor(String database, String host, Int32 port, String user, String pass) in c:\\code\\bts\\spark\\src\\client\\spark_historical\\Query\\Query.cs:line 30",
|
||||
" at Submission#4.<<Initialize>>d__0.MoveNext()",
|
||||
"--- End of stack trace from previous location where exception was thrown ---",
|
||||
" at Microsoft.CodeAnalysis.Scripting.ScriptExecutionState.RunSubmissionsAsync[TResult](ImmutableArray`1 precedingExecutors, Func`2 currentExecutor, StrongBox`1 exceptionHolderOpt, Func`2 catchExceptionOpt, CancellationToken cancellationToken)"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"var q = new Query(\"oil_11_20\", \"bigblue\");\n",
|
||||
"//Timestamp ts = new Timestamp();\n",
|
||||
@@ -76,7 +91,20 @@
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"ename": "Unhandled Exception",
|
||||
"evalue": "Object reference not set to an instance of an object.",
|
||||
"output_type": "error",
|
||||
"traceback": [
|
||||
"Unhandled Exception",
|
||||
"Object reference not set to an instance of an object.",
|
||||
" at Submission#5.<<Initialize>>d__0.MoveNext()",
|
||||
"--- End of stack trace from previous location where exception was thrown ---",
|
||||
" at Microsoft.CodeAnalysis.Scripting.ScriptExecutionState.RunSubmissionsAsync[TResult](ImmutableArray`1 precedingExecutors, Func`2 currentExecutor, StrongBox`1 exceptionHolderOpt, Func`2 catchExceptionOpt, CancellationToken cancellationToken)"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"var c1 = q.collection<HistoryRow>(\"CLZ9-CLF0\");\n",
|
||||
"var c2 = q.collection<HistoryRow>(\"CLF0-CLG0\");\n",
|
||||
@@ -109,7 +137,20 @@
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"ename": "Unhandled Exception",
|
||||
"evalue": "Object reference not set to an instance of an object.",
|
||||
"output_type": "error",
|
||||
"traceback": [
|
||||
"Unhandled Exception",
|
||||
"Object reference not set to an instance of an object.",
|
||||
" at Submission#7.<<Initialize>>d__0.MoveNext()",
|
||||
"--- End of stack trace from previous location where exception was thrown ---",
|
||||
" at Microsoft.CodeAnalysis.Scripting.ScriptExecutionState.RunSubmissionsAsync[TResult](ImmutableArray`1 precedingExecutors, Func`2 currentExecutor, StrongBox`1 exceptionHolderOpt, Func`2 catchExceptionOpt, CancellationToken cancellationToken)"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"var begin = DateTime.SpecifyKind(new DateTime(2019, 11, 19, 0, 0, 0), DateTimeKind.Utc);\n",
|
||||
"var end = DateTime.SpecifyKind(new DateTime(2019, 11, 22, 23, 59, 59), DateTimeKind.Utc);\n",
|
||||
@@ -128,31 +169,17 @@
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"18844"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"83773"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"35257"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
"ename": "Unhandled Exception",
|
||||
"evalue": "Value cannot be null. (Parameter 'source')",
|
||||
"output_type": "error",
|
||||
"traceback": [
|
||||
"Unhandled Exception",
|
||||
"Value cannot be null. (Parameter 'source')",
|
||||
" at System.Linq.Queryable.Count[TSource](IQueryable`1 source)",
|
||||
" at Submission#8.<<Initialize>>d__0.MoveNext()",
|
||||
"--- End of stack trace from previous location where exception was thrown ---",
|
||||
" at Microsoft.CodeAnalysis.Scripting.ScriptExecutionState.RunSubmissionsAsync[TResult](ImmutableArray`1 precedingExecutors, Func`2 currentExecutor, StrongBox`1 exceptionHolderOpt, Func`2 catchExceptionOpt, CancellationToken cancellationToken)"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
@@ -170,17 +197,22 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 23,
|
||||
"execution_count": 8,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<table><thead><tr><th>TopBook</th><th>value</th><th>trade_date</th><th>sending_time</th><th>transact_time</th><th>MsgSeqNum</th></tr></thead><tbody><tr><td>{ bts.co2.TopBookMessage: Bid: { bts.co2.PriceSizeMessage: Mantissa: 0, Exponent: 0, Size: 9 }, Ask: { bts.co2.PriceSizeMessage: Mantissa: 4, Exponent: 0, Size: 17 } }</td><td>{ bts.history.HistoryRow: trade_date: 2019-11-20 00:00:00Z, sending_time: 2019-11-20 16:23:37Z, transact_time: 2019-11-20 16:23:37Z, TradeDate: { Google.Protobuf.WellKnownTypes.Timestamp: Seconds: 1574208000, Nanos: 0 }, MsgSeqNum: 106692306, SendingTime: { Google.Protobuf.WellKnownTypes.Timestamp: Seconds: 1574267017, Nanos: 559710300 }, TransactTime: { Google.Protobuf.WellKnownTypes.Timestamp: Seconds: 1574267017, Nanos: 559610900 }, SecurityDesc: CLZ9-CLG0, Book: { bts.co2.BookMessage: Bids: [ { bts.co2.PriceSizeMessage: Mantissa: 0, Exponent: 0, Size: 9 }, { bts.co2.PriceSizeMessage: Mantissa: -1, Exponent: 0, Size: 14 }, { bts.co2.PriceSizeMessage: Mantissa: -2, Exponent: 0, Size: 50 }, { bts.co2.PriceSizeMessage: Mantissa: -3, Exponent: 0, Size: 10 }, { bts.co2.PriceSizeMessage: Mantissa: -4, Exponent: 0, Size: 10 }, { bts.co2.PriceSizeMessage: Mantissa: -5, Exponent: 0, Size: 10 }, { bts.co2.PriceSizeMessage: Mantissa: -6, Exponent: 0, Size: 10 }, { bts.co2.PriceSizeMessage: Mantissa: -7, Exponent: 0, Size: 10 }, { bts.co2.PriceSizeMessage: Mantissa: -8, Exponent: 0, Size: 10 }, { bts.co2.PriceSizeMessage: Mantissa: -9, Exponent: 0, Size: 10 } ], Asks: [ { bts.co2.PriceSizeMessage: Mantissa: 4, Exponent: 0, Size: 17 }, { bts.co2.PriceSizeMessage: Mantissa: 5, Exponent: 0, Size: 15 }, { bts.co2.PriceSizeMessage: Mantissa: 6, Exponent: 0, Size: 10 }, { bts.co2.PriceSizeMessage: Mantissa: 7, Exponent: 0, Size: 10 }, { bts.co2.PriceSizeMessage: Mantissa: 8, Exponent: 0, Size: 10 }, { bts.co2.PriceSizeMessage: Mantissa: 9, Exponent: 0, Size: 10 }, { bts.co2.PriceSizeMessage: Mantissa: 10, Exponent: 0, Size: 10 }, { bts.co2.PriceSizeMessage: Mantissa: 11, Exponent: 0, Size: 10 }, { bts.co2.PriceSizeMessage: Mantissa: 0, Exponent: 0, Size: 0 }, { bts.co2.PriceSizeMessage: Mantissa: 0, Exponent: 0, Size: 0 } ] }, TopBook: <null>, Trade: <null>, Order: <null> }</td><td>2019-11-20 00:00:00Z</td><td>2019-11-20 16:23:37Z</td><td>2019-11-20 16:23:37Z</td><td>106692306</td></tr></tbody></table>"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
"ename": "Unhandled Exception",
|
||||
"evalue": "Value cannot be null. (Parameter 'source')",
|
||||
"output_type": "error",
|
||||
"traceback": [
|
||||
"Unhandled Exception",
|
||||
"Value cannot be null. (Parameter 'source')",
|
||||
" at System.Linq.Queryable.Where[TSource](IQueryable`1 source, Expression`1 predicate)",
|
||||
" at MongoDB.Driver.Linq.MongoQueryable.Where[TSource](IMongoQueryable`1 source, Expression`1 predicate)",
|
||||
" at Submission#9.<<Initialize>>d__0.MoveNext()",
|
||||
"--- End of stack trace from previous location where exception was thrown ---",
|
||||
" at Microsoft.CodeAnalysis.Scripting.ScriptExecutionState.RunSubmissionsAsync[TResult](ImmutableArray`1 precedingExecutors, Func`2 currentExecutor, StrongBox`1 exceptionHolderOpt, Func`2 catchExceptionOpt, CancellationToken cancellationToken)"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
@@ -198,9 +230,18 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 24,
|
||||
"execution_count": 9,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"ename": "Unhandled Exception",
|
||||
"evalue": "(10,34): error CS1061: 'T' does not contain a definition for 'MsgSeqNum' and no accessible extension method 'MsgSeqNum' accepting a first argument of type 'T' could be found (are you missing a using directive or an assembly reference?)\r\n(11,39): error CS1061: 'T' does not contain a definition for 'trade_date' and no accessible extension method 'trade_date' accepting a first argument of type 'T' could be found (are you missing a using directive or an assembly reference?)\r\n(12,41): error CS1061: 'T' does not contain a definition for 'sending_time' and no accessible extension method 'sending_time' accepting a first argument of type 'T' could be found (are you missing a using directive or an assembly reference?)\r\n(13,42): error CS1061: 'T' does not contain a definition for 'transact_time' and no accessible extension method 'transact_time' accepting a first argument of type 'T' could be found (are you missing a using directive or an assembly reference?)\r\n(19,51): error CS1061: 'T' does not contain a definition for 'MsgSeqNum' and no accessible extension method 'MsgSeqNum' accepting a first argument of type 'T' could be found (are you missing a using directive or an assembly reference?)\r\n(21,51): error CS1061: 'T' does not contain a definition for 'MsgSeqNum' and no accessible extension method 'MsgSeqNum' accepting a first argument of type 'T' could be found (are you missing a using directive or an assembly reference?)",
|
||||
"output_type": "error",
|
||||
"traceback": [
|
||||
"(10,34): error CS1061: 'T' does not contain a definition for 'MsgSeqNum' and no accessible extension method 'MsgSeqNum' accepting a first argument of type 'T' could be found (are you missing a using directive or an assembly reference?)\r\n(11,39): error CS1061: 'T' does not contain a definition for 'trade_date' and no accessible extension method 'trade_date' accepting a first argument of type 'T' could be found (are you missing a using directive or an assembly reference?)\r\n(12,41): error CS1061: 'T' does not contain a definition for 'sending_time' and no accessible extension method 'sending_time' accepting a first argument of type 'T' could be found (are you missing a using directive or an assembly reference?)\r\n(13,42): error CS1061: 'T' does not contain a definition for 'transact_time' and no accessible extension method 'transact_time' accepting a first argument of type 'T' could be found (are you missing a using directive or an assembly reference?)\r\n(19,51): error CS1061: 'T' does not contain a definition for 'MsgSeqNum' and no accessible extension method 'MsgSeqNum' accepting a first argument of type 'T' could be found (are you missing a using directive or an assembly reference?)\r\n(21,51): error CS1061: 'T' does not contain a definition for 'MsgSeqNum' and no accessible extension method 'MsgSeqNum' accepting a first argument of type 'T' could be found (are you missing a using directive or an assembly reference?)"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"class TopReport<T> where T : IHasTopBook, IHasTimestamp, Google.Protobuf.IDeepCloneable<T>\n",
|
||||
"{\n",
|
||||
@@ -239,9 +280,18 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 25,
|
||||
"execution_count": 10,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"ename": "Unhandled Exception",
|
||||
"evalue": "(4,55): error CS0246: The type or namespace name 'TopReport<>' could not be found (are you missing a using directive or an assembly reference?)",
|
||||
"output_type": "error",
|
||||
"traceback": [
|
||||
"(4,55): error CS0246: The type or namespace name 'TopReport<>' could not be found (are you missing a using directive or an assembly reference?)"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"\n",
|
||||
"var synth = create_synthetic_top( new []{c1top, c2top, c3top}, new[] {1.0, 1.0, -1.0}, new[] {1.0, 1.0, -1.0}, \n",
|
||||
@@ -251,17 +301,16 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 26,
|
||||
"execution_count": 11,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<table><thead><tr><th><i>index</i></th><th>seq_num</th><th>trade_date</th><th>sending_time</th><th>transact_time</th><th>bidsize</th><th>bid</th><th>ask</th><th>asksize</th><th>legbids</th><th>legasks</th></tr></thead><tbody><tr><td>0</td><td>77632899</td><td>2019-11-20</td><td>2019-11-19 23:01:29.444834</td><td>2019-11-19 23:01:29.444674</td><td>1</td><td>-25</td><td>-1</td><td>0</td><td>77623170 26 -13.00 |77632359 599 10.00 |77632899 0 0.00 |</td><td>77623170 9 -12.00 |77632359 809 11.00 |77632899 1 22.00 |</td></tr><tr><td>1</td><td>77632900</td><td>2019-11-20</td><td>2019-11-19 23:01:29.444935</td><td>2019-11-19 23:01:29.444830</td><td>1</td><td>-25</td><td>-1</td><td>0</td><td>77623170 26 -13.00 |77632359 599 10.00 |77632900 0 0.00 |</td><td>77623170 9 -12.00 |77632359 809 11.00 |77632900 1 22.00 |</td></tr><tr><td>2</td><td>77633139</td><td>2019-11-20</td><td>2019-11-19 23:01:31.008894</td><td>2019-11-19 23:01:31.008777</td><td>1</td><td>-25</td><td>-1</td><td>0</td><td>77623170 26 -13.00 |77633139 599 10.00 |77632900 0 0.00 |</td><td>77623170 9 -12.00 |77633139 809 11.00 |77632900 1 22.00 |</td></tr><tr><td>3</td><td>77633233</td><td>2019-11-20</td><td>2019-11-19 23:01:31.507462</td><td>2019-11-19 23:01:31.507346</td><td>1</td><td>-25</td><td>-1</td><td>0</td><td>77623170 26 -13.00 |77633233 599 10.00 |77632900 0 0.00 |</td><td>77623170 9 -12.00 |77633233 809 11.00 |77632900 1 22.00 |</td></tr><tr><td>4</td><td>77633265</td><td>2019-11-20</td><td>2019-11-19 23:01:32.157546</td><td>2019-11-19 23:01:32.157409</td><td>1</td><td>-10</td><td>-1</td><td>0</td><td>77623170 26 -13.00 |77633233 599 10.00 |77633265 0 0.00 |</td><td>77623170 9 -12.00 |77633233 809 11.00 |77633265 1 7.00 |</td></tr><tr><td>5</td><td>77633266</td><td>2019-11-20</td><td>2019-11-19 23:01:32.157639</td><td>2019-11-19 23:01:32.157536</td><td>1</td><td>-10</td><td>-1</td><td>0</td><td>77623170 26 -13.00 |77633233 599 10.00 |77633266 0 0.00 |</td><td>77623170 9 -12.00 |77633233 809 11.00 |77633266 1 7.00 |</td></tr><tr><td>6</td><td>77633967</td><td>2019-11-20</td><td>2019-11-19 23:01:38.955779</td><td>2019-11-19 23:01:38.955632</td><td>1</td><td>-6</td><td>-1</td><td>0</td><td>77623170 26 -13.00 |77633233 599 10.00 |77633967 0 0.00 |</td><td>77623170 9 -12.00 |77633233 809 11.00 |77633967 1 3.00 |</td></tr><tr><td>7</td><td>77633968</td><td>2019-11-20</td><td>2019-11-19 23:01:38.955866</td><td>2019-11-19 23:01:38.955760</td><td>1</td><td>-6</td><td>-1</td><td>0</td><td>77623170 26 -13.00 |77633233 599 10.00 |77633968 0 0.00 |</td><td>77623170 9 -12.00 |77633233 809 11.00 |77633968 1 3.00 |</td></tr><tr><td>8</td><td>77634067</td><td>2019-11-20</td><td>2019-11-19 23:01:41.509218</td><td>2019-11-19 23:01:41.509092</td><td>1</td><td>-6</td><td>-1</td><td>0</td><td>77623170 26 -13.00 |77634067 599 10.00 |77633968 0 0.00 |</td><td>77623170 9 -12.00 |77634067 809 11.00 |77633968 1 3.00 |</td></tr><tr><td>9</td><td>77634146</td><td>2019-11-20</td><td>2019-11-19 23:01:42.008457</td><td>2019-11-19 23:01:42.008346</td><td>1</td><td>-6</td><td>-1</td><td>0</td><td>77623170 26 -13.00 |77634146 599 10.00 |77633968 0 0.00 |</td><td>77623170 9 -12.00 |77634146 809 11.00 |77633968 1 3.00 |</td></tr><tr><td>10</td><td>77634662</td><td>2019-11-20</td><td>2019-11-19 23:01:44.039520</td><td>2019-11-19 23:01:44.039346</td><td>1</td><td>-4</td><td>-1</td><td>0</td><td>77623170 26 -13.00 |77634146 599 10.00 |77634662 0 0.00 |</td><td>77623170 9 -12.00 |77634146 809 11.00 |77634662 1 1.00 |</td></tr><tr><td>11</td><td>77634663</td><td>2019-11-20</td><td>2019-11-19 23:01:44.039606</td><td>2019-11-19 23:01:44.039493</td><td>1</td><td>-4</td><td>-1</td><td>0</td><td>77623170 26 -13.00 |77634146 599 10.00 |77634663 0 0.00 |</td><td>77623170 9 -12.00 |77634146 809 11.00 |77634663 1 1.00 |</td></tr><tr><td>12</td><td>77635060</td><td>2019-11-20</td><td>2019-11-19 23:01:52.009603</td><td>2019-11-19 23:01:52.009478</td><td>1</td><td>-4</td><td>-1</td><td>0</td><td>77623170 26 -13.00 |77635060 599 10.00 |77634663 0 0.00 |</td><td>77623170 9 -12.00 |77635060 809 11.00 |77634663 1 1.00 |</td></tr><tr><td>13</td><td>77635104</td><td>2019-11-20</td><td>2019-11-19 23:01:52.509048</td><td>2019-11-19 23:01:52.508929</td><td>1</td><td>-4</td><td>-1</td><td>0</td><td>77623170 26 -13.00 |77635104 599 10.00 |77634663 0 0.00 |</td><td>77623170 9 -12.00 |77635104 809 11.00 |77634663 1 1.00 |</td></tr><tr><td>14</td><td>77635195</td><td>2019-11-20</td><td>2019-11-19 23:01:54.107257</td><td>2019-11-19 23:01:54.107128</td><td>1</td><td>-4</td><td>-1</td><td>0</td><td>77623170 26 -13.00 |77635104 599 10.00 |77635195 0 0.00 |</td><td>77623170 9 -12.00 |77635104 809 11.00 |77635195 1 1.00 |</td></tr><tr><td>15</td><td>77635196</td><td>2019-11-20</td><td>2019-11-19 23:01:54.107340</td><td>2019-11-19 23:01:54.107238</td><td>1</td><td>-4</td><td>-1</td><td>0</td><td>77623170 26 -13.00 |77635104 599 10.00 |77635196 0 0.00 |</td><td>77623170 9 -12.00 |77635104 809 11.00 |77635196 Line truncated
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
"ename": "Unhandled Exception",
|
||||
"evalue": "(1,9): error CS0103: The name 'synth' does not exist in the current context",
|
||||
"output_type": "error",
|
||||
"traceback": [
|
||||
"(1,9): error CS0103: The name 'synth' does not exist in the current context"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
|
||||
@@ -1,343 +0,0 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {
|
||||
"scrolled": true
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Invalid: Command: #r C:/Users/darby/.nuget/packages/google.protobuf/3.6.1/lib/netstandard1.0/Google.Protobuf.dllInvalid: Command: #r C:/Users/darby/.nuget/packages/newtonsoft.json/12.0.3/lib/netstandard2.0/Newtonsoft.Json.dllInvalid: Command: #r C:/Users/darby/.nuget/packages/system.linq.dynamic.core/1.0.19/lib/netstandard2.0/System.Linq.Dynamic.Core.dllInvalid: Command: #r C:/Users/darby/.nuget/packages/mongodb.driver/2.9.3/lib/netstandard1.5/MongoDB.Driver.dllInvalid: Command: #r C:/Users/darby/.nuget/packages/mongodb.driver.core/2.9.3/lib/netstandard1.5/MongoDB.Driver.Core.dllInvalid: Command: #r C:/Users/darby/.nuget/packages/mongodb.bson/2.9.3/lib/netstandard1.5/MongoDB.Bson.dll"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"//#r \"nuget:Google.Protobuf, 3.6.1\"\n",
|
||||
"#r \"C:/Users/darby/.nuget/packages/google.protobuf/3.6.1/lib/netstandard1.0/Google.Protobuf.dll\"\n",
|
||||
"//#r \"nuget:Microsoft.CSharp, 4.5.0\"\n",
|
||||
"//#r \"C:/Users/darby/.nuget/packages/microsoft.netcore.app.runtime.linux-x64/3.0.0/runtimes/linux-x64/lib/netcoreapp3.0/Microsoft.CSharp.dll\" \n",
|
||||
"//#r \"nuget:Newtonsoft.Json, 12.0.3\"\n",
|
||||
"#r \"C:/Users/darby/.nuget/packages/newtonsoft.json/12.0.3/lib/netstandard2.0/Newtonsoft.Json.dll\"\n",
|
||||
"//#r \"nuget:System.Linq.Dynamic, 1.0.7\"\n",
|
||||
"#r \"C:/Users/darby/.nuget/packages/system.linq.dynamic.core/1.0.19/lib/netstandard2.0/System.Linq.Dynamic.Core.dll\"\n",
|
||||
"//#r \"nuget:MongoDB.Driver, 2.9.3\"\n",
|
||||
"#r \"C:/Users/darby/.nuget/packages/mongodb.driver/2.9.3/lib/netstandard1.5/MongoDB.Driver.dll\" \n",
|
||||
"#r \"C:/Users/darby/.nuget/packages/mongodb.driver.core/2.9.3/lib/netstandard1.5/MongoDB.Driver.Core.dll\"\n",
|
||||
"//#r \"nuget:MongoDB.Bson, 2.9.3\"\n",
|
||||
"#r \"C:/Users/darby/.nuget/packages/mongodb.bson/2.9.3/lib/netstandard1.5/MongoDB.Bson.dll\" "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"scrolled": true
|
||||
},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"metadata": {
|
||||
"scrolled": true
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Invalid: Command: #r c:/code/bts/spark/build/Debug/bin/netstandard2.0/spark_historical.dll"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"#r \"c:/code/bts/spark/build/Debug/bin/netstandard2.0/spark_historical.dll\" \n",
|
||||
"using bts.history;\n",
|
||||
"using MongoDB.Driver;\n",
|
||||
"using MongoDB.Driver.Linq;\n",
|
||||
"using Google.Protobuf.WellKnownTypes;\n",
|
||||
"using static bts.history.Query;\n",
|
||||
"using MathNet.Numerics.Statistics;\n",
|
||||
"using mbts.co2;\n",
|
||||
"\n",
|
||||
"bts.BTS.init();\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 9,
|
||||
"metadata": {
|
||||
"scrolled": true
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"var q = new Query(\"10Y_201911_W4\", \"bigblue\");"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 10,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"var c1 = q.collection<HistoryRow>(\"ZNZ9\");\n",
|
||||
"var c2 = q.collection<HistoryRow>(\"ZNH0\");\n",
|
||||
"var c3 = q.collection<HistoryRow>(\"ZNZ9-ZNH0\");\n",
|
||||
"\n",
|
||||
" "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"scrolled": true
|
||||
},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"scrolled": true
|
||||
},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 11,
|
||||
"metadata": {
|
||||
"scrolled": true
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"var begin = DateTime.SpecifyKind(new DateTime(2019, 11, 25, 10, 0, 0), DateTimeKind.Utc);\n",
|
||||
"var end = DateTime.SpecifyKind(new DateTime(2019, 11, 25, 23, 59, 59), DateTimeKind.Utc);\n",
|
||||
"var c1t = q.timeseries<HistoryRow>(c1, begin, end).OrderBy(x => x.sending_time);\n",
|
||||
"var c2t = q.timeseries<HistoryRow>(c2, begin, end).OrderBy(x => x.sending_time);\n",
|
||||
"var c3t = q.timeseries<HistoryRow>(c3, begin, end).OrderBy(x => x.sending_time);\n",
|
||||
"\n",
|
||||
"//local copy so we don't beat up the database\n",
|
||||
"var c1f = local(c1t).ToArray();\n",
|
||||
"var c2f = local(c2t).ToArray();\n",
|
||||
"var c3f = local(c3t).ToArray();"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 12,
|
||||
"metadata": {
|
||||
"scrolled": true
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"913591"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"517775"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"494994"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"display(c1f.Count());\n",
|
||||
"display(c2f.Count());\n",
|
||||
"display(c3f.Count());\n",
|
||||
"//display(c1t.Count());\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 13,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"class AlgoReport\n",
|
||||
"{\n",
|
||||
" readonly AlgoResults _res;\n",
|
||||
" public string security_desc => _res.security_desc;\n",
|
||||
" public string transact_time => _res.data?.transact_time.ToString(\"yyyy-MM-dd HH:mm:ss.ffffff\");\n",
|
||||
" public MarketBook market_book { get;}\n",
|
||||
" public MarketTrade market_trade { get;} \n",
|
||||
" public OurOrder our_order { get; }\n",
|
||||
" public OurFill our_fill { get; } \n",
|
||||
" public AlgoReport(AlgoResults res)\n",
|
||||
" {\n",
|
||||
" _res = res;\n",
|
||||
" if(res.book != null)\n",
|
||||
" market_book = new MarketBook(_res); \n",
|
||||
" if(res.trade != null)\n",
|
||||
" market_trade = new MarketTrade(_res);\n",
|
||||
" if(res.order != null)\n",
|
||||
" our_order = new OurOrder(_res);\n",
|
||||
" if(res.fill != null)\n",
|
||||
" our_fill = new OurFill(_res);\n",
|
||||
" }\n",
|
||||
" \n",
|
||||
" internal class MarketBook\n",
|
||||
" {\n",
|
||||
" AlgoResults _res;\n",
|
||||
" public MarketBook(AlgoResults res) { _res = res; }\n",
|
||||
" \n",
|
||||
" public uint? market_book_bid_size => _res.book?.Bids?[0].Size; \n",
|
||||
" public double? market_book_bid => \n",
|
||||
" NativePriceHelpers.to_double(_res.book?.Bids?[0].Mantissa ?? 0, (sbyte)(_res.book?.Bids?[0].Exponent ?? 0)); \n",
|
||||
" public double? market_book_ask => \n",
|
||||
" NativePriceHelpers.to_double(_res.book?.Asks?[0].Mantissa ?? 0, (sbyte)(_res.book?.Asks?[0].Exponent ?? 0)); \n",
|
||||
" public uint? market_book_ask_size => _res.book?.Asks?[0].Size; \n",
|
||||
" } \n",
|
||||
" \n",
|
||||
" internal class MarketTrade\n",
|
||||
" {\n",
|
||||
" AlgoResults _res;\n",
|
||||
" public MarketTrade(AlgoResults res) { _res = res; }\n",
|
||||
" public string market_trade_side => _res.trade?.AggressorSide.ToString();\n",
|
||||
" public double? market_trade_price => \n",
|
||||
" NativePriceHelpers.to_double(_res.trade?.Mantissa ?? 0, (sbyte)(_res.trade?.Exponent ?? 0));\n",
|
||||
" public uint? market_trade_size => _res.trade?.Size; \n",
|
||||
" }\n",
|
||||
"\n",
|
||||
" internal class OurOrder\n",
|
||||
" {\n",
|
||||
" AlgoResults _res;\n",
|
||||
" public OurOrder(AlgoResults res) { _res = res; }\n",
|
||||
" public string security_desc => _res.security_desc;\n",
|
||||
" public string our_order_time => _res.order?.last_change.ToDateTime().ToString(\"yyyy-MM-dd HH:mm:ss.ffffff\"); \n",
|
||||
" public string our_order_side => _res.order?.side.ToString();\n",
|
||||
" public string our_order_status => _res.order?.state.Status.ToString();\n",
|
||||
" public double? our_order_price => _res.order?.state.Price;\n",
|
||||
" public uint? our_order_size => _res.order?.state.Quantity;\n",
|
||||
" public uint? our_order_filled => _res.order?.state.FilledQuantity;\n",
|
||||
" }\n",
|
||||
" \n",
|
||||
" internal class OurFill\n",
|
||||
" {\n",
|
||||
" AlgoResults _res;\n",
|
||||
" public OurFill(AlgoResults res) { _res = res; }\n",
|
||||
" public string our_fill_time => _res.fill?.timestamp.ToDateTime().ToString(\"yyyy-MM-dd HH:mm:ss.ffffff\"); \n",
|
||||
" public string our_fill_side => _res.fill?.side.ToString();\n",
|
||||
" public double? our_fill_price => _res.fill?.price;\n",
|
||||
" public ulong? our_fill_size => _res.fill?.size;\n",
|
||||
" public int? our_fill_piq => _res.fill?.piq; \n",
|
||||
" public string tag => _res.fill?.tag;\n",
|
||||
" }\n",
|
||||
"}"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 15,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"var security_list = new [] {\"ZNH0\",\"ZNZ9-ZNH0\", \"ZNZ9\"};\n",
|
||||
"//quotes the last leg\n",
|
||||
"var algo_type = typeof(RoundTrip);\n",
|
||||
"var algo_params = \"size=10;tick_size=0.015625,0.0078125,0.015625;hedge_factors=1,1,-1\";\n",
|
||||
"\n",
|
||||
"//var algo = AlgoFactory.algo_factory(typeof(RoundTrip), sink, security_list, algo_params);"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 16,
|
||||
"metadata": {
|
||||
"scrolled": true
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"var sink = new FIFOModel(new Bucket(0, 1));\n",
|
||||
"var stream = run_algo<HistoryRow,AlgoReport>(algo_type, sink, algo_params,\n",
|
||||
" bts.api.Side.Undefined, 0.0, 10, security_list, \n",
|
||||
" new[] {c2f, c3f, c1f}, x => x.Select(xx => new AlgoReport(xx)) );\n",
|
||||
"\n",
|
||||
"var streamlocal = stream.ToArray();\n",
|
||||
"\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 21,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<table><thead><tr><th><i>index</i></th><th>security_desc</th><th>transact_time</th><th>market_book</th><th>market_trade</th><th>our_order</th><th>our_fill</th></tr></thead><tbody><tr><td>0</td><td>ZNZ9</td><td>2019-11-25 15:00:00.000011</td><td>{ Submission#14+AlgoReport+MarketBook: market_book_bid_size: 1976, market_book_bid: 129.53125, market_book_ask: 129.546875, market_book_ask_size: 1324 }</td><td>{ Submission#14+AlgoReport+MarketTrade: market_trade_side: Sell, market_trade_price: 129.53125, market_trade_size: 8 }</td><td>{ Submission#14+AlgoReport+OurOrder: security_desc: ZNZ9, our_order_time: 2019-11-25 15:00:00.252817, our_order_side: Sell, our_order_status: Canceled, our_order_price: 129.5859375, our_order_size: 10, our_order_filled: 0 }</td><td><null></td></tr><tr><td>1</td><td>ZNZ9</td><td>2019-11-25 15:00:00.000011</td><td>{ Submission#14+AlgoReport+MarketBook: market_book_bid_size: 1976, market_book_bid: 129.53125, market_book_ask: 129.546875, market_book_ask_size: 1324 }</td><td>{ Submission#14+AlgoReport+MarketTrade: market_trade_side: Sell, market_trade_price: 129.53125, market_trade_size: 8 }</td><td>{ Submission#14+AlgoReport+OurOrder: security_desc: ZNZ9, our_order_time: 2019-11-25 15:00:00.252817, our_order_side: Buy, our_order_status: Completed, our_order_price: 129.53125, our_order_size: 8, our_order_filled: 10 }</td><td><null></td></tr><tr><td>2</td><td>ZNZ9</td><td>2019-11-25 15:00:00.000011</td><td>{ Submission#14+AlgoReport+MarketBook: market_book_bid_size: 1976, market_book_bid: 129.53125, market_book_ask: 129.546875, market_book_ask_size: 1357 }</td><td>{ Submission#14+AlgoReport+MarketTrade: market_trade_side: Sell, market_trade_price: 129.53125, market_trade_size: 8 }</td><td>{ Submission#14+AlgoReport+OurOrder: security_desc: ZNZ9, our_order_time: 2019-11-25 15:00:00.253025, our_order_side: Sell, our_order_status: Canceled, our_order_price: 129.5859375, our_order_size: 10, our_order_filled: 0 }</td><td><null></td></tr><tr><td>3</td><td>ZNZ9</td><td>2019-11-25 15:00:00.000011</td><td>{ Submission#14+AlgoReport+MarketBook: market_book_bid_size: 1976, market_book_bid: 129.53125, market_book_ask: 129.546875, market_book_ask_size: 1357 }</td><td>{ Submission#14+AlgoReport+MarketTrade: market_trade_side: Sell, market_trade_price: 129.53125, market_trade_size: 8 }</td><td>{ Submission#14+AlgoReport+OurOrder: security_desc: ZNZ9, our_order_time: 2019-11-25 15:00:00.253025, our_order_side: Buy, our_order_status: Completed, our_order_price: 129.53125, our_order_size: 8, our_order_filled: 10 }</td><td><null></td></tr><tr><td>4</td><td>ZNZ9</td><td>2019-11-25 15:00:00.000011</td><td>{ Submission#14+AlgoReport+MarketBook: market_book_bid_size: 546, market_book_bid: 129.546875, market_book_ask: 129.5625, market_book_ask_size: 2594 }</td><td>{ Submission#14+AlgoReport+MarketTrade: market_trade_side: Sell, market_trade_price: 129.546875, market_trade_size: 6 }</td><td>{ Submission#14+AlgoReport+OurOrder: security_desc: ZNZ9, our_order_time: 2019-11-25 15:01:30.512226, our_order_side: Sell, our_order_status: Canceled, our_order_price: 129.5859375, our_order_size: 10, our_order_filled: 0 }</td><td><null></td></tr><tr><td>5</td><td>ZNZ9</td><td>2019-11-25 15:00:00.000011</td><td>{ Submission#14+AlgoReport+MarketBook: market_book_bid_size: 546, market_book_bid: 129.546875, market_book_ask: 129.5625, market_book_ask_size: 2594 }</td><td>{ Submission#14+AlgoReport+MarketTrade: market_trade_side: Sell, market_trade_price: 129.546875, market_trade_size: 6 }</td><td>{ Submission#14+AlgoReport+OurOrder: security_desc: ZNZ9, our_order_time: 2019-11-25 15:01:30.512226, our_order_side: Buy, our_order_status: Completed, our_order_price: 129.53125, our_order_size: 8, our_order_filled: 10 }</td><td><null></td></tr><tr><td>6</td><td>ZNZ9</td><td>2019-11-25 15:00:00.000011</td><td>{ Submission#14+AlgoReport+MarketBook: market_book_bid_size: 556, market_book_bid: 129.546875, market_book_ask: 129.5625, market_book_ask_size: 2614 }</td><td>{ Submission#14+AlgoReport+MarketTrade: market_trade_side: Sell, market_trade_price: 129.546875, market_trade_size: 6 }</td><td>{ Submission#14+AlgoReport+OurOrder: security_desc: ZNZ9, our_order_time: 2019-11-25 15:01:30.512278, our_order_side: Sell, our_order_status: Canceled, our_order_price: 129.5859375, our_order_size: 10, our_order_filled: 0 }</td><td><null></td></tr><tr><td>7</td><td>ZNZ9</td><td>2019-11-25 15:00:00.000011</td><td>{ Submission#14+AlgoReport+MarketBook: market_book_bid_size: 556, market_book_bid: 129.546875, market_book_ask: 129.5625, market_book_ask_size: 2614 }</td><td>{ Submission#14+AlgoReport+MarketTrade: market_trade_side: Sell, market_trade_price: 129.546875, market_trade_size: 6 }</td><td>{ Submission#14+AlgoReport+OurOrder: security_desc: ZNZ9, our_order_time: 2019-11-25 15:01:30.512278, our_order_side: Buy, our_order_status: Completed, our_order_price: 129.53125, our_order_size: 8, our_order_filLine truncated
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"var fills = streamlocal.Where(x => x.our_fill != null || x.our_order != null).OrderBy(x => x.transact_time);\n",
|
||||
"display(fills.Take(1000));\n",
|
||||
"\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 10,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": ".NET (C#)",
|
||||
"language": "C#",
|
||||
"name": ".net-csharp"
|
||||
},
|
||||
"language_info": {
|
||||
"file_extension": ".cs",
|
||||
"mimetype": "text/x-csharp",
|
||||
"name": "C#",
|
||||
"pygments_lexer": "csharp",
|
||||
"version": "8.0"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 2
|
||||
}
|
||||
@@ -238,7 +238,9 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 9,
|
||||
"metadata": {},
|
||||
"metadata": {
|
||||
"scrolled": true
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
@@ -306,34 +308,9 @@
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
" public class MBODisplay \n",
|
||||
" {\n",
|
||||
" MBOMessage _res;\n",
|
||||
" public MBODisplay(MBOMessage res)\n",
|
||||
" {\n",
|
||||
" _res = res;\n",
|
||||
" }\n",
|
||||
" \n",
|
||||
" public string OrderUpdateAction => _res.OrderUpdateAction.ToString();\n",
|
||||
" public ulong OrderId => _res.OrderId;\n",
|
||||
" public string SecurityDesc => _res.SecurityDesc;\n",
|
||||
" public ulong MdOrderPriority => _res.MdOrderPriority;\n",
|
||||
" public double MdEntryPx => _res.MdEntryPx;\n",
|
||||
" public uint MdPriceLevel => _res.MdPriceLevel;\n",
|
||||
" public ulong MdDisplayQty => _res.MdDisplayQty;\n",
|
||||
" public uint LastQty =>_res.LastQty;\n",
|
||||
" public string MdEntryType => _res.MdEntryType.ToString(); \n",
|
||||
" public string TradeDate => _res.TradeDate.ToString();\n",
|
||||
" public uint MsgSeqNum => _res.MsgSeqNum;\n",
|
||||
" public string SendingTime => _res.SendingTime.ToString();\n",
|
||||
" public string TransactTime => _res.TransactTime.ToString();\n",
|
||||
" \n",
|
||||
" public MDEntry MdEntry => _res.MdEntry;\n",
|
||||
" public OrderIDEntry OrderEntry => _res.OrderEntry;\n",
|
||||
" \n",
|
||||
" }\n",
|
||||
"\n",
|
||||
"//display(exchange_orders.Skip(20000).Take(100));\n",
|
||||
"display(exchange_orders.Where(x => x.OrderId == 846784119686).Select(x => new MBODisplay(x)));"
|
||||
"display(exchange_orders.Where(x => x.OrderId == 846784119686).Select(x => new Display.MBODisplay(x)));"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
@@ -0,0 +1,310 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {
|
||||
"scrolled": true
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Invalid: Command: #r C:/Users/darby/.nuget/packages/google.protobuf/3.6.1/lib/netstandard1.0/Google.Protobuf.dllInvalid: Command: #r C:/Users/darby/.nuget/packages/newtonsoft.json/12.0.3/lib/netstandard2.0/Newtonsoft.Json.dllInvalid: Command: #r C:/Users/darby/.nuget/packages/system.linq.dynamic.core/1.0.19/lib/netstandard2.0/System.Linq.Dynamic.Core.dllInvalid: Command: #r C:/Users/darby/.nuget/packages/mongodb.driver/2.9.3/lib/netstandard1.5/MongoDB.Driver.dllInvalid: Command: #r C:/Users/darby/.nuget/packages/mongodb.driver.core/2.9.3/lib/netstandard1.5/MongoDB.Driver.Core.dllInvalid: Command: #r C:/Users/darby/.nuget/packages/mongodb.bson/2.9.3/lib/netstandard1.5/MongoDB.Bson.dllInvalid: Command: #r C:/Users/darby/.nuget/packages/protobuf-net/2.3.2/lib/netstandard1.3/protobuf-net.dll"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"//#r \"nuget:Google.Protobuf, 3.6.1\"\n",
|
||||
"#r \"C:/Users/darby/.nuget/packages/google.protobuf/3.6.1/lib/netstandard1.0/Google.Protobuf.dll\"\n",
|
||||
"//#r \"nuget:Microsoft.CSharp, 4.5.0\"\n",
|
||||
"//#r \"C:/Users/darby/.nuget/packages/microsoft.netcore.app.runtime.linux-x64/3.0.0/runtimes/linux-x64/lib/netcoreapp3.0/Microsoft.CSharp.dll\" \n",
|
||||
"//#r \"nuget:Newtonsoft.Json, 12.0.3\"\n",
|
||||
"#r \"C:/Users/darby/.nuget/packages/newtonsoft.json/12.0.3/lib/netstandard2.0/Newtonsoft.Json.dll\"\n",
|
||||
"//#r \"nuget:System.Linq.Dynamic, 1.0.7\"\n",
|
||||
"#r \"C:/Users/darby/.nuget/packages/system.linq.dynamic.core/1.0.19/lib/netstandard2.0/System.Linq.Dynamic.Core.dll\"\n",
|
||||
"//#r \"nuget:MongoDB.Driver, 2.9.3\"\n",
|
||||
"#r \"C:/Users/darby/.nuget/packages/mongodb.driver/2.9.3/lib/netstandard1.5/MongoDB.Driver.dll\" \n",
|
||||
"#r \"C:/Users/darby/.nuget/packages/mongodb.driver.core/2.9.3/lib/netstandard1.5/MongoDB.Driver.Core.dll\"\n",
|
||||
"//#r \"nuget:MongoDB.Bson, 2.9.3\"\n",
|
||||
"#r \"C:/Users/darby/.nuget/packages/mongodb.bson/2.9.3/lib/netstandard1.5/MongoDB.Bson.dll\"\n",
|
||||
"//#r \"nuget:protobuf-net, 2.3.2.0\"\n",
|
||||
"#r \"C:/Users/darby/.nuget/packages/protobuf-net/2.3.2/lib/netstandard1.3/protobuf-net.dll\" "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"scrolled": true
|
||||
},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"metadata": {
|
||||
"scrolled": true
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Invalid: Command: #r c:/code/bts/spark/build/Debug/bin/netstandard2.0/spark_historical.dll"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"#r \"c:/code/bts/spark/build/Debug/bin/netstandard2.0/spark_historical.dll\" \n",
|
||||
"using bts.history;\n",
|
||||
"using MongoDB.Driver;\n",
|
||||
"using MongoDB.Driver.Linq;\n",
|
||||
"using Google.Protobuf.WellKnownTypes;\n",
|
||||
"using static bts.history.Query;\n",
|
||||
"using MathNet.Numerics.Statistics;\n",
|
||||
"using mbts.co2;\n",
|
||||
"\n",
|
||||
"bts.BTS.init();\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"metadata": {
|
||||
"scrolled": true
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"var q = new Query(\"CL_201911_W4\", \"bigblue\");"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"//var c1 = q.collection<HistoryRow>(\"HEZ9-HEG0\");\n",
|
||||
"//var c2 = q.collection<HistoryRow>(\"HEG0-HEV0\");\n",
|
||||
"//var c3 = q.collection<HistoryRow>(\"HEZ9-HEV0\");\n",
|
||||
"\n",
|
||||
"var s1 = \"CLZ9-CLF0\";\n",
|
||||
"var s2 = \"CLF0-CLG0\";\n",
|
||||
"var s3 = \"CLZ9-CLG0\";\n",
|
||||
"\n",
|
||||
"var c1 = q.collection<HistoryRow>(s1);\n",
|
||||
"var c2 = q.collection<HistoryRow>(s2);\n",
|
||||
"var c3 = q.collection<HistoryRow>(s3);\n",
|
||||
"\n",
|
||||
" "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"scrolled": true
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"var begin = DateTime.SpecifyKind(new DateTime(2019, 11, 25, 0, 0, 0), DateTimeKind.Utc);\n",
|
||||
"var end = DateTime.SpecifyKind(new DateTime(2019, 11, 25, 23, 59, 59), DateTimeKind.Utc);\n",
|
||||
"\n",
|
||||
"var c1t = await q.timeseries_cached<HistoryRow>(c1, begin, end);\n",
|
||||
"var c2t = await q.timeseries_cached<HistoryRow>(c2, begin, end);\n",
|
||||
"var c3t = await q.timeseries_cached<HistoryRow>(c3, begin, end);\n",
|
||||
"\n",
|
||||
"//await Task.WhenAll(new[] {z9t, h0t, spdt} );\n",
|
||||
"\n",
|
||||
"//local copy so we don't beat up the database\n",
|
||||
"var c1f = c1t.Where(x => x.Book != null && (x.Book.Bids.Count > 0 || x.Book.Asks.Count > 0));\n",
|
||||
"var c2f = c2t.Where(x => x.Book != null && (x.Book.Bids.Count > 0 || x.Book.Asks.Count > 0));\n",
|
||||
"var c3f = c3t.Where(x => x.Book != null && (x.Book.Bids.Count > 0 || x.Book.Asks.Count > 0));"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 22,
|
||||
"metadata": {
|
||||
"scrolled": true
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"35655"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"7706"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"1268"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"display(c1f.Count()); display(c2f.Count()); display(c3f.Count());"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 23,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"var c1top = c1f.AsEnumerable().Select(x => new GetTopOfBook(x)).OrderBy(x => x.sending_time);\n",
|
||||
"var c2top = c2f.AsEnumerable().Select(x => new GetTopOfBook(x)).OrderBy(x => x.sending_time);\n",
|
||||
"var c3top = c3f.AsEnumerable().Select(x => new GetTopOfBook(x)).OrderBy(x => x.sending_time);"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 24,
|
||||
"metadata": {
|
||||
"scrolled": true
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"var synth = create_synthetic_top( new []{c1top, c2top, c3top}, new[] {1.0, 1.0, -1.0}, new[] {1.0, 1.0, -1.0}, \n",
|
||||
" x => x.TopBook.Bid.price() > 0.0 || x.TopBook.Ask.price() < 0.0, \n",
|
||||
" (legs, synth)=> new TopDisplay<GetTopOfBook>(legs, synth));"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 25,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<table><thead><tr><th><i>index</i></th><th>seq_num</th><th>trade_date</th><th>sending_time</th><th>transact_time</th><th>bidsize</th><th>bid</th><th>ask</th><th>asksize</th><th>legbids</th><th>legasks</th></tr></thead><tbody><tr><td>0</td><td>5716175</td><td>2019-11-21</td><td>2019-11-21 14:46:53.991789</td><td>2019-11-21 14:46:53.991622</td><td>1</td><td>-475</td><td>-11000</td><td>0</td><td>5716153 1 -7275.00 |5715803 1 -4050.00 |5716175 0 0.00 |</td><td>5716153 3 -7250.00 |5715803 1 -3750.00 |5716175 2 -10850.00 |</td></tr><tr><td>1</td><td>5727722</td><td>2019-11-21</td><td>2019-11-21 14:47:41.431609</td><td>2019-11-21 14:47:41.431335</td><td>1</td><td>-500</td><td>-11100</td><td>0</td><td>5727697 4 -7425.00 |5726767 1 -4025.00 |5727722 0 0.00 |</td><td>5727697 3 -7350.00 |5726767 1 -3750.00 |5727722 2 -10950.00 |</td></tr><tr><td>2</td><td>5745097</td><td>2019-11-21</td><td>2019-11-21 14:49:07.039873</td><td>2019-11-21 14:49:07.038347</td><td>1</td><td>-525</td><td>-11375</td><td>0</td><td>5745095 1 -7375.00 |5745096 1 -4275.00 |5745097 0 0.00 |</td><td>5745095 2 -7350.00 |5745096 1 -4025.00 |5745097 2 -11125.00 |</td></tr><tr><td>3</td><td>5745119</td><td>2019-11-21</td><td>2019-11-21 14:49:07.040215</td><td>2019-11-21 14:49:07.038521</td><td>1</td><td>-550</td><td>-11375</td><td>0</td><td>5745119 3 -7400.00 |5745096 1 -4275.00 |5745097 0 0.00 |</td><td>5745119 2 -7350.00 |5745096 1 -4025.00 |5745097 2 -11125.00 |</td></tr><tr><td>4</td><td>5745119</td><td>2019-11-21</td><td>2019-11-21 14:49:07.040215</td><td>2019-11-21 14:49:07.038521</td><td>1</td><td>-550</td><td>-11375</td><td>0</td><td>5745119 3 -7400.00 |5745096 1 -4275.00 |5745097 0 0.00 |</td><td>5745119 2 -7350.00 |5745096 1 -4025.00 |5745097 2 -11125.00 |</td></tr><tr><td>5</td><td>5745124</td><td>2019-11-21</td><td>2019-11-21 14:49:07.040277</td><td>2019-11-21 14:49:07.038560</td><td>1</td><td>-550</td><td>-11375</td><td>0</td><td>5745119 3 -7400.00 |5745124 1 -4275.00 |5745097 0 0.00 |</td><td>5745119 2 -7350.00 |5745124 1 -4025.00 |5745097 2 -11125.00 |</td></tr><tr><td>6</td><td>5745124</td><td>2019-11-21</td><td>2019-11-21 14:49:07.040277</td><td>2019-11-21 14:49:07.038560</td><td>1</td><td>-550</td><td>-11375</td><td>0</td><td>5745119 3 -7400.00 |5745124 1 -4275.00 |5745097 0 0.00 |</td><td>5745119 2 -7350.00 |5745124 1 -4025.00 |5745097 2 -11125.00 |</td></tr><tr><td>7</td><td>5745157</td><td>2019-11-21</td><td>2019-11-21 14:49:07.040776</td><td>2019-11-21 14:49:07.039250</td><td>1</td><td>-550</td><td>-11375</td><td>0</td><td>5745157 3 -7400.00 |5745124 1 -4275.00 |5745097 0 0.00 |</td><td>5745157 1 -7350.00 |5745124 1 -4025.00 |5745097 2 -11125.00 |</td></tr><tr><td>8</td><td>5747196</td><td>2019-11-21</td><td>2019-11-21 14:49:12.635871</td><td>2019-11-21 14:49:12.632905</td><td>1</td><td>-600</td><td>-11425</td><td>0</td><td>5747194 4 -7375.00 |5747165 1 -4350.00 |5747196 0 0.00 |</td><td>5747194 1 -7325.00 |5747165 2 -4100.00 |5747196 2 -11125.00 |</td></tr><tr><td>9</td><td>5747199</td><td>2019-11-21</td><td>2019-11-21 14:49:12.635905</td><td>2019-11-21 14:49:12.632932</td><td>1</td><td>-250</td><td>-11425</td><td>0</td><td>5747194 4 -7375.00 |5747165 1 -4350.00 |5747199 0 0.00 |</td><td>5747194 1 -7325.00 |5747165 2 -4100.00 |5747199 2 -11475.00 |</td></tr><tr><td>10</td><td>5747203</td><td>2019-11-21</td><td>2019-11-21 14:49:12.635946</td><td>2019-11-21 14:49:12.632965</td><td>1</td><td>-250</td><td>-11425</td><td>0</td><td>5747194 4 -7375.00 |5747165 1 -4350.00 |5747203 0 0.00 |</td><td>5747194 1 -7325.00 |5747165 2 -4100.00 |5747203 2 -11475.00 |</td></tr><tr><td>11</td><td>5747266</td><td>2019-11-21</td><td>2019-11-21 14:49:12.636993</td><td>2019-11-21 14:49:12.633635</td><td>1</td><td>-250</td><td>-11425</td><td>0</td><td>5747194 4 -7375.00 |5747266 1 -4350.00 |5747203 0 0.00 |</td><td>5747194 1 -7325.00 |5747266 2 -4100.00 |5747203 2 -11475.00 |</td></tr><tr><td>12</td><td>5747266</td><td>2019-11-21</td><td>2019-11-21 14:49:12.636993</td><td>2019-11-21 14:49:12.633635</td><td>1</td><td>-250</td><td>-11425</td><td>0</td><td>5747194 4 -7375.00 |5747266 1 -4350.00 |5747203 0 0.00 |</td><td>5747194 1 -7325.00 |5747266 2 -4100.00 |5747203 2 -11475.00 |</td></tr><tr><td>13</td><td>5747274</td><td>2019-11-21</td><td>2019-11-21 14:49:12.637123</td><td>2019-11-21 14:49:12.633695</td><td>1</td><td>-250</td><td>-11475</td><td>0</td><td>5747194 4 -7375.00 |5747274 1 -4350.00 |5747203 0 0.00 |</td><td>5747194 1 -7325.00 |5747274 2 -4150.00 |5747203 2 -11475.00 |</td></tr><tr><td>14</td><td>5747274</td><td>2019-11-21</td><td>2019-11-21 14:49:12.637123</td><td>2019-11-21 14:49:12.633707</td><td>1</td><td>-250</td><td>-11475</td><td>0</td><td>5747194 4 -7375.00 |5747274 1 -4350.00 |5747203 0 0.00 |</td><td>5747194 1 -7325.00 |5747274 2 -4150.00 |5747203 2 -11475.00 |</td></tr><tr><td>15</td><td>5747295</td><td>2019-11-21</td><td>2019-11-21 14:49:12.637433</td><td>2019-11-21 14:49:12.633978</td><td>1</td><td>-250</td><td>-11475</tLine truncated
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"display(synth.OrderBy(x => x.sending_time));"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 10,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 11,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"scrolled": true
|
||||
},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 13,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 16,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"scrolled": true
|
||||
},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": ".NET (C#)",
|
||||
"language": "C#",
|
||||
"name": ".net-csharp"
|
||||
},
|
||||
"language_info": {
|
||||
"file_extension": ".cs",
|
||||
"mimetype": "text/x-csharp",
|
||||
"name": "C#",
|
||||
"pygments_lexer": "csharp",
|
||||
"version": "8.0"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 2
|
||||
}
|
||||
@@ -68,20 +68,6 @@ namespace bts.history
|
||||
x.TopBook.Ask.price().ToString("0.00 |")).ToArray();
|
||||
}
|
||||
|
||||
public class OrderOrFill
|
||||
{
|
||||
public OrderOrFill(OrderStatus ord)
|
||||
{
|
||||
this.order = ord;
|
||||
}
|
||||
public OrderOrFill(FillEntry fil)
|
||||
{
|
||||
this.fill = fil;
|
||||
}
|
||||
public OrderStatus order { get; }
|
||||
public FillEntry fill { get; }
|
||||
}
|
||||
|
||||
public class Display
|
||||
{
|
||||
OrderOrFill _res;
|
||||
@@ -123,8 +109,8 @@ namespace bts.history
|
||||
OrderOrFill _res;
|
||||
public FillDisplay(OrderOrFill res) { _res = res; }
|
||||
public FillDisplay(FillEntry res) { _res = new OrderOrFill(res); }
|
||||
public string our_fill_transact_time => _res.fill?.TransactTime.ToString();
|
||||
public string our_fill_sending_time => _res.fill?.SendingTime.ToString();
|
||||
public string our_fill_transact_time => _res.fill?.TransactTime.ToString();
|
||||
public ulong? order_id => _res.fill?.order.order_id;
|
||||
public string security_desc => _res.fill?.order.security_desc;
|
||||
public string our_fill_side => _res.fill?.side.ToString();
|
||||
@@ -136,6 +122,31 @@ namespace bts.history
|
||||
public double? best_bid => _res.fill?.bid;
|
||||
public double? best_ask => _res.fill?.ask;
|
||||
}
|
||||
public class MBODisplay
|
||||
{
|
||||
MBOMessage _res;
|
||||
public MBODisplay(MBOMessage res)
|
||||
{
|
||||
_res = res;
|
||||
}
|
||||
public string OrderUpdateAction => _res.OrderUpdateAction.ToString();
|
||||
public ulong OrderId => _res.OrderId;
|
||||
public string SecurityDesc => _res.SecurityDesc;
|
||||
public ulong MdOrderPriority => _res.MdOrderPriority;
|
||||
public double MdEntryPx => _res.MdEntryPx;
|
||||
public uint MdPriceLevel => _res.MdPriceLevel;
|
||||
public ulong MdDisplayQty => _res.MdDisplayQty;
|
||||
public uint LastQty => _res.LastQty;
|
||||
public string MdEntryType => _res.MdEntryType.ToString();
|
||||
public string TradeDate => _res.TradeDate.ToString();
|
||||
public uint MsgSeqNum => _res.MsgSeqNum;
|
||||
public string SendingTime => _res.SendingTime.ToString();
|
||||
public string TransactTime => _res.TransactTime.ToString();
|
||||
|
||||
public MDEntry MdEntry => _res.MdEntry;
|
||||
public OrderIDEntry OrderEntry => _res.OrderEntry;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public class Utils
|
||||
|
||||
Reference in new issue
Block a user