-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestBidAsk.py
95 lines (82 loc) · 2.96 KB
/
TestBidAsk.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
from Artesian import ArtesianConfig
from Artesian.Query import QueryService
from . import helpers
import unittest
cfg = ArtesianConfig("https://arkive.artesian.cloud/tenantName/", "APIKey")
qs = QueryService(cfg)
class TestBidAsk(unittest.TestCase):
@helpers.TrackRequests
def test_Null_Fill(self, requests):
url = (
qs.createBidAsk()
.forMarketData([100000001])
.forProducts(["M+1", "M+2"])
.inAbsoluteDateRange("2018-01-01", "2018-01-02")
.withFillNull()
.execute()
)
self.assertEqual(requests.getQs()["fillerK"], "Null")
@helpers.TrackRequests
def test_No_Fill(self, requests):
url = (
qs.createBidAsk()
.forMarketData([100000001])
.forProducts(["M+1", "M+2"])
.inAbsoluteDateRange("2018-01-01", "2018-01-02")
.withFillNone()
.execute()
)
self.assertEqual(requests.getQs()["fillerK"], "NoFill")
@helpers.TrackRequests
def test_Latest_Fill(self, requests):
url = (
qs.createBidAsk()
.forMarketData([100000001])
.forProducts(["M+1", "M+2"])
.inAbsoluteDateRange("2018-01-01", "2018-01-02")
.withFillLatestValue("P5D")
.execute()
)
query = requests.getQs()
self.assertEqual(query["fillerK"], "LatestValidValue")
self.assertEqual(query["fillerP"], "P5D")
self.assertEqual(query["fillerC"], "False")
@helpers.TrackRequests
def test_Latest_Fill_Continue(self, requests):
url = (
qs.createBidAsk()
.forMarketData([100000001])
.forProducts(["M+1", "M+2"])
.inAbsoluteDateRange("2018-01-01", "2018-01-02")
.withFillLatestValue("P5D", "True")
.execute()
)
query = requests.getQs()
self.assertEqual(query["fillerK"], "LatestValidValue")
self.assertEqual(query["fillerP"], "P5D")
self.assertEqual(query["fillerC"], "True")
@helpers.TrackRequests
def test_Custom_Value_Fill(self, requests):
url = (
qs.createBidAsk()
.forMarketData([100000001])
.forProducts(["M+1", "M+2"])
.inAbsoluteDateRange("2018-01-01", "2018-01-02")
.withFillCustomValue(
bestBidPrice=1,
bestAskPrice=2,
bestBidQuantity=3,
bestAskQuantity=4,
lastPrice=5,
lastQuantity=6,
)
.execute()
)
query = requests.getQs()
self.assertEqual(query["fillerK"], "CustomValue")
self.assertEqual(query["fillerDVbbp"], "1")
self.assertEqual(query["fillerDVbap"], "2")
self.assertEqual(query["fillerDVbbq"], "3")
self.assertEqual(query["fillerDVbaq"], "4")
self.assertEqual(query["fillerDVlp"], "5")
self.assertEqual(query["fillerDVlq"], "6")