Skip to content

Commit

Permalink
add strike price
Browse files Browse the repository at this point in the history
  • Loading branch information
uv-orbs committed Jul 31, 2022
1 parent 3e62f5a commit b4d4be2
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions drbt.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import re
import os
import json
import asyncio
import websockets
import json
import os
from collections.abc import MutableMapping
from datetime import datetime, timedelta
from influx import get_influx_client, get_influx_write_api
Expand All @@ -21,7 +22,7 @@
while strike < 50000:
chans.append(f'ticker.BTC-{expiry}-{strike}-C.100ms')
chans.append(f'ticker.BTC-{expiry}-{strike}-P.100ms')
strike += 500
strike += 1000

msgSub = \
{
Expand All @@ -48,12 +49,18 @@ def flatten_dict(d: MutableMapping, parent_key: str = '', sep: str = '.') -> Mut
def create_data_point(data):
p = get_influx_client().Point("options").tag("version", "dev1.1")
flat = flatten_dict(data)

for f in flat:
if isinstance(flat[f], str):
p = p.tag(f, flat[f])
elif type(flat[f]) == int or type(flat[f]) == float:
p = p.field(f, flat[f])

# add strike price
strike_price = re.search(
'.*?-.*?-(.*)-[CP]', flat['instrument_name']).group(1)
p = p.field('strike_price', int(strike_price))

return p


Expand Down

0 comments on commit b4d4be2

Please sign in to comment.