示例#1
0
 def test_parsed_subject(self):
     subject = Subject.parse_string(
         "AssetClass=Fx,Currency=GBP,Quantity=10000.00,Symbol=GBPJPY"
     )
     self.assertEqual(len(subject), 4)
     self.assertEqual(subject["AssetClass"], "Fx")
     self.assertEqual(subject["Symbol"], "GBPJPY")
示例#2
0
 def test_flatten(self):
     self.assertListEqual(
         [
             "AssetClass",
             "Fx",
             "Currency",
             "GBP",
             "Quantity",
             "10000.00",
             "Symbol",
             "GBPJPY",
         ],
         Subject.parse_string(
             "AssetClass=Fx,Currency=GBP,Quantity=10000.00,Symbol=GBPJPY"
         ).flatten(),
     )
示例#3
0
from unittest import TestCase

from bidfx import Subject
from bidfx.pricing import (
    PriceEvent,
    SubscriptionEvent,
    SubscriptionStatus,
    ProviderEvent,
    ProviderStatus,
)

PROVIDER = "Pixie-3"
SUBJECT = Subject.parse_string(
    "AssetClass=Fx,Currency=EUR,Quantity=10000.00,Symbol=EURUSD"
)
PRICE = {
    "AskSize": "1000000.0",
    "BidSize": "1000000.0",
    "Ask": "1.109271",
    "Bid": "1.107795",
}


class TestPriceEvent(TestCase):
    def test_get_subject(self):
        self.assertEqual(SUBJECT, PriceEvent(SUBJECT, PRICE, True).subject)

    def test_get_price(self):
        self.assertDictEqual(PRICE, PriceEvent(SUBJECT, PRICE, True).price)

    def test_get_price_is_true_when_there_are_fields(self):
示例#4
0
from unittest import TestCase

from bidfx import Subject
from bidfx.pricing._pixie.subscription_register import SubscriptionRegister

SUBJECT1 = Subject.parse_string("Source=A,Symbol=EURGBP")
SUBJECT2 = Subject.parse_string("Source=A,Symbol=GBPAUD")
SUBJECT3 = Subject.parse_string("Source=A,Symbol=GBPUSD")
SUBJECT4 = Subject.parse_string("Source=A,Symbol=GBPNZD")
SUBJECT5 = Subject.parse_string("Source=A,Symbol=USDCAD")


class TestCurrentSubscriptionSet(TestCase):
    def setUp(self):
        self.register = SubscriptionRegister()

    def test_zero_subscribe(self):
        self.assertEqual(None, self.register.subscription_sync(),
                         "No change to be synced")

    def test_single_subscribe(self):
        self.register.subscribe(SUBJECT1)
        self.assertListEqual([SUBJECT1],
                             self.register.subscription_sync().subjects)

    def test_sequence_of_subscribes(self):
        self.register.subscribe(SUBJECT1)
        self.register.subscribe(SUBJECT2)
        self.register.subscribe(SUBJECT3)
        self.assertListEqual([SUBJECT1, SUBJECT2, SUBJECT3],
                             self.register.subscription_sync().subjects)
示例#5
0
 def test_parsed_subject_to_string_gives_back_equivalent_string(self):
     s = "AssetClass=Fx,Currency=GBP,Quantity=10000.00,Symbol=GBPJPY"
     subject = Subject.parse_string(s)
     self.assertEqual(str(subject), s)
示例#6
0
 def test_subject_does_not_matches_different_subject(self):
     subject2 = Subject.parse_string(
         "AssetClass=Fx,Currency=GBP,Quantity=10000.00,Symbol=GBPJPY"
     )
     self.assertFalse(self.subject == subject2)
示例#7
0
 def test_subject_matches_subject_parsed_from_its_string(self):
     subject2 = Subject.parse_string(str(self.subject))
     self.assertTrue(self.subject == subject2)