-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestWriteDataAndDeleteAuction.py
108 lines (90 loc) · 2.73 KB
/
TestWriteDataAndDeleteAuction.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
96
97
98
99
100
101
102
103
104
105
106
107
108
from datetime import datetime
import Artesian
from Artesian import Query
from dateutil import tz
from Artesian import MarketData
from Artesian.Granularity import Granularity
cfg = Artesian.ArtesianConfig("https://arkive.artesian.cloud/tenantName/", "APIKey")
mkdservice = Artesian.MarketData.MarketDataService(cfg)
auction = Artesian.MarketData.MarketDataEntityInput(
"PythonSDK",
"TestAuctionWriteAndDelete",
Granularity.Hour,
MarketData.MarketDataType.Auction,
"CET",
tags={"TestSDKPython": ["PythonValue2"]},
)
registered = mkdservice.readMarketDataRegistryByName(
auction.providerName, auction.marketDataName
)
if registered is None:
registered = mkdservice.registerMarketData(auction)
auctionRowData = {
datetime(2020, 1, 1, h): MarketData.AuctionBids(
datetime(2020, 1, 1),
bid=[
MarketData.AuctionBidValue(11.0, 12.0),
MarketData.AuctionBidValue(13.0, 14.0),
],
offer=[
MarketData.AuctionBidValue(21.0, 22.0),
MarketData.AuctionBidValue(23.0, 24.0),
],
)
for h in range(0, 23)
}
auctionRows = MarketData.UpsertData(
Artesian.MarketData.MarketDataIdentifier(
auction.providerName, auction.marketDataName
),
"UTC",
auctionRows=auctionRowData,
downloadedAt=datetime(2020, 1, 3).replace(tzinfo=tz.UTC),
)
mkdservice.upsertData(auctionRows)
query = Query.QueryService(cfg)
res = (
query.createAuction()
.forMarketData([registered.marketDataId])
.inAbsoluteDateRange("2020-01-01", "2020-01-02")
.inTimeZone("CET")
.execute()
)
print(res)
# Delete data between 2020-01-01 06:00 and 2020-01-01 18:00
deleteData = Artesian.MarketData.DeleteData(
ID=Artesian.MarketData.MarketDataIdentifier(
registered.providerName, registered.marketDataName
),
timezone="CET",
rangeStart=datetime(2020, 1, 1, 6),
rangeEnd=datetime(2020, 1, 1, 18),
)
mkdservice.deleteData(deleteData)
res = (
query.createAuction()
.forMarketData([registered.marketDataId])
.inAbsoluteDateRange("2020-01-01", "2020-01-02")
.inTimeZone("CET")
.execute()
)
print(res)
# Delete data between 2020-01-01 06:00 and 2020-01-01 18:00 without Timezone
deleteData = Artesian.MarketData.DeleteData(
ID=Artesian.MarketData.MarketDataIdentifier(
registered.providerName, registered.marketDataName
),
rangeStart=datetime(2020, 1, 1, 6),
rangeEnd=datetime(2020, 1, 1, 18),
)
mkdservice.deleteData(deleteData)
res = (
query.createAuction()
.forMarketData([registered.marketDataId])
.inAbsoluteDateRange("2020-01-01", "2020-01-02")
.inTimeZone("CET")
.execute()
)
print(res)
# Delete the curve completely
mkdservice.deleteMarketData(registered.marketDataId)