Delete Trades

The endpoint deletes trades for the instrument.

The deleted trades are not physically removed from the database until a corresponding administrative action is performed against the atsd_trade table.

Request

Method Path
POST /api/v1/trades/delete

Payload

Field Name Description
symbol [Required] Symbol.
class [Required] Class.
exchange [Required] Exchange.
startDate [Required] Start date in ISO format.
endDate [Required] End date in ISO format. endDate is inclusive.
multipleInstruments Omit the symbol parameter and add multipleInstruments set to true to delete trades for all instruments within the class.
{
  "symbol": "<symbol>",
  "class": "<class-name>",
  "exchange": "<exchange>",
  "startDate": "<start date in ISO format>",
  "endDate": "<end date in ISO format>"
}

To delete trades for all instruments within the class.

{
  "class": "<class-name>",
  "multipleInstruments": "true",
  "exchange": "<exchange>",
  "startDate": "<start date in ISO format>",
  "endDate":   "<end date in ISO format>"
}

Logging

Deleted trades are logged in deleted_trades.log file using the format:

<delete timestamp>;<hour timestamp>;<Instrument specification>
trade_command
trade_command
...
2021-01-17T12:23:53.312Z;2020-12-12T11:00:00Z;Instrument(id=32, symbol=TSLA, class=IEXG, exchange=IEX)
3406495814,1607773266798,435,IEXG,TSLA,IEX,S,1,199,293,N
3406495817,1607773286767,32,IEXG,TSLA,IEX,B,1,202.8,282,N

Example

Request

curl

curl --insecure --request POST 'https://atsd_hostname:8443/api/v1/trades/delete' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data-raw '{
  "class":    "IEXG",
  "symbol":   "TSLA",
  "exchange": "IEX",
  "startDate": "2020-12-12T00:00:00.000+03:00",
  "endDate":   "2020-12-12T59:59:59.999+03:00"
}'

Physical_deletion

Disable tombstone protection.

echo "alter 'atsd_trade', NAME => 'd', KEEP_DELETED_CELLS => false" | /opt/atsd/hbase/bin/hbase shell

Initiate major compaction.

echo "major_compact 'atsd_trade'" | /opt/atsd/hbase/bin/hbase shell

Wait until major compaction is completed. Watch for Completed major compaction message.

tail -n 100 -F /opt/atsd/hbase/logs/* | grep atsd_trade

Re-enable tombstone protection.

echo "alter 'atsd_trade', NAME => 'd', KEEP_DELETED_CELLS => true" | /opt/atsd/hbase/bin/hbase shell

Verify that protection is enabled: KEEP_DELETED_CELLS => 'TRUE'

echo "describe 'atsd_trade'" | /opt/atsd/hbase/bin/hbase shell