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
#loading model | |
loaded_model = NHiTSModel.load_from_checkpoint("old_checkpoint","/content/", best=True) | |
#defining new parameters | |
MODEL_NAME = "finetune_only" | |
from torch.optim import RAdam | |
OPTIMIZER_CLS = RAdam | |
BASE_LR = 0.00001 | |
EPOCHS = 25 |
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
import pandas as pd | |
import numpy as np | |
class DiffNormalizer(): | |
def __init__(self, diff_len=1): | |
self.diff_len = diff_len | |
self.fitted = False | |
self.first_values = None |
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
from orderbook import OrderBook | |
class ElectraOrderBook(OrderBook): | |
def get_executed_trades(self): | |
trades_list=[] | |
#... | |
# do some magic with self.idontknowwhat variables, put them into the trades_list... | |
#... | |
return trades_list |
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
from orderbook import OrderBook | |
contract_ids = [111,2222,3333,4444]#df...contractId.unique() | |
orderbooks={} | |
for contract_id in contract_ids: | |
orderbooks[contract_id]=OrderBook() |
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
Fltered by area and by contractid. | |
Unsorted is sorted only by created_at, "sorted" is sorted by revisionNo. | |
Unsorted: Sorted: | |
469 469 | |
470 470 | |
471 471 | |
472 472 | |
473 473 |
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
import pandas as pd | |
from sqlalchemy import create_engine | |
... | |
engine = create_engine('postgresql://'+user+':'+password+'@'+host+':'+port+'/'+dbname,echo=False) | |
df_orderbook = pd.read_sql_query('select * from "public_orderbook"',con=engine) |
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
my_dict={"key1":13,"key2":14} | |
assert type(my_dict) == type({}) | |
print(my_dict.keys()) | |
print(my_dict.values()) | |
print(my_dict.items()) | |
for i in my_dict.items(): | |
print(i) |
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
my_dict={"key1":(1,2,13141), "key2":(1,2,4354365462)} | |
for k,v in my_dict.items(): | |
tmp = my_dict[k] | |
tmp = (tmp[0],tmp[1],"owerwritten") | |
my_dict[k]=tmp | |
print(my_dict) | |
assert my_dict["key1"]==my_dict["key2"] |
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
# -*- coding: utf-8 -*- | |
import threading | |
import time | |
#import queue | |
#import logging | |
from unittest import TestCase | |
from HFTOrderbook.lob import LimitOrderBook, Order |
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
import _thread | |
import ...whatever the orderbook needs to be.. | |
def multi_order_sumit(thread_num): | |
print("This is thread",thread_num) | |
LOB = instance of an orderbook please () | |
for i in range(1000): | |
result = LOB.submit_order( some test cases with incermentally groving price or such...) #or whatever it is callled | |
return whatever we ecpect result to be |
NewerOlder