NexusFi: Find Your Edge


Home Menu

 





Custom database with custom tickers. Is it possible ?


Discussion in Platforms and Indicators

Updated
      Top Posters
    1. looks_one enjoyaol with 2 posts (0 thanks)
    2. looks_two iildm with 1 posts (1 thanks)
    3. looks_3 occasionallurker with 1 posts (0 thanks)
    4. looks_4 Big Mike with 1 posts (0 thanks)
    1. trending_up 4,814 views
    2. thumb_up 1 thanks given
    3. group 3 followers
    1. forum 4 posts
    2. attach_file 0 attachments




 
Search this Thread

Custom database with custom tickers. Is it possible ?

  #1 (permalink)
 enjoyaol 
Paris, France
 
Experience: Intermediate
Platform: MT4, Amibroker, Custom
Trading: EUR/USD
Posts: 44 since Jan 2012
Thanks Given: 5
Thanks Received: 27

Hello,
I have generated fantasy data (1000 stocks) in CSV files. These 1000 stocks are not realy one and their tickers are not real ones.

Importing one file is OK, manually using the custom ascii import (I have made a special .format file).

What would be an easy way (using maybe an external software ?) to create a custom database containing the list of tickers (I have) + the CSV files (I have) ?

The goal is to be able to update a CSV file I have and directly see the new charts in amibroker without having to import manually using the ascii import menu. I hope I don't have to create a data plugin using C++ to achieve that ? I could not post this question to the amibroker yahoo group as I'm not a customer yet.

Thanks!

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Online prop firm The Funded Trader (TFT) going under?
Traders Hideout
Exit Strategy
NinjaTrader
NexusFi Journal Challenge - April 2024
Feedback and Announcements
New Micros: Ultra 10-Year & Ultra T-Bond -- Live Now
Treasury Notes and Bonds
Futures True Range Report
The Elite Circle
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
59 thanks
Funded Trader platforms
37 thanks
NexusFi site changelog and issues/problem reporting
24 thanks
GFIs1 1 DAX trade per day journal
22 thanks
The Program
19 thanks
  #2 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,399 since Jun 2009
Thanks Given: 33,175
Thanks Received: 101,539

Simplest is probably scripting something in AutoHotKey to duplicate the interactions needed to import them one at a time, and use it to automate the process.

Mike

We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
  #3 (permalink)
 enjoyaol 
Paris, France
 
Experience: Intermediate
Platform: MT4, Amibroker, Custom
Trading: EUR/USD
Posts: 44 since Jan 2012
Thanks Given: 5
Thanks Received: 27


This seems simple but very slow. I wonder if there is some mechanizm in amibroker to do that without automating the UI ?

Started this thread Reply With Quote
  #4 (permalink)
 iildm 
Italy
 
Experience: Beginner
Platform: AmiBrojer,NinjaTrader,ProRealTime
Trading: STOXX
Posts: 8 since Feb 2011
Thanks Given: 170
Thanks Received: 6

Yes you can use OLE (not too fast, but ..)

The following is just an example using VBS; obviously could be written in Javascript, or Python
(sorry comments are in italian) :

'
' ManageQUANDL
' @info effettua il download e l'import dei dati QUANDL
' Aggiorna il database QuandlEOD
'
' @param sDISCO una stringa che indica il disco in cui risiedono i dati finanziari
' @param oLOG TextStream Object del di log da usare
'
' NOTA : il campo Address deve contenere :
' STOXX,indexID (ossia nome dell'indice stoxx e del file)
'
PUBLIC SUB ManageQUANDL(sDISCO,oLOG)
'
CONST sQUANDLBaseArchiv = "\FINANZA\OTHERS_DATA\QUANDL\"
CONST sQUANDLBaseURL = "http://www.quandl.com/api/v1/datasets/"
CONST sQUANDLAuthURL = "?&auth_token="
CONST sQUANDLEndPartURL = "&sort_order=desc"
'
DIM oAB,oSTOCKS,oStock,sAddress,sURL,sFileTicker,sAmiBrokerFILE
' invia msg apertura
SET oSHELL = CreateObject("WScript.Shell")
iResp = oSHELL.popup("Start Manage QUANDL",1,G_sTITOLO,0)
SET oSHELL = NOTHING
'
oLOG.WriteLine(""+Cstr(Now()) + " Start QUANDL Import")
'
' ottieni FileSystemScripting per creare directory dati (se non esiste)
SET oFSO = CreateObject("Scripting.FileSystemObject")
sAmiBrokerFILE = sDISCO & sQUANDLBaseArchiv
CALL GeneratePath(oFSO,sAmiBrokerFILE)
SET oFSO = NOTHING
'
' loop sui dati di AmiBroker, se trovi dato quandl cerca di caricare/aggiornare
'
' crea AmiBroker, load database
SET oAB = CreateObject("Broker.Application")
sDB = sDISCO & "\\FINANZA\\AB\\QuandlEOD"
CALL oAB.LoadDatabase(sDB)
' l'elenco dei titoli
SET oSTOCKS = oAB.Stocks
iStockQty = oSTOCKS.Count
'
' loop su tutti i titoli prendi solo quelli di QUANDL
' in address : quandl,unique id (nome file),numero rollover per anno correnti,
'
ndownloaded = 0
FOR i = 0 TO (iStockQty-1)
SET oStock = oSTOCKS( i )
sERROR = ""
IF (oStock.Address <> "" ) THEN
sAddress = Split(oStock.Address,",")
IF (UCASE(sAddress(0)) = "QUANDL") THEN
IF UBound(sAddress) < 2 THEN
sERROR = " Error on Address field of " & oStock.Ticker & " of QUANDL(" & oStock.Address & ")"
ELSE
sFileTicker = sAddress(1) & ".csv"
sURL = sQUANDLBaseURL & sFileTicker & sQUANDLAuthURL & G_sQUANDL_TOKEN & sQUANDLEndPartURL
sAmiBrokerFILE = sDISCO & sQUANDLBaseArchiv & oStock.Ticker & ".csv"
' DEBUG ONLY
'oLOG.WriteLine(""+Cstr(Now()) & " debug url=" & sURL& & " AmiBroker file=" & sAmiBrokerFILE)
END IF
IF sERROR <> "" THEN
oLOG.WriteLine(""+Cstr(Now()) + sERROR)
ELSE
ndownloaded = ndownloaded + 1
ierr = DownloadFile(sURL,sAmiBrokerFILE)
IF ierr <> 0 THEN
oLOG.WriteLine(""+Cstr(Now()) & " Error downloading (" &CSTR(ierr)& ") " & sURL & " to file " & sAmiBrokerFILE )
ELSE
CALL oAB.Import(0,sAmiBrokerFILE,"quandl_futures.format")
END IF
END IF
END IF
END IF
NEXT
SET oSTOCKS = NOTHING
SET oStock = NOTHING
' aggiorna AmiBroker, salva e rilascia
'CALL oAB.RefreshAll()
CALL oAB.SaveDatabase()
SET oAB = NOTHING
'
oLOG.WriteLine(""+Cstr(Now()) + " END QUANDL Import ("+Cstr(ndownloaded)+" files)")
' invia msg chiusra
SET oSHELL = CreateObject("WScript.Shell")
iResp = oSHELL.popup("END Manage QUANDL",1,G_sTITOLO,0)
SET oSHELL = NOTHING
END SUB

This example will download and import in AmiBroker QUANDL data.

The idea is :
loop on all tickers, and see the Address field
if address field will indicate to download/import data I usually put inside the field
the path o part of the path for download/import data..

The DownloadFile() is an utility routine that download data :

'
' DownloadFile
' @info effettua il download della sURL indicata nel
' file sLocation indicato torna 0 per OK, -1 per errore
'
' @param sURL la URL completa di cui deve essere fatto il
' download
' @param sLocation il path base di ove vuoi sia archiviato il
' file downloaded, tipicamente si tratta di
' una locazione che poi NON viene cancellata
'
PUBLIC FUNCTION DownloadFile(sURL,sLocation)
On Error Resume NEXT
'
DIM oXMLHTTP,oADOStream,oFSO,oSHELL
' crea l'XMLHTTP per fare la fetch del file
SET oXMLHTTP = CreateObject("MSXML2.XMLHTTP")
' effettua lo GET del file
CALL oXMLHTTP.open("GET", sURL, false)
CALL oXMLHTTP.send()
' se riesce a creare XMLHTTP, crea uno stream e setta i dati
If oXMLHTTP.Status = 200 Then
' crea lo stream
SET oADOStream = CreateObject("ADODB.Stream")
' Apri lo stream appena creato
CALL oADOStream.Open()
' setta lo Stream in modo binario
oADOStream.Type = 1 'adTypeBinary
' setta nello Stream il response body dell'XMLHTTP
CALL oADOStream.Write(oXMLHTTP.ResponseBody)
' setta la posizione dello Stream all'inizio
oADOStream.Position = 0
' crea oggetto per manipolare file system
SET oFSO = Createobject("Scripting.FileSystemObject")
' se il file esiste, cancellalo
If oFSO.Fileexists(sLocation) Then CALL oFSO.DeleteFile(sLocation)
' rilascia oggetto per manipolare file system
SET oFSO = NOTHING
' chiedi allo Stream di scaricare il file e salvarlo
CALL oADOStream.SaveToFile(sLocation)
' chiudi lo Stream
CALL oADOStream.Close()
' rilascia lo stream
SET oADOStream = NOTHING
DownloadFile = 0
ELSE
'
' errors : signal an wait 300 sec or OK
'
SET oSHELL = CreateObject("WScript.Shell")
iRespOK = oSHELL.popup("Site " & sURL & " is unavailable (press OK to continue)",60,"DownloadFile", 48+0 )
SET oSHELL = NOTHING
DownloadFile = -1
END if
' rilascia lo XMLHTTP
SET oXMLHTTP = NOTHING
END FUNCTION


The GeneratePath() is a simple utility function that verify if specified path exists
otherwise create it.

Regards
Luca

Reply With Quote
Thanked by:
  #5 (permalink)
 occasionallurker 
London UK
 
Posts: 18 since Mar 2014


enjoyaol View Post
Hello,
I have generated fantasy data (1000 stocks) in CSV files. These 1000 stocks are not realy one and their tickers are not real ones.

Importing one file is OK, manually using the custom ascii import (I have made a special .format file).

What would be an easy way (using maybe an external software ?) to create a custom database containing the list of tickers (I have) + the CSV files (I have) ?

The goal is to be able to update a CSV file I have and directly see the new charts in amibroker without having to import manually using the ascii import menu. I hope I don't have to create a data plugin using C++ to achieve that ? I could not post this question to the amibroker yahoo group as I'm not a customer yet.

Thanks!

If you don't wanna make a plugin then use import via OLE.
What is the format of your files?

Reply With Quote




Last Updated on March 28, 2014


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts