我有一个由外部软件生成的文件,我将其读入C#程序。 在streamreader重新检索文件后,我制作了几种方法来完成我需要的安排。像这样:
object[] array = new object[7];
// THE "WHILE" SPLIT MORE THAN 1 ORDERS FILLED
// INSERT FILL INFORMATION INTO ARRAY TO POPULATE TABLES
while (QtyFilled > 0)
{
for (int i = 0; i < fillData.Length; i++)
{
if (i == 4) // check the price
{
array[i] = Math.Round((double)fillData.GetValue(i), prodSpecs.DigitsAfterDecimal);
}
else
{
array[i] = fillData.GetValue(i);
}
array[5] = 1; // set the fill qty to 1 always
}
switch (BuySell)
{
case "B":
TradeSequenceOrientation += QtyFilled;
Table_Buy.Rows.Add(array);
// if (Table_Buy.Rows.Count <= 1) break;
DataView viewB = new DataView(Table_Buy);
viewB.Sort = "Contract ASC, DateExec ASC, TimeExec ASC";
Table_Buy = viewB.Table;
break;
case "S":
TradeSequenceOrientation -= QtyFilled;
Table_Sell.Rows.Add(array);
//if (Table_Sell.Rows.Count <= 1) break;
DataView viewS = new DataView(Table_Sell);
viewS = new DataView(Table_Sell);
viewS.Sort = "Contract ASC, DateExec ASC, TimeExec ASC";
Table_Sell = viewS.Table;
break;
}
MERGE_TABLES();
QtyFilled--;
}
这种方式非常好但可以优化。此外,我需要在建立导入后进行其他查询。
例如,我需要查询&#34;数量&#34;当&#34;购买&#34;时,价值不一样和&#34;出售&#34;已完成(参见&#34;复杂查询&#34;图片上)。例如,你想购买10个数量,并执行如此6,2,2。后来,销售一下子就出现了:10。
activity = 6 ;
activity =+ 2 ;
activity =+ 2 ;
activity =- 10 ;
activity == 0;
即使&#34;数量&#34;不同,买卖活动之间存在关系直到结束,直到活动为0。
因此决赛桌必须使这种特殊性看起来像&#34;复杂的查询&#34;照片上的窗口。
PICTURE OF GENERATED TABLES EXAMPLES
为了优化代码,我对LINQ查询感兴趣。我做了几次测试,但是无法得到理想的结果(如图所示)。我可以使用&#34;其中&#34;仅显示相关产品。通过利弊,我似乎无法合并类似于图片的线条。因为我从查询开始,我专注于简单过滤器的事实,但我发现自己很快被阻止,因为有很多数据,并且很难在购买和销售之间总是有相同的行数。
以下是代码:
var queryBuys = from rowbuy in TableBuys.buyTable.AsEnumerable()
where rowbuy.Field<string>("Product") == "CL"
select rowbuy;
var querySells = from rowsell in TableSells.sellTable.AsEnumerable()
where rowsell.Field<string>("Product") == "CL"
select rowsell;
Array arrBuy = null;
Array arrSell = null;
foreach (var item in queryBuys)
{
arrBuy = item.ItemArray.ToArray();
}
foreach (var item in querySells)
{
arrSell = item.ItemArray.ToArray();
}
//Array arrMerge = arrBuy
foreach (var item in arrBuy)
{
trackTable.Rows.Add(arrBuy, arrSell);
}
如果我能在流读取器之后直接完成工作的查询示例,那将会很棒。我的目标是让决赛桌看起来像是&#34;大B&amp; B组合。 C&#34;图片上的部分。
感谢您的帮助,
答案 0 :(得分:0)
Id Product B/S Qty Price Order Time Trans ID
1 FDAX B 1 9933 08:50:31:405 2818572289
2 FDAX B 1 9932 08:50:31:407 2818572290
3 FDAX B 1 9931 08:50:31:408 2818572291
4 FDAX B 1 9923 08:50:31:409 2818572292
5 FDAX B 1 9922 08:50:31:409 2818572293
6 FDAX B 1 9921 08:50:31:410 2818572294
7 FDAX S 1 9924 08:54:10:720 2818572295
8 FDAX B 1 9921 08:54:55:058 2818572296
9 FDAX S 1 9924 08:55:11:229 2818572297
10 FDAX S 1 9925 08:54:11:001 2818572298
11 FDAX S 1 9926 08:54:11:400 2818572299
12 FDAX S 1 9934 08:52:11:384 2818572300
13 FDAX S 1 9935 08:52:11:673 2818572301
14 FDAX S 1 9936 08:52:12:169 2818572302
15 FDAX B 1 9933 08:59:59:800 2818572303
16 FDAX B 1 9932 08:59:59:802 2818572304
17 FDAX B 1 9931 08:59:59:803 2818572305
18 FDAX B 1 9923 08:59:59:804 2818572306
19 FDAX B 1 9922 08:59:59:804 2818572307
20 FDAX B 1 9921 08:59:59:805 2818572308
21 FDAX B 1 9913 08:59:59:806 2818572309
22 FDAX B 1 9912 08:59:59:807 2818572310
23 FDAX B 1 9911 08:59:59:807 2818572311
24 FDAX S 1 9914 09:00:54:354 2818572312
25 FDAX S 1 9915 09:00:54:249 2818572313
26 FDAX B 1 9912 09:00:55:804 2818572314
27 FDAX B 1 9911 09:00:54:858 2818572315
28 FDAX S 1 9914 09:01:08:656 2818572316
29 FDAX S 1 9915 09:01:08:605 2818572317
30 FDAX S 1 9916 09:00:52:749 2818572318
31 FDAX B 1 9913 09:01:14:151 2818572319
32 FDAX S 1 9916 09:01:26:952 2818572320
33 FDAX S 1 9924 09:00:13:048 2818572321
34 FDAX S 1 9925 09:00:12:908 2818572322
35 FDAX S 1 9926 09:00:12:892 2818572323
36 FDAX B 1 9923 09:02:00:910 2818572324
37 FDAX B 1 9922 09:01:58:463 2818572325
38 FDAX B 1 9921 09:01:56:272 2818572326
39 FDAX S 1 9924 09:02:08:309 2818572327
40 FDAX S 1 9925 09:02:07:911 2818572328
41 FDAX S 1 9926 09:02:07:260 2818572329
42 FDAX B 1 9923 09:02:20:215 2818572330
43 FDAX B 1 9922 09:02:19:709 2818572331
44 FDAX B 1 9921 09:02:19:248 2818572332
45 FDAX B 1 9913 09:01:32:103 2818572333
46 FDAX B 1 9912 09:01:12:646 2818572334
47 FDAX B 1 9911 09:01:11:437 2818572335
48 FDAX S 1 9914 09:03:16:865 2818572336
49 FDAX S 1 9915 09:03:07:814 2818572337
50 FDAX S 1 9916 09:03:07:262 2818572338
51 FDAX S 1 9924 09:02:27:563 2818572339
52 FDAX B 1 9921 09:04:07:069 2818572340
53 FDAX B 1 9913 09:04:04:916 2818572341
54 FDAX B 1 9912 09:04:04:771 2818572342
55 FDAX B 1 9911 09:03:55:669 2818572343
56 FDAX B 1 9903 08:59:59:808 2818572344
57 FDAX B 1 9902 08:59:59:810 2818572345
58 FDAX B 1 9901 08:59:59:811 2818572346
59 FDAX S 1 9904 09:05:06:345 2818572347
60 FDAX S 1 9905 09:05:06:329 2818572348
61 FDAX S 1 9906 09:05:00:128 2818572349
62 FDAX B 1 9903 09:05:24:026 2818572350
63 FDAX B 1 9902 09:05:21:176 2818572351
64 FDAX B 1 9901 09:05:20:854 2818572352
65 FDAX S 1 9897 09:05:54:177 2818572353
66 FDAX S 1 9898 09:05:54:179 2818572354
67 FDAX S 1 9899 09:05:54:180 2818572355
68 FDAX S 1 9904 09:05:34:107 2818572356
69 FDAX S 1 9905 09:05:28:125 2818572357
70 FDAX S 1 9906 09:05:26:208 2818572358
71 FDAX S 1 9907 09:05:54:181 2818572359
72 FDAX S 1 9908 09:05:54:182 2818572360
73 FDAX S 1 9909 09:05:54:183 2818572361
74 FDAX S 1 9914 09:04:25:325 2818572362
75 FDAX S 1 9915 09:04:25:009 2818572363
76 FDAX S 1 9916 09:04:23:920 2818572364
77 FDAX S 1 9917 09:05:54:185 2818572365
78 FDAX S 1 9918 09:05:54:189 2818572366
79 FDAX B 1 9915 09:06:34:083 2818572367
80 FDAX B 1 9914 09:06:33:534 2818572368
81 FDAX B 1 9913 09:06:32:411 2818572369
82 FDAX B 1 9912 09:06:31:571 2818572370
83 FDAX B 1 9911 09:06:30:766 2818572371
84 FDAX S 1 9914 09:06:42:377 2818572372
85 FDAX S 1 9915 09:06:41:334 2818572373
86 FDAX S 1 9916 09:06:38:232 2818572374
87 FDAX S 1 9917 09:06:37:932 2818572375
88 FDAX S 1 9918 09:06:36:162 2818572376
89 FDAX S 1 9919 09:05:54:190 2818572377
90 FDAX S 1 9924 09:04:10:035 2818572378
91 FDAX B 1 9923 09:07:56:075 2818572379
92 FDAX B 1 9922 09:07:56:088 2818572380
93 FDAX B 1 9921 09:07:55:233 2818572381
94 FDAX B 1 9916 09:07:40:520 2818572382
95 FDAX B 1 9915 09:07:39:634 2818572383
96 FDAX B 1 9914 09:07:34:815 2818572384
97 FDAX B 1 9913 09:07:34:017 2818572385
98 FDAX B 1 9912 09:07:32:416 2818572386
99 FDAX B 1 9911 09:06:45:284 2818572387
100 FDAX B 1 9906 09:06:24:879 2818572388
101 FDAX B 1 9905 09:06:24:789 2818572389
102 FDAX B 1 9904 09:06:24:722 2818572390
103 FDAX S 1 9907 09:08:35:328 2818572391
104 FDAX S 1 9908 09:08:34:286 2818572392
105 FDAX S 1 9909 09:08:34:097 2818572393
106 FDAX S 1 9914 09:08:16:172 2818572394
107 FDAX S 1 9915 09:08:15:826 2818572395
108 FDAX S 1 9916 09:08:15:219 2818572396
109 FDAX S 1 9917 09:08:14:824 2818572397
110 FDAX S 1 9918 09:08:12:475 2818572398
111 FDAX S 1 9919 09:08:12:191 2818572399
112 FDAX B 1 9916 09:09:47:646 2818572400
113 FDAX B 1 9915 09:09:45:932 2818572401
114 FDAX S 1 9918 09:09:59:109 2818572402
115 FDAX S 1 9919 09:09:58:345 2818572403
116 FDAX S 1 9924 09:08:06:197 2818572404
117 FDAX S 1 9925 09:02:24:615 2818572405
118 FDAX S 1 9926 09:02:22:114 2818572406
119 FDAX S 1 9927 09:05:54:191 2818572407
120 FDAX S 1 9928 09:05:54:192 2818572408
121 FDAX S 1 9929 09:05:54:192 2818572409
122 FDAX B 1 9926 09:10:41:350 2818572410
123 FDAX B 1 9925 09:10:39:783 2818572411
124 FDAX B 1 9924 09:10:35:048 2818572412
125 FDAX S 1 9927 09:11:09:134 2818572413
126 FDAX S 1 9928 09:11:00:210 2818572414
127 FDAX S 1 9929 09:10:59:733 2818572415
128 FDAX S 1 9934 09:00:02:291 2818572416
129 FDAX S 1 9935 09:00:02:099 2818572417
130 FDAX S 1 9936 09:00:01:647 2818572418
131 FDAX B 1 9933 09:11:55:096 2818572419
132 FDAX B 1 9933 09:11:55:141 2818572419
133 FDAX B 1 9932 09:11:55:092 2818572420
134 FDAX B 1 9931 09:11:54:797 2818572421
135 FDAX S 1 9934 09:13:08:747 2818572422
136 FDAX S 1 9935 09:13:07:692 2818572423
137 FDAX S 1 9936 09:13:05:151 2818572424
138 FDAX B 1 9933 09:13:20:091 2818572425
139 FDAX B 1 9932 09:13:12:943 2818572426
140 FDAX B 1 9931 09:13:12:761 2818572427
141 FDAX S 1 9934 09:13:28:213 2818572428
142 FDAX S 1 9935 09:13:27:910 2818572429
143 FDAX S 1 9936 09:13:05:155 2818572430
144 FDAX S 1 9936 09:13:24:895 2818572431
145 FDAX B 1 9933 09:14:52:499 2818572432
146 FDAX B 1 9933 09:14:52:557 2818572433
147 FDAX B 1 9932 09:14:51:856 2818572434
148 FDAX B 1 9931 09:14:51:772 2818572435
149 FDAX S 1 9934 09:15:07:276 2818572436
150 FDAX B 1 9931 09:15:55:273 2818572437
151 FDAX S 1 9934 09:16:01:129 2818572438
152 FDAX S 1 9935 09:15:07:200 2818572439
153 FDAX S 1 9936 09:15:05:999 2818572440
154 FDAX S 1 9936 09:15:07:099 2818572441
155 FDAX B 1 9933 09:16:14:777 2818572442
156 FDAX B 1 9933 09:16:15:071 2818572442
157 FDAX B 1 9932 09:16:13:655 2818572443
158 FDAX B 1 9931 09:16:13:555 2818572444
159 FDAX B 1 9926 09:11:23:599 2818572445
160 FDAX B 1 9925 09:11:21:360 2818572446
161 FDAX B 1 9924 09:11:15:430 2818572447
162 FDAX S 1 9927 09:18:04:286 2818572448
163 FDAX S 1 9928 09:18:02:434 2818572449
164 FDAX B 1 9925 09:18:18:535 2818572450
165 FDAX S 1 9928 09:18:27:235 2818572451
166 FDAX B 1 9925 09:18:36:124 2818572452
167 FDAX B 1 9924 09:18:10:516 2818572453
168 FDAX B 1 9923 09:10:30:634 2818572454
169 FDAX S 1 9926 09:18:42:283 2818572455
170 FDAX S 1 9927 09:18:42:120 2818572456
171 FDAX S 1 9928 09:18:41:328 2818572457
172 FDAX S 1 9929 09:18:01:430 2818572458
173 FDAX S 1 9934 09:17:07:233 2818572459
174 FDAX S 1 9935 09:17:06:658 2818572460
175 FDAX S 1 9936 09:17:05:276 2818572461
176 FDAX S 1 9936 09:17:05:273 2818572462
177 FDAX B 1 9933 09:18:53:729 2818572463
178 FDAX B 1 9933 09:18:55:020 2818572464
179 FDAX B 1 9932 09:18:53:186 2818572465
180 FDAX B 1 9931 09:18:53:019 2818572466
181 FDAX S 1 9934 09:24:42:206 2818572467
182 FDAX B 1 9931 09:25:04:308 2818572468
183 FDAX S 1 9934 09:25:10:501 2818572469
184 FDAX B 1 9931 09:25:22:221 2818572470
185 FDAX B 1 9926 09:18:52:391 2818572471
186 FDAX B 1 9925 09:18:52:389 2818572472
187 FDAX B 1 9924 09:18:52:229 2818572473
188 FDAX B 1 9923 09:18:51:117 2818572474
189 FDAX B 1 9922 09:10:30:630 2818572475
190 FDAX B 1 9921 09:10:29:341 2818572476
191 FDAX S 1 9987 09:47:50:537 2818572477
192 FDAX S 1 9988 09:47:50:538 2818572478
193 FDAX B 1 9985 09:47:52:796 2818572479
194 FDAX B 1 9984 09:47:50:983 2818572480
195 FDAX B 1 10103 10:38:26:987 2818572481
196 FDAX B 1 10102 10:38:26:988 2818572482
197 FDAX B 1 10101 10:38:26:989 2818572483
198 FDAX S 1 10104 10:38:29:657 2818572484
199 FDAX S 1 10105 10:38:27:226 2818572485
200 FDAX B 1 10102 10:38:35:672 2818572486
201 FDAX B 1 10101 10:38:35:031 2818572487
202 FDAX S 1 10104 10:38:42:319 2818572488
203 FDAX B 1 10101 10:39:45:325 2818572489
204 FDAX S 1 10104 10:39:50:441 2818572490
205 FDAX S 1 10105 10:38:39:128 2818572491
206 FDAX S 1 10106 10:38:27:143 2818572492
207 FDAX B 1 10123 10:40:05:641 2818572493
208 FDAX B 1 10122 10:40:05:645 2818572494
209 FDAX B 1 10121 10:40:05:646 2818572495
210 FDAX S 1 10124 10:40:05:983 2818572496
211 FDAX S 1 10125 10:40:05:862 2818572497
212 FDAX S 1 10126 10:40:05:751 2818572498
213 FDAX S 1 10097 10:54:09:339 2818572499
214 FDAX S 1 10098 10:54:09:339 2818572500
215 FDAX S 1 10099 10:54:09:340 2818572501
216 FDAX B 1 10103 11:00:32:571 2818572502
217 FDAX B 1 10102 11:00:32:574 2818572503
218 FDAX B 1 10101 11:00:32:575 2818572504
219 FDAX B 1 10096 11:00:05:366 2818572505
220 FDAX B 1 10095 11:00:04:186 2818572506
221 FDAX B 1 10094 11:00:04:125 2818572507
222 FDAX B 1 10093 11:00:32:577 2818572508
223 FDAX S 1 10096 11:01:28:144 2818572509
224 FDAX S 1 10097 11:01:19:041 2818572510
225 FDAX S 1 10098 11:01:11:180 2818572511
226 FDAX S 1 10099 11:01:10:373 2818572512
227 FDAX B 1 10096 11:01:53:906 2818572513
228 FDAX B 1 10095 11:01:52:809 2818572514
229 FDAX S 1 10098 11:02:02:999 2818572515
230 FDAX S 1 10099 11:01:58:898 2818572516
231 FDAX S 1 10104 11:01:01:833 2818572517
232 FDAX S 1 10105 11:00:52:336 2818572518
233 FDAX S 1 10106 11:00:52:174 2818572519
234 FDAX S 1 10107 10:54:09:341 2818572520
235 FDAX S 1 10108 10:54:09:342 2818572521
236 FDAX S 1 10109 10:54:09:344 2818572522
237 FDAX B 1 10106 11:03:17:905 2818572523
238 FDAX S 1 10109 11:05:18:444 2818572524
239 FDAX B 1 10106 11:05:28:347 2818572525
240 FDAX B 1 10105 11:03:08:102 2818572526
241 FDAX B 1 10104 11:03:04:449 2818572527
242 FDAX B 1 10103 11:02:49:001 2818572528
243 FDAX B 1 10103 11:02:57:435 2818572529
244 FDAX B 1 10102 11:02:48:992 2818572530
245 FDAX B 1 10101 11:02:48:951 2818572531
246 FDAX S 1 10100.5 11:07:15:254 2818572532
247 FDAX S 1 10097 11:15:56:429 2818572533
248 FDAX S 1 10098 11:15:56:431 2818572534
249 FDAX B 1 10095 11:16:58:076 2818572535
250 FDAX B 1 10094 11:16:16:236 2818572536
251 FDAX S 1 10097 11:17:11:586 2818572537
252 FDAX B 1 10094 11:17:32:123 2818572538
253 FDAX S 1 10077 11:20:49:336 2818572539
254 FDAX S 1 10078 11:20:49:338 2818572540
255 FDAX B 1 10075 11:20:51:940 2818572541
256 FDAX B 1 10074 11:20:51:046 2818572542
257 FDAX S 1 10077 11:20:56:003 2818572543
258 FDAX S 1 10078 11:20:54:987 2818572544
259 FDAX B 1 10075 11:22:04:341 2818572545
260 FDAX B 1 10074 11:21:38:046 2818572546
261 FDAX S 1 10077 11:23:40:165 2818572547
262 FDAX S 1 10078 11:23:28:766 2818572548
263 FDAX S 1 10079 11:20:49:339 2818572549
264 FDAX B 1 10076 11:25:50:570 2818572550
265 FDAX B 1 10075 11:24:29:670 2818572551
266 FDAX B 1 10074 11:24:27:567 2818572552
267 FDAX S 1 10077 11:26:15:631 2818572553
268 FDAX B 1 10074 11:28:03:728 2818572554
269 FDAX S 1 10077 11:28:26:637 2818572555
270 FDAX S 1 10078 11:26:04:917 2818572556
271 FDAX B 1 10075 11:28:33:779 2818572557
272 FDAX S 1 10078 11:28:38:372 2818572558
273 FDAX S 1 10079 11:26:04:272 2818572559
274 FDAX B 1 10076 11:29:24:189 2818572560
275 FDAX B 1 10075 11:28:51:038 2818572561
299 CL B 1 4133 13:44:25:408 2818572585
300 CL B 1 4132 13:44:25:466 2818572586
301 CL B 1 4131 13:44:25:468 2818572587
302 CL S 1 4134 13:45:12:120 2818572588
303 CL S 1 4135 13:45:06:315 2818572589
304 CL S 1 4136 13:44:37:648 2818572590
305 CL B 1 4133 13:49:10:858 2818572591
306 CL S 1 4136 13:49:21:997 2818572592
307 CL B 1 4133 14:15:35:825 2818572593
308 CL B 1 4132 14:15:35:827 2818572594
309 CL B 1 4131 14:15:35:828 2818572595
310 CL B 1 4123 14:15:35:830 2818572596
311 CL B 1 4122 14:15:35:834 2818572597
312 CL S 1 4125 14:17:02:631 2818572598
313 CL S 1 4126 14:16:54:376 2818572599
314 CL S 1 4134 14:16:53:651 2818572600
315 CL S 1 4135 14:16:53:641 2818572601
316 CL S 1 4131 14:17:40:481 2818572602