# Fundamentals Capstone 5.2

**URL:** <https://forum.kx.com/t/fundamentals-capstone-5-2/13058>\
**Category:** Community Support\
**Tags:** kx-academy\
**Created:** [October 31, 2023, 3:46pm UTC](https://forum.kx.com/t/fundamentals-capstone-5-2/13058 "2023-10-31T15:46:00Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![danritch1](https://avatars.discourse-cdn.com/v4/letter/d/9e8a1a/32.png) [@danritch1](https://forum.kx.com/u/danritch1)\
**Post date:** [October 31, 2023, 3:46pm UTC](https://forum.kx.com/t/fundamentals-capstone-5-2/13058/1 "2023-10-31T15:46:00Z")

</div>

I cant seem to fix the type error on the 2nd part of question 5 my code looks like this,

&nbsp;

avgtrdata : select avgEdge by option\_id from optProfile

select edge,avg avgEdge by option\_id from latesttrds ij avgtrdata where edge \> avgEdge

&nbsp;

I gave up with the fby for now as I was getting the same type errors but it seems when I am using the “by” command in SQL the data type changes from 32 to 64 bit or lowercase to uppercase on the meta of the table and this means that it is no longer comparable with the \> symbol.

Any help would be appreciated thanks,

Dan

---

<div class="post-metadata">

**Author:** ![danritch1](https://avatars.discourse-cdn.com/v4/letter/d/9e8a1a/32.png) [@danritch1](https://forum.kx.com/u/danritch1)\
**Post date:** [October 31, 2023, 4:08pm UTC](https://forum.kx.com/t/fundamentals-capstone-5-2/13058/2 "2023-10-31T16:08:00Z")

</div>

UPDATE:

I now have this which works,

edgeProfile: select numTrds:count i, avgEdge: avg edge, minQty:min qty, maxQty:max qty by option\_id from latesttrds where edge \<(avg;edge) fby option\_id

However it fails the test… any help would be great my output table looks like this,

?

---

<div class="post-metadata">

**Author:** ![megan\_mcp1](https://avatars.discourse-cdn.com/v4/letter/m/ea5d25/32.png) [@megan\_mcp1](https://forum.kx.com/u/megan_mcp1)\
**Post date:** [October 31, 2023, 4:17pm UTC](https://forum.kx.com/t/fundamentals-capstone-5-2/13058/3 "2023-10-31T16:17:00Z")

</div>

Hi&nbsp;,

Can you send the code for the table _latesttrds_ please?

Thanks,

Megan

---

<div class="post-metadata">

**Author:** ![danritch1](https://avatars.discourse-cdn.com/v4/letter/d/9e8a1a/32.png) [@danritch1](https://forum.kx.com/u/danritch1)\
**Post date:** [October 31, 2023, 4:25pm UTC](https://forum.kx.com/t/fundamentals-capstone-5-2/13058/4 "2023-10-31T16:25:00Z")

</div>

Thanks for the reply,

latesttrds: select from trade where date = 2020.08.06

was just a way of selecting only the last day and not having to worry about it.

thanks,

Dan

---

<div class="post-metadata">

**Author:** ![megan\_mcp1](https://avatars.discourse-cdn.com/v4/letter/m/ea5d25/32.png) [@megan\_mcp1](https://forum.kx.com/u/megan_mcp1)\
**Post date:** [October 31, 2023, 4:37pm UTC](https://forum.kx.com/t/fundamentals-capstone-5-2/13058/5 "2023-10-31T16:37:00Z")

</div>

Hi&nbsp;,

As you can see in the screenshot provided below the question asks to&nbsp;include trades where the edge collected was **greater** than the average edge collected by that option.

If you adjust this, it should work fine.

Thanks,

Megan

---

<div class="post-metadata">

**Author:** ![danritch1](https://avatars.discourse-cdn.com/v4/letter/d/9e8a1a/32.png) [@danritch1](https://forum.kx.com/u/danritch1)\
**Post date:** [October 31, 2023, 4:48pm UTC](https://forum.kx.com/t/fundamentals-capstone-5-2/13058/6 "2023-10-31T16:48:00Z")

</div>

Amazing, I apologise that was a silly error however on a very similar note, I thought that would fix the fail for the values on 5.3, unfortunately, it hasn’t.

My code looks like this,

optinstRef: optRef ij select by inst\_id from instRef

edgeProfileFull: select numTrds, avgEdge, minQty, maxQty, inst\_id, opt\_type, strike, expiry, inst\_syb, inst\_name by option\_id from edgeProfile ij select by option\_id from optinstRef

and my table top row matches the one printed in the work book,

Any final help would be amazing on this,

Thanks Dan?

---

<div class="post-metadata">

**Author:** ![danritch1](https://avatars.discourse-cdn.com/v4/letter/d/9e8a1a/32.png) [@danritch1](https://forum.kx.com/u/danritch1)\
**Post date:** [October 31, 2023, 5:37pm UTC](https://forum.kx.com/t/fundamentals-capstone-5-2/13058/7 "2023-10-31T17:37:00Z")

</div>

For further reference&nbsp;this is the data types in the table,

&nbsp;

---

<div class="post-metadata">

**Author:** ![megan\_mcp1](https://avatars.discourse-cdn.com/v4/letter/m/ea5d25/32.png) [@megan\_mcp1](https://forum.kx.com/u/megan_mcp1)\
**Post date:** [October 31, 2023, 5:37pm UTC](https://forum.kx.com/t/fundamentals-capstone-5-2/13058/8 "2023-10-31T17:37:00Z")

</div>

Can I ask you to send the fail message you are getting? I’ve ran your code and it seems to work fine.

Thanks,

Megan

---

<div class="post-metadata">

**Author:** ![danritch1](https://avatars.discourse-cdn.com/v4/letter/d/9e8a1a/32.png) [@danritch1](https://forum.kx.com/u/danritch1)\
**Post date:** [October 31, 2023, 6:14pm UTC](https://forum.kx.com/t/fundamentals-capstone-5-2/13058/9 "2023-10-31T18:14:00Z")

</div>

Thanks for the reply there is actually no message it just says it has failed and I cant submit.

&nbsp;

Thanks,

Dan

---

<div class="post-metadata">

**Author:** ![danritch1](https://avatars.discourse-cdn.com/v4/letter/d/9e8a1a/32.png) [@danritch1](https://forum.kx.com/u/danritch1)\
**Post date:** [November 1, 2023, 10:16am UTC](https://forum.kx.com/t/fundamentals-capstone-5-2/13058/10 "2023-11-01T10:16:00Z")

</div>

Just to add i restarted everything and reran it but it seems to still fail without an error message,

---

<div class="post-metadata">

**Author:** ![megan\_mcp1](https://avatars.discourse-cdn.com/v4/letter/m/ea5d25/32.png) [@megan\_mcp1](https://forum.kx.com/u/megan_mcp1)\
**Post date:** [November 1, 2023, 11:35am UTC](https://forum.kx.com/t/fundamentals-capstone-5-2/13058/11 "2023-11-01T11:35:00Z")

</div>

Hi&nbsp;,

Sorry for the delay in this response, the majority of the columns in your edgeProfileFull table are in the wrong format and I feel this has something to do with your code leading up to creating this table.

Can I ask you to download your notebook and send it to me at mmcparland@kx.com&nbsp;so I can have a better look?&nbsp;

Thanks,

Megan&nbsp;
