Skip to content

Commit

Permalink
add example of notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
molotgor committed Oct 16, 2024
1 parent e6be386 commit ee47e3a
Showing 1 changed file with 93 additions and 0 deletions.
93 changes: 93 additions & 0 deletions example/example.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"tags": [
"parameters"
]
},
"outputs": [],
"source": [
"output_path='output.jsonl'\n",
"lambda_pycode = \"\"\"lambda a:a['weight'] < 300\"\"\""
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0 5 50\n"
]
}
],
"source": [
"import json\n",
"import asyncio\n",
"import random\n",
"from datetime import datetime\n",
"amount = 100\n",
"\n",
"displayTable = [\n",
" ['bid order', 'bid rate', 'bid qty', 'ask order', 'ask rate', 'ask qty'],\n",
" ['424', '0.61500000', '101', '', '', ''],\n",
" ['424', '0.61500000', '101', '', '', ''],\n",
"]\n",
"\n",
"drift = 5\n",
"drift_range = [5, 10]\n",
"group = 50\n",
"group_range = [50, 100]\n",
"timestamp = 1725539650\n",
"amount = 200\n",
"pos = 0\n",
"conver = 1000000000\n",
"\n",
"testArr = []\n",
"\n",
"print(pos, drift, group)\n",
"while pos < amount:\n",
" timestamp_in_nano = timestamp*1000000000\n",
" weight = random.randrange(1, 1000)\n",
" timest_obj = datetime.fromtimestamp(timestamp)\n",
" testArr.append({ '#display-timestamp': timestamp_in_nano, '#display-name': str(pos) + ' ' + str(timest_obj), '#display-table': displayTable, 'weight': weight})\n",
" pos = pos + 1\n",
" timestamp += random.randrange(1, 100)\n",
"\n",
"filtered = list(filter(eval(lambda_pycode), testArr))\n",
"\n",
"with open(output_path, \"w\") as out_file:\n",
" for orig_order in filtered:\n",
" json.dump(orig_order, out_file)\n",
" out_file.write('\\n')"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.0"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

0 comments on commit ee47e3a

Please sign in to comment.