-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
176 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 30 additions & 10 deletions
40
roboquant/journals/equitymetric.py → roboquant/journals/pnlmetric.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import os | ||
import time | ||
import unittest | ||
import roboquant as rq | ||
|
||
|
||
class TestBigFeed(unittest.TestCase): | ||
|
||
def test_bigfeed(self): | ||
start = time.time() | ||
path = os.path.expanduser("~/data/nyse_stocks/") | ||
feed = rq.feeds.CSVFeed.stooq_us_daily(path) | ||
loadtime = time.time() - start | ||
strategy = rq.strategies.EMACrossover(13, 26) | ||
journal = rq.journals.BasicJournal() | ||
start = time.time() | ||
account = rq.run(feed, strategy, journal=journal) | ||
runtime = time.time() - start | ||
|
||
self.assertTrue(journal.items > 1_000_000) | ||
self.assertTrue(journal.signals > 100_000) | ||
self.assertTrue(journal.orders > 10_000) | ||
self.assertTrue(journal.events > 10_000) | ||
|
||
print(account) | ||
print(journal) | ||
|
||
# Print statistics | ||
print() | ||
print(f"load time = {loadtime:.1f}s") | ||
print("files =", len(feed.symbols)) | ||
print(f"throughput = {len(feed.symbols) / loadtime:.0f} files/s") | ||
print(f"run time = {runtime:.1f}s") | ||
candles = journal.items | ||
print(f"candles = {(candles / 1_000_000):.1f}M") | ||
throughput = candles / (runtime * 1_000_000) | ||
print(f"throughput = {throughput:.1f}M candles/s") | ||
print() | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from cProfile import Profile | ||
import os | ||
from pstats import Stats, SortKey | ||
import roboquant as rq | ||
import unittest | ||
|
||
|
||
class TestProfile(unittest.TestCase): | ||
|
||
def test_profile(self): | ||
path = os.path.expanduser("~/data/nasdaq_stocks/1") | ||
feed = rq.feeds.CSVFeed.stooq_us_daily(path) | ||
print("timeframe =", feed.timeframe(), " symbols =", len(feed.symbols)) | ||
strategy = rq.strategies.EMACrossover(13, 26) | ||
journal = rq.journals.BasicJournal() | ||
|
||
# Profile the run to detect bottlenecks | ||
with Profile() as profile: | ||
rq.run(feed, strategy, journal=journal) | ||
print(f"\n{journal}") | ||
Stats(profile).sort_stats(SortKey.TIME).print_stats() | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import logging | ||
import time | ||
|
||
from roboquant import Timeframe | ||
from roboquant.feeds import EventChannel, TiingoLiveFeed, feedutil | ||
from statistics import mean, stdev | ||
import unittest | ||
|
||
|
||
class TestTiingoDelay(unittest.TestCase): | ||
|
||
def test_tiingodelay(self): | ||
""" | ||
Measure the average delay receiving prices from IEX using Tiingo. | ||
This includes the following paths: | ||
- From IEX to Tiingo (New York) | ||
- Tiingo holds it for 15ms (requirement from IEX) | ||
- From Tiingo to the modem/access-point in your house | ||
- From the access-point to your computer (f.e lan or Wi-Fi) | ||
""" | ||
|
||
logging.basicConfig(level=logging.INFO) | ||
|
||
feed = TiingoLiveFeed(market="iex") | ||
|
||
# subscribe to all IEX stocks for TOP of order book changes and Trades. | ||
feed.subscribe(threshold_level=5) | ||
|
||
timeframe = Timeframe.next(minutes=1) | ||
channel = EventChannel(timeframe, maxsize=10_000) | ||
feedutil.play_background(feed, channel) | ||
|
||
delays = [] | ||
while event := channel.get(): | ||
if event.items: | ||
delays.append(time.time() - event.time.timestamp()) | ||
|
||
if delays: | ||
t = ( | ||
f"mean={mean(delays):.3f} stdev={stdev(delays):.3f}" | ||
+ f"max={max(delays):.3f} min={min(delays):.3f} n={len(delays)}" | ||
) | ||
print(t) | ||
else: | ||
print("didn't receive any actions, is it perhaps outside trading hours?") | ||
|
||
feed.close() | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters