Skip to content

Commit

Permalink
misc fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminsingleton committed Oct 27, 2023
1 parent fe205ef commit da88189
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions examples/live/interactive_brokers/historic_download_ticks.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from nautilus_trader.config import LoggingConfig
from nautilus_trader.config import TradingNodeConfig
from nautilus_trader.live.node import TradingNode
from nautilus_trader.model.data import QuoteTick
from nautilus_trader.model.data import TradeTick


Expand All @@ -35,11 +36,16 @@
df = pd.DataFrame()


# Data Handler for BarDataDownloader
# Data Handler for TickDataDownloader
def do_something_with_ticks(ticks: list):
global df
bars_dict = [TradeTick.to_dict(tick) for tick in ticks]
df = pd.concat([df, pd.DataFrame(bars_dict)])
ticks_dict = [
TradeTick.to_dict(tick)
if tick.__class__.__name__ == "TradeTick"
else QuoteTick.to_dict(tick)
for tick in ticks
]
df = pd.concat([df, pd.DataFrame(ticks_dict)])
df = df.sort_values(by="ts_init")


Expand Down

0 comments on commit da88189

Please sign in to comment.