예제 #1
0
 def getQuote(tradingSymbol, isFnO=False):
     broker = Controller.getBrokerName()
     brokerHandle = Controller.getBrokerLogin().getBrokerHandle()
     quote = None
     if broker == "zerodha":
         key = ('NFO:' +
                tradingSymbol) if isFnO == True else ('NSE:' +
                                                      tradingSymbol)
         bQuoteResp = brokerHandle.quote(key)
         bQuote = bQuoteResp[key]
         # convert broker quote to our system quote
         quote = Quote(tradingSymbol)
         quote.tradingSymbol = tradingSymbol
         quote.lastTradedPrice = bQuote['last_price']
         quote.lastTradedQuantity = bQuote['last_quantity']
         quote.avgTradedPrice = bQuote['average_price']
         quote.volume = bQuote['volume']
         quote.totalBuyQuantity = bQuote['buy_quantity']
         quote.totalSellQuantity = bQuote['sell_quantity']
         ohlc = bQuote['ohlc']
         quote.open = ohlc['open']
         quote.high = ohlc['high']
         quote.low = ohlc['low']
         quote.close = ohlc['close']
         quote.change = bQuote['net_change']
         quote.oiDayHigh = bQuote['oi_day_high']
         quote.oiDayLow = bQuote['oi_day_low']
         quote.lowerCiruitLimit = bQuote['lower_circuit_limit']
         quote.upperCircuitLimit = bQuote['upper_circuit_limit']
     else:
         # The logic may be different for other brokers
         quote = None
     return quote
예제 #2
0
 def test010_save(self):
     self.assertEqual(Quote(10000, 'brexbottest', 1000, 'Test Quote', 'Test Viewer').exists(), None)
     Quote(10000, 'brexbottest', 1000, 'Test Quote', 'Test Viewer').save()
     self.assertEqual(Quote(10000, 'brexbottest', 1000, 'Test Quote', 'Test Viewer').exists(), True)
예제 #3
0
 def test030_load(self):
     quote = Quote(10000, 'brexbottest', 1000, 'Test Quote', 'Test Viewer').load()
     self.assertIsNotNone(quote)
예제 #4
0
 def test040_delete(self):
     quote = Quote(10000, 'brexbottest', 1000, 'Test Quote', 'Test Viewer').load()
     self.assertIsNotNone(quote)
     quote.delete()
     exist_check = quote.exists()
     self.assertEqual(exist_check, None)
예제 #5
0
 def test020_exists(self):
     quote = Quote(10000, 'brexbottest', 1000, 'Test Quote', 'Test Viewer').load()
     exist_check = quote.exists()
     self.assertEqual(exist_check, True)