Capstone 2.1 2.2 and 2.3

I have the finished 2.1 , 2.2 and 2.3 as following:

2.1 In the optRef table, the expiry column is in a string format. Convert this into the kdb date format.

Help: See Casting

meta optRef
`optRef[`expiry]: "D"$optRef[`expiry]
//optRef

2.2 Create a function extractBrokerId

extractBrokerId:{[exMsg] parts: "-" vs exMsg;
exch: parts 0;
$[exch like "CME*"; brokerId:parts 2; brokerId:parts 1];
:"J"$brokerId
}
//show t1: extractBrokerId["CME-TSLA20200920C1700-709"]
//show t2: extractBrokerId["ISE-708-TSLA20200920C1700"]

2.3. Using the extractBrokerId function (or otherwise), update the messages table

//select broker_id: extractBrokerId each string each exch_message from messages
messages: select trade_id, exch_message, broker_id: extractBrokerId each string each exch_message from messages
//meta messages

but the testSection[`exercise2] shows:

quizItem success description error

exercise2.1 Fail "optRef Has Correct Format" ""
exercise2.2 Fail "instRef Has Correct Format" ""
exercise2.3 Fail "messages Has Correct Format" ""

1 Answer

1

Hi @yinzhihong12 ,

When I run your code above for 2.1 optRef I get an NYI error. I would recommend using an update statement for casting the type of the expiry column.

Your code for 2.2 looks fine, but for 2.3 you can use an update statement instead of selecting, and you don't need the each string in your statement.

Hope this helps! Let me know if you're still getting errors.

Laura

2.3 the main issue is 1.7 csv load message need be ("**",enlist csv) other than ("SS",enlist csv). and change the select to update as well. it works. thanks.