Izinto ezikhuthaza uphuhliso lwenkonzo yeenkcukacha-manani kuTyalo-mali lwe-Tinkoff yaba:
- NONE _
- uhlalutyo lweminqweno yabasebenzisi beqonga
- inqaku malunga nokubalwa kweekomishini .
- Yintoni eza kuxutyushwa?
- Ukuphuhlisa inkonzo yeenkcukacha-manani inyathelo nenyathelo:
- Uqhagamshelwano kwi-Tinkoff Invest API
- Ukuzoba idatha kwi-Tinkoff Invest API kwisikhangeli
- Ukufumana iingxelo ze-brokerage kunye neentengiselwano
- GetBrokerReport
- Indlela yokufumana umhla, kuthathelwa ingqalelo ukuthabatha ukusuka kumhla wangoku
- Isicelo sokwenziwa kwengxelo
- Iziphumo:
- GetDividendsForeignIssuer
- GetOperationsByCursor
- Ukubalwa kunye nesiphumo solwazi lomdla
- Ukusebenza ngamaxabiso
- Iindleko zeekontraka zexesha elizayo
- Imarike ye-OTC
- Imisebenzi yezibalo kwizixhobo
- I-Microservice ilungile!
- Izigqibo nezicwangciso zexesha elizayo
- https://opexbot.info
Yintoni eza kuxutyushwa?
- Kuphela inxalenye esetyenzisiweyo malunga nophuhliso.
- Ulwazi lokwenene kunye namava, abaluleke kakhulu ekusebenzeni ngezixhobo zemali.
- Isishwankathelo semiba ekufuneka kusetyenzwe kuyo
Ke, ndifuna ukubala izibalo zorhwebo kwaye ndiyenze ngendlela efanelekileyo.
Ukuphuhlisa inkonzo yeenkcukacha-manani inyathelo nenyathelo:
- Uqhagamshelwano kwi-Tinkoff Invest API
- Ukuzoba idatha kwi-Tinkoff Invest API kwisikhangeli
- Ukufumana iingxelo ze-brokerage kunye neentengiselwano
- Ukubalwa kunye nesiphumo solwazi lomdla
- Izigqibo nezicwangciso zexesha elizayo
Uqhagamshelwano kwi-Tinkoff Invest API
Ukuqhagamshela kwi-API, ungathatha nayiphi na i-sdk kumaxwebhu https://github.com/Tinkoff/investAPI#sdk . Okanye iphakheji ye-npm ` tinkoff-sdk-grpc-js `. Kubalulekile ukuba ipakethe ihlaziywe kuguqulelo lwamva nje ngabaphuhlisi. Faka
npm i tinkoff-sdk-grpc-js
Ukujonga
const {dalaSdk } = funa(‘tinkoff-sdk-grpc-js’); // Uphawu olunokufumaneka njengale const TOKEN = ‘YOURAPI’; // Igama lesicelo onokufunyanwa ngalo kwiilog zeTCS. const appName = ‘tcsstat’; const sdk = createSdk(TOKEN, appName); (async () => { console.log(await sdk.users.getAccounts()); })();
Isiphumo: Uluhlu lweeakhawunti zakho luya kuboniswa kwi-console. Umzekelo, makhe sihlalutye ama-nuances:
- Kuluhlu lweeakhawunti kukho “ibhanki yoTyalo-mali”, apho awukwazi ukusebenza usebenzisa i-API
- Nceda uqaphele ukuba amasimi angena kwiCamelCase, ngelixa kuxwebhu le mimandla iboniswe ngaphantsi_kwenqaku.
- Kuya kuba njalo kuyo yonke indawo, ngoko awukwazi nje ukuthatha kwaye ukope intsimi kumaxwebhu.
Iluncedo:
- Ungayifumana le khowudi kwisebe leprojekthi
https://github.com/pskucherov/tcsstat/tree/step1 https://github.com/pskucherov/tcsstat/compare/step1
Ukuzoba idatha kwi-Tinkoff Invest API kwisikhangeli
Ndithathe ngokulandelayo.js kunye ne-socket.io. Oku akusiyo ingcebiso eqinileyo, khetha ngokubona kwakho.
npx yenza-ilandelayo-app@latest npm i socket.io socket.io-client
Ngoko nangoko siqhubela phambili kwinyathelo lobuhlobo elilandelayo+socket+investapi, kwaye ubone icandelo eliluncedo leli nyathelo kuzo zonke iinkcukacha. Ndiza kuchaza iinkcukacha:
- Kwicala le-nodejs (umncedisi), kukho amaphepha/api/investapi.js ifayile. Apha kulapho senza khona iseva ye-socket.io kwaye siqhagamshele kwi-investapi.
- Kwicala lomkhangeli (umxhasi), sixhuma kumncedisi ngesokhethi kwaye sicele idatha ye-akhawunti kumthengisi.
- Sifumana idatha kumthengisi kwiseva, emva koko siyithumele kumxhasi. Xa zifunyenwe kumxhasi, ziboniswa kwisikhangeli.
Isiphumo: kwi-browser console sinokubona ulwazi malunga neeakhawunti. Oko kukuthi, kwinqanaba lokugqibela, sabona ulwazi malunga neeakhawunti kwi-console ye-server (i-nodejs), kwinqanaba langoku, sidlulisele le ngcaciso kumxhasi (isiphequluli).
Ngoku makhe siyenze ukwenzela ukuba ukhethe i-akhawunti kwisiphequluli, kwaye ukuba akukho mqondiso, ke impazamo ithunyelwa kwi-console. Umsebenzi ulula kwaye akukho nto intsha, ke ndinika amakhonkco okuzibophelela kuphela
- https://github.com/pskucherov/tcsstat/commit/7e1ac57061e5e971588479015b06d8814d6609a9
- https://github.com/pskucherov/tcsstat/commit/b28ac973a57494f5232589b4cb6b9fb13b8af759
Iluncedo:
- Indlela yokwenza abahlobo ngokulandelayo kunye nesokhethi ichazwe ngokubanzi apha .
- Ikhowudi yobuhlobo elandelayo+socket+investapi:
https://github.com/pskucherov/tcsstat/commit/a443a4ac1bb4f0aa898f638128755fe7391ee381 Kubani kunzima oku ngasentla, ke sihlala kweli nqanaba kwaye sijongane nekhowudi. Ukuba unemibuzo – buza. https://github.com/pskucherov/tcsstat/tree/step2 https://github.com/pskucherov/tcsstat/compare/step1…step2
Ukufumana iingxelo ze-brokerage kunye neentengiselwano
Kukho iindlela ezintathu zokufumana iingxelo ze-brokerage kunye nokuthengiselana
Ukususela ekuqaleni kubalulekile ukwazi:
- Ingxelo ye-brokerage yenziwa kwimodi ye-T-3, okt. urhwebo luboniswa apho emva kokwenziwa kokwenyani.
- Ngokufanelekileyo, ukuba ucela le ngxelo kwiintsuku ezimbini zokugqibela, iya kuba ilungile ngeentsuku ezintathu.
- Ukwenza izivumelwano ngeentsuku zokugqibela, sisebenzisa indlela yokufumana imisebenzi, kodwa khumbula ukuba i-id kunye nomxholo wabo unokutshintsha emva kokusekwa kwengxelo ye-brokerage.
GetBrokerReport
Ukufumana ingxelo ye-brokerage, kufuneka uthathe i-id ye-akhawunti, umhla wokuqala kunye nomhla wokugqibela wengxelo, kodwa akukho ngaphezu kweentsuku ze-31. Sithumela isicelo sokuvelisa ingxelo kwi-API ekwenzeni _broker_report_request , fumana i-taskId ekuphenduleni. Emva koko, usebenzisa le taskId, sifumana idatha kwi get _broker_report_response. [isihloko sespoiler=”Ke ngoko uxwebhu luthi, eneneni kukho imiba. Bukela izandla zakho:”]
- Kufuneka ugcine i-TaskID ngonaphakade kanye ngale mihla.
- Kuba ukuba uyaphulukana nayo, ke ngeentsuku eziceliweyo ingxelo iya kuqala iphendule kwisicelo sesizukulwana,
- Kwaye ke ayizukuza kwaphela.
[/spoiler] Masiqale ukubhala ikhowudi
Indlela yokufumana umhla, kuthathelwa ingqalelo ukuthabatha ukusuka kumhla wangoku
const getDateSubDay = (uSuku olungaphantsi = 5, qala = yinyaniso) => { umhla we-const = Umhla omtsha (); date.setUTCDate(date.getUTCDate() – subDay); ukuba (ukuqala) { date.setUTCHours(0, 0, 0, 0); } enye { date.setUTCHours(23, 59, 59, 999); } umhla wokubuya; };
Isicelo sokwenziwa kwengxelo
const brokerReport = linda (sdk.operations.getBrokerReport) ({ generateBrokerReportRequest: { accountId, from, to, }, });
Iziphumo:
- Njengesiphumo sokuphunyezwa kokuqala komyalelo, sifumana i-taskId.
- Ingxelo iqala ukuveliswa kwicala lomthengisi. Xa ilungile ayaziwa, siyalinda kwaye ngamaxesha athile sitsale i-taskId ngokulindela ingxelo.
- Ngoba? Kuba ukuba ingxelo ayilungile, iphosa impazamo. Ukuba ingxelo ayilunganga kwicala lomthengisi, ke le yimpazamo kwikhowudi yakho. Nceda uqhubeke: 30058|INVALID_ARGUMENT|umsebenzi awukagqitywa, nceda uzame kwakhona.
Ikhowudi yokulinda nokufumana ingxelo ijongeka ngolu hlobo.
const timer = ixesha le-async => { buyisela iSithembiso esitsha (sombulule => setTimeout(ukusombulula, ixesha)); } const getBrokerResponseByTaskId = async (taskId, page = 0) => { zama { ukubuya ulindele (sdk.operations.getBrokerReport)({ getBrokerReportRequest: { taskId, page, }, }); } bamba (e) { console.log(‘linda’, e); linda ixesha (10000); buyela ulinde getBrokerResponseByTaskId(taskId, page); } }
Emva koko umlingo ofanayo uyenzeka. Simisa iskripthi sethu, siqale kwakhona, asinayo i-taskId. Senza ikhowudi ngesicelo taskId, kodwa asisafumani taskId, kodwa ngoko nangoko ingxelo. Umlingo! Kwaye yonke into yayizakulunga ukuba yayihlala inje. Kodwa ngenyanga akuyi kubakho datha konke konke. Iluncedo :
- Intwana yethiyori ichazwe apha kwaye apha .
- Ukubeka ikhowudi ndawonye, uyilo luya kujongeka ngolu hlobo.
https://github.com/pskucherov/tcsstat/tree/step3.1 https://github.com/pskucherov/tcsstat/compare/step3.1
- Ukuba umntu ufumana oku, wamkelekile kumbandela . Emva kokuba balungise lo mlingo, uya kulahlekelwa amandla kwaye uya kuba ngandlela-thile. Kodwa okwangoku (03/21/2023) isebenza ngolo hlobo.
GetDividendsForeignIssuer
Omnye umntu unokucinga ukuba indlela iyafana naleyo yangaphambili kwaye ungasebenzisa indlela enye apho utshintsha kuphela igama lemisebenzi. Kodwa abazange baqikelele! Ukuthiywa kwamagama apho kwahluke kakhulu kwiindlela kunye nakwingcaciso ebuyisiweyo. Kwaye ubalo lwephepha luqala ku-0, emva koko ukusuka ku-1. Ukuze ungabhideki kuyo yonke le nto, kulula ukubhala iindlela ezimbini ezahlukeneyo. Yintoni engaqhelekanga, kuba ingqiqo yomsebenzi iyafana. Ndatshicela ixesha elide xa ndizama ukwenza indlela enye kwaye kukho ikhowudi encinci. Akusayi kubakho mizekelo apha.
GetOperationsByCursor
Endiyithandayo kwezi zintathu. Nangona ingeyiyo eyona ichanekileyo, kodwa eyona ifanelekileyo. Senza isicelo ukususela ekuqaleni kokudala i-akhawunti ukuya kumhla ophezulu onokwenzeka (ukuvala i-akhawunti okanye le yangoku). Sifumana impendulo, sithathe ikhesa kwaye sicele kwakhona ukuba kukho idatha. Kwaye ikhowudi imfutshane ngakumbi kunale mizekelo ingasentla.
const timer = ixesha le-async => { buyisela iSithembiso esitsha (sombulule => setTimeout(ukusombulula, ixesha)); } const getOperationsByCursor = async (sdk, accountId, ukusuka, ukuya, cursor = ”) => { zama { const reqData = { accountId, ukusuka, ukuya, umda: 1000, state: sdk.OperationState.OPERATION_STATE_EXECUTED, ngaphandle kweeKomishini: bubuxoki, ngaphandle kweTrades: bubuxoki, ngaphandle kobusuku obunye: bubuxoki, ikhesa, }; buyisela linda sdk.operations.getOperationsByCursor(reqData); } bamba (e) { linda isibali-xesha (60000); buyisela linda getOperationsByCursor(sdk, accountId, from, to, cursor = ”); } }
Uyilo oluza kuqhuba lulapha: https://github.com/pskucherov/tcsstat/tree/step3.3 https://github.com/pskucherov/tcsstat/compare/step3.3 Ngoku sikulungele ukongeza imisebenzi yokufumana isicelo sethu. Ukuba yenziwe ngokuchanekileyo, ngoko kufuneka ufumane iingxelo ze-brokerage kubo bonke ubukho be-akhawunti. Kwaye kwidatha elahlekileyo, ezo T-3 ezifanayo, zilayishe kwakhona ukusuka kwimisebenzi. Kodwa oku kunokwahlulwa kwinqaku elahlukileyo. Kwimiba ephambili oya kudibana nayo kukuncamathelisa imisebenzi kunye nengxelo ye-brokerage.
- Ukuba namhlanje ufumene ingxelo ye-brokerage kunye nokuthengiselana kwemihla efunekayo, yibeke yonke kwi-database, ngoko akukho ngxaki.
- Uya kuba neengxaki ngomso xa ufumana inxalenye elandelayo yedatha evela kwingxelo kunye nokusebenza kwaye wenze isigqibo sokuzivumelanisa kunye nedatha ekhoyo.
- Uninzi lwee-nuances malunga nokungahambelani okanye ukutshintsha i-id emva kokulungiswa
- Ke kwimakethi ye-OTC, i-id ayihambelani kwaphela.
- Kanye kunye ne-nuances yezixhobo zokuvumelanisa, eziphinda zingahambelani, ngenxa yezinto ezikhethekileyo ze-API. Kodwa lelinye ibali.
Masiyongeze ukufumana ulwazi malunga nokusebenza kwisicelo sethu. Umbuzo oyintloko uya kuba apho idatha iya kuqhutyelwa khona kwaye igcinwe.
- Ukuba uyazenzela, uya kusebenzisa idatha efanayo kwizixhobo ezahlukeneyo. Emva koko kufuneka usebenze kwaye ugcine idatha kwiseva.
- Ukuba unedatha eninzi eyahlukeneyo esetyenziswe ngabasebenzisi abaninzi abahlukeneyo, ngoko kufuneka unqume oko kubaluleke kakhulu: isantya sabasebenzisi okanye ukugcinwa kwentsimbi kwicala lakho. Nabani na onokukwazi ukufumana isixa esingenasiphelo se-hardware ibala yonke into kwi-server yakhe kwaye yenza ukuba ikhawuleze kakhulu kubasebenzisi, igcina izixhobo zomsebenzisi, ezifana nebhetri kunye ne-traffic, ebaluleke kakhulu kwiifowuni.
Kwelinye icala, ukubala kwibhrawuza ayisosona sisombululo silungileyo ngokomgaqo. Ngoko ke, into engabizi kakhulu, siyiqwalasela kwiseva yethu. Okuseleyo sikushiya kumxhasi. Ndifuna ngokwenene ukuthatha kwaye ndibale ikhomishini kumncedisi. Kodwa nantsi i-nuance ebizwa ngokuba yi “interactivity”. Masithi unamawaka emisebenzi kwaye kuthatha imizuzu emihlanu ukuyifumana. Uya kuba yintoni umsebenzisi ngeli xesha? Ispinner? Inkqubela? Infa malunga nokuba yimalini elayishiwe? Kufanelekile ukusebenzisa “ukulinda okusebenzayo” xa umsebenzisi okwinkqubo sele ebona into. Nasi isiphumo:
- Ukulayishwa kwephepha
- Zonke ii-invoyisi ziyacelwa
- Emva koko, zonke ii-transactions kunye nee-commissions zentengiselwano ezenziweyo ziyacelwa kuzo zonke ii-akhawunti. Njengoko idatha ifunyenwe, inikezelwa kwi-browser.
Ukuze singahluzi idatha kwiziganeko ngexesha ngalinye, sitsala umsitho wethu kwiakhawunti nganye. Ndiyayithanda lento:
socket.emit(‘sdk:getOperationsCommissionResult_’ + accountId, { izinto: data?.items, InProgress: Boolean(nextCursor), });
Idrafti yokuqalisa ilapha: https://github.com/pskucherov/tcsstat/tree/step3 https://github.com/pskucherov/tcsstat/compare/step2…step3 Ukuqhubela phambili. Kuhle ukuba uwufundile lo mgca!
Ukubalwa kunye nesiphumo solwazi lomdla
Kuxhomekeke ekubeni ngubani na ofuna ulwazi. Ke ngoko, ndikuxelela kwangoko ezona nuances ziphambili oza kudibana nazo.
Ukusebenza ngamaxabiso
Wonke umntu osebenza ngemali uyazi ukuba ukuthengiselana ngemali kufuneka kwenziwe kuphela ngamanani apheleleyo. Ngenxa yokungachaneki kwamaxabiso emva kwenqaku ledesimali kunye nempazamo eyongezelekayo ngenani elikhulu lemisebenzi. Yiyo loo nto onke amaxabiso eboniswe ngolu hlobo lulandelayo lweMoneyValue
intsimi | uhlobo | Inkcazo |
---|---|---|
imali | umtya | Umtya ikhowudi yemali ye-ISO |
iiyunithi | int64 | Inani elipheleleyo lesibalo, linokuba linani elithabathayo |
nano | int32 | Inxalenye yesixa-mali, inokuba linani elithabathayo |
Sizicubungula ngokwahlukeneyo, emva koko sizise kwixabiso lexabiso:
ucaphulo.iiyunithi + quotation.nano / 1e9
Iindleko zeekontraka zexesha elizayo
Ixabiso lexesha elizayo linikezelwa ngamanqaku, xa unekamva lemali, kufuneka wazi izinga. Kwaye ngokuqinisekileyo ixabiso kumanqaku kunye nenyathelo lexabiso. Xa ubala inzuzo kwiintengiselwano, oku kunokudubula, kuba. ukuba ubala isixa esipheleleyo ngokuphinda-phinda ixabiso ngobungakanani. Apha kufuneka ulumke. Okwangoku, siza kubona ukuba ihamba njani. Oku kusebenza kwikamva lemali, kwezinye iindawo yonke into ilungile ngale nto.
Imarike ye-OTC
Le ntengiso inezinto ezininzi ezikhethekileyo, ngoko ke masifunde ukusebenza kuyo ngokwahlukeneyo.Xa uqala ungqamaniso lwemisebenzi, kuya kuvela ukuba kufuneka uzise i-figi / iticker kwifomu efanayo ukuze ifanise isixhobo ngokuchanekileyo. Xa uqala ukuvumelanisa oku kunye nengxelo ye-brokerage, kuya kuvela ukuba i-tradeID yentengiselwano efanayo ineeleta ekuqaleni kweentengiselwano kwaye azikho kwingxelo ye-brokerage. Ngoko ke, azinakuthelekiswa … ahem-ahem … ngokuthelekisa! Ndifanise ixesha lorhwebo, iticker kunye nokuthelekisa ukuba tradeId enye iqulethwe kwenye. Kunjalo, andazi. Nabani na odibana nale nto kwaye ngubani oyikhathaleleyo, yiza kumcimbi okanye uqale entsha.
Imisebenzi yezibalo kwizixhobo
Akunakwenzeka, ngaphandle kokujonga, ukwenza imisebenzi yemathematika ngoluhlu lonke. Ukuze singafaki ukufudumala kwi-soft, sihlala sijonga imali kunye nenkqubo kuphela ukuba siqinisekile ukuba imali iyahambelana, kwaye amanqaku aguqulwa abe yimali efunwayo. Exhotywe ngolwazi malunga nokusebenza ngamanani ebhanki, siya kubala ikhomishini echithwe kwi-akhawunti nganye. Njengale: https://github.com/pskucherov/tcsstat/tree/step4 https://github.com/pskucherov/tcsstat/compare/step3…step4
I-Microservice ilungile!
https://github.com/pskucherov/tcsstat Njengomsebenzi wasekhaya, unokujonga ukuba inkonzo isebenza ngoxhulumaniso olucothayo, xa uxhulumaniso luphukile, xa i-intanethi inqanyuliwe, xa iimpazamo okanye imida ephelelwe yisikhathi kwi-broker.
Izigqibo nezicwangciso zexesha elizayo
- Ufunde malunga nokusebenza okusisiseko kunye nokusebenza kunye ne-Invest API
- Ixesha elichithwe ~ iiyure ezili-10
- Inqanaba lobunzima ~ junior+ / low middle
Ukuba uyaqhubeka nokucokisa i-microservice, unokuphela ngento enje
https://opexbot.info
Olu luphuhliso lwam, kwabo bavila kakhulu ukuqonda, ukubaleka kunye nokubala ngokwabo. Ndiceba ukongeza uhlalutyo apho ngesicelo sabasebenzisi. Ukuba ulithandile inqaku, emva koko ubhalise kwitshaneli yetelegram yam .
Полезная статья. Не могу представить, сколько усилий автора потребовалось, чтобы все описать. Благодарю.