Abashishikarije iterambere rya serivisi y’ibarurishamibare ya Tinkoff ishoramari bari:
- ingingo kuri Habré “Ibyo ishoramari rya Tinkoff ntabwo rivuga”
- gusesengura ibyifuzo byabakoresha urubuga
- ingingo yerekeye kubara komisiyo .
- Ni iki kizaganirwaho?
- Gutezimbere serivisi yimibare intambwe ku yindi:
- Kwihuza na Tinkoff gushora API
- Gukuramo amakuru muri Tinkoff Gushora API muri mushakisha
- Kwakira raporo yubucuruzi nubucuruzi
- GetBrokerReport
- Uburyo bwo kubona itariki, urebye gukuramo kuva kumunsi wubu
- Tanga icyifuzo cyo kubyara
- Igisubizo:
- Kubona Kubuntu
- KubonaByCursor
- Kubara no gusohora amakuru yinyungu
- Gukorana n’ibiciro
- Igiciro cyamasezerano yigihe kizaza
- Isoko rya OTC
- Imibare yimibare kubikoresho
- Microservice iriteguye!
- Imyanzuro n’imigambi y’ejo hazaza
- https://opexbot.info
Ni iki kizaganirwaho?
- Gusa igice cyakoreshejwe kubyerekeye iterambere.
- Ubumenyi nyabwo nuburambe, nibyingenzi mugukorana nibikoresho byimari.
- Incamake y’ibibazo byo gukora
Noneho, ndashaka kubara imibare yubucuruzi no kubikora muburyo bworoshye.
Gutezimbere serivisi yimibare intambwe ku yindi:
- Kwihuza na Tinkoff gushora API
- Gukuramo amakuru muri Tinkoff Gushora API muri mushakisha
- Kwakira raporo yubucuruzi nubucuruzi
- Kubara no gusohora amakuru yinyungu
- Imyanzuro n’imigambi y’ejo hazaza
Kwihuza na Tinkoff gushora API
Kugirango uhuze na API, urashobora gufata sdk iyariyo yose uhereye kumyandiko https://github.com/Tinkoff/investAPI#sdk . Cyangwa npm pack ` tinkoff-sdk-grpc-js` . Ni ngombwa ko pake ivugururwa kuri verisiyo iheruka kubateza imbere. Shyiramo
npm i tinkoff-sdk-grpc-js
Kugenzura
const {kuremaSdk} = bisaba (‘tinkoff-sdk-grpc-js’); // Token ishobora kuboneka nkiyi const TOKEN = ‘YOURAPI’; // Izina rya porogaramu ushobora kuyisanga mubiti bya TCS. const appName = ‘tcsstat’; const sdk = kuremaSdk (TOKEN, appName); (async () => { konsole.log (tegereza sdk.abakoresha .
Igisubizo: urutonde rwa konte yawe ruzerekanwa muri konsole. Kurugero, reka dusesengure ibyingenzi:
- Kurutonde rwa konti harimo “Banki yishoramari”, udashobora gukorana ukoresheje API
- Nyamuneka menya ko imirima ije mu ngamiyaCase, mugihe mubyangombwa iyi mirima yerekanwe munsi_score.
- Bizaba nkibi ahantu hose, ntushobora gufata gusa no gukoporora umurima uva mubyangombwa.
Ingirakamaro:
- Urashobora kubona iyi code mumashami yumushinga
https://github.com/pskucherov/tcsstat/tree/step1 https://github.com/pskucherov/tcsstat/compare/step1
Gukuramo amakuru muri Tinkoff Gushora API muri mushakisha
Nafashe ubutaha.js na sock.io. Ibi ntabwo ari ibyifuzo bikomeye, hitamo kubushake bwawe.
npx kurema-ubutaha-porogaramu @ igezweho npm i socket.io sock.io-umukiriya
Turahita dukomeza intambwe yubucuti ubutaha + sock + investapi, hanyuma turebe igice cyingirakamaro cyiyi ntambwe kubisobanuro byose. Nzasobanura ibisobanuro:
- Kuruhande rwa nodejs (seriveri), hari page / api / investapi.js dosiye. Aha niho dushiraho socket.io seriveri hanyuma tugahuza na investapi.
- Kuruhande rwa mushakisha (umukiriya), duhuza seriveri dukoresheje sock hanyuma dusaba amakuru ya konte kuri broker.
- Twakira amakuru yatanzwe na broker kuri seriveri, hanyuma twohereze kubakiriya. Iyo bakiriwe kubakiriya, berekanwa muri mushakisha.
Igisubizo: muri mushakisha ya konsole dushobora kubona amakuru yerekeye konti. Nukuvuga ko, muntambwe yanyuma, twabonye amakuru ajyanye na konti muri seriveri ya seriveri (nodejs), mu ntambwe iriho, twohereje aya makuru ku mukiriya (mushakisha).
Noneho reka tubikore kugirango ubashe guhitamo konte muri mushakisha, kandi niba nta kimenyetso, noneho ikosa ryoherejwe kuri konsole. Akazi karoroshye kandi ntakintu gishya, ndatanga gusa amahuza kubikorwa
- https://github.com/pskucherov/tcsstat/commit/7e1ac57061e5e971588479015b06d8814d6609a9
- https://github.com/pskucherov/tcsstat/commit/b28ac973a57494f5232589b4cb6b9fb13b8af759
Ingirakamaro:
- Nigute ushobora kubona inshuti ubutaha na sock byasobanuwe muburyo burambuye hano .
- Kode yubucuti ikurikira + sock + investapi:
https://github.com/pskucherov/tcsstat/commit/a443a4ac1bb4f0aa898f638128755fe7391ee381 Kubo twavuze haruguru biragoye, noneho tuguma kuriyi ntambwe kandi dukorana na code. Niba ufite ibibazo – baza. https://github.com/pskucherov/tcsstat/tree/step2 https://github.com/pskucherov/tcsstat/compare/step1…step2
Kwakira raporo yubucuruzi nubucuruzi
Hariho uburyo butatu bwo kwakira raporo yubucuruzi
Kuva mu ntangiriro ni ngombwa kumenya:
- Raporo ya brokerage ikorwa muburyo bwa T-3, ni ukuvuga ubucuruzi bwerekanwa hariya nyuma yimikorere yabyo.
- Kubwibyo, niba usabye iyi raporo muminsi ibiri ishize, izaba yiteguye muminsi itatu.
- Kugirango tubone ibicuruzwa muminsi yanyuma, dukoresha uburyo bwo kwakira ibicuruzwa, ariko wibuke ko id hamwe nibirimo bishobora guhinduka nyuma ya raporo yubucuruzi.
GetBrokerReport
Kugirango ubone raporo ya brokerage, ugomba gufata konte id, itariki yo gutangiriraho nitariki ya nyuma ya raporo, ariko ntibirenza iminsi 31. Twohereje icyifuzo cyo gutanga raporo kuri API mukubyara _umukoresha_amakuru_ibisabwa , kubona akaziId mugusubiza. Nyuma yibyo, dukoresheje iki gikorwaId, tubona amakuru yo kubona _broker_report_response.
- Ugomba kubika TaskID ubuziraherezo kuriyi matariki.
- Kuva niba ubuze, noneho kumatariki wasabwe raporo izabanza gusubiza igisubizo cyibisekuru,
- Hanyuma ntabwo bizaza na gato.
[/ uwangiza] Reka dutangire kwandika code
Uburyo bwo kubona itariki, urebye gukuramo kuva kumunsi wubu
const getDateSubDay = (subDay = 5, tangira = ukuri) => { itariki yumunsi = Itariki nshya (); itariki.setUTCDate (itariki. niba (tangira) { itariki.setUTCHours (0, 0, 0, 0); } ikindi { itariki.isomo ryamasomo (23, 59, 59, 999); date itariki yo kugaruka; };
Tanga icyifuzo cyo kubyara
const brokerReport = gutegereza (sdk.operations.getBrokerReport) ({ generateBrokerReportRequest: { konteId, kuva, kugeza, }, });
Igisubizo:
- Nkigisubizo cyambere cyo gutegeka, tubona taskId.
- Raporo itangira gukorerwa kuruhande rwabakozi. Iyo byiteguye ntibizwi, turategereza kandi rimwe na rimwe dukurura taskId mugutegereza raporo.
- Kubera iki? Kuberako niba raporo ititeguye, itera ikosa. Niba raporo ititeguye kuruhande rwa broker, noneho iri ni ikosa muri code yawe. Nyamuneka gutunganya: 30058 | INVALID_ARGUMENT | umurimo utararangira, nyamuneka gerageza nyuma
Kode yo gutegereza no kwakira raporo isa nkiyi.
const timer = async igihe => { subiza Isezerano rishya (gukemura => gushiraho Igihe cyagenwe (gukemura, igihe)); } const getBrokerResponseByTaskId = async (taskId, page = 0) => { gerageza { kugaruka gutegereza (sdk.operations.getBrokerReport) ({ getBrokerReportRequest: { taskId, page, }, }); } gufata (e) { konsole.log (‘gutegereza’, e); gutegereza igihe (10000); garuka utegereze kubonaBrokerResponseByTaskId (taskId, page); } };
Noneho amarozi amwe arabaho. Duhagarika inyandiko zacu, twongere tuyitangire, ntabwo dufite umurimoId. Dukora kode hamwe na taskId icyifuzo, ariko ntitukibona taskId, ariko ako kanya raporo. Ubumaji! Kandi ibintu byose byaba byiza iyo bihora nkibi. Ariko mu kwezi nta makuru azabaho. Ingirakamaro :
https://github.com/pskucherov/tcsstat/tree/step3.1 https://github.com/pskucherov/tcsstat/compare/step3.1
- Niba umuntu ahuye nibi, noneho urakaza neza kubibazo . Nyuma yo gusana ubu bupfumu, buzabura imbaraga kandi bizaba bitandukanye. Ariko magingo aya (03/21/2023) ikora gutya.
Kubona Kubuntu
Umuntu arashobora gutekereza ko uburyo busa nubwa mbere kandi urashobora gukoresha uburyo bumwe uhindura izina ryibikorwa gusa. Ariko ntibakekaga! Kwita izina biratandukanye cyane muburyo ndetse no mumakuru yatashye. Na page yo kubara itangirira kuri 0, hanyuma guhera kuri 1. Kugirango utazitiranya muribi byose, biroroshye kwandika uburyo bubiri butandukanye. Bikaba bidasanzwe, kuko logique y’akazi ni imwe. Naciriye amacandwe igihe kinini mugihe nagerageje gukora uburyo bumwe kandi hari code nke. Hano nta ngero zizabaho.
KubonaByCursor
Nkunda muri bitatu. Nubwo atari ukuri, ariko birahagije. Dutanga icyifuzo kuva twatangira gushiraho konti kumunsi ntarengwa ushoboka (gufunga konti cyangwa iyubu). Twabonye igisubizo, fata indanga hanyuma twongere dusabe igihe cyose hari amakuru. Kandi code irasobanutse kuruta kurugero hejuru.
const timer = async igihe => { subiza Isezerano rishya (gukemura => gushiraho Igihe cyagenwe (gukemura, igihe)); } const getOperationsByCursor = async (sdk, konteId, kuva, kugeza, indanga = ”) => { gerageza { const reqData = { konteId, kuva, kugeza, imipaka: 1000, leta: sdk.Ibikorwa bya Leta.OPERATION_STATE_EXECUT , udafite Ubucuruzi: ibinyoma, nta Ijoro ryose: ibinyoma, indanga, }; garuka utegereze sdk.ibikorwa.ibikorwaByCursor (reqData); } gufata (e) { gutegereza igihe (60000); garuka utegereze kubonaOperationsByCursor (sdk, konteId, kuva, kugeza, indanga = ”); } };
Umushinga wo gukora hano: https://github.com/pskucherov/tcsstat/tree/step3.3 https://github.com/pskucherov/tcsstat/compare/step3.3 Noneho twiteguye kongera ibikorwa byo kwakira Porogaramu. Niba bikozwe neza, ugomba rero kubona raporo ya brokerage kubibaho byose bya konti. Kandi kubintu byabuze, izo T-3s imwe, ongera uve mubikorwa. Ariko ibi birashobora gutandukana mubice bitandukanye. Mubyingenzi byingenzi uzahura nabyo ni uguhuza ibikorwa na raporo ya brokerage.
- Niba uyumunsi wakiriye raporo ya brokerage hamwe nubucuruzi kumatariki asabwa, shyira byose mububiko, noneho ntakibazo.
- Uzagira ibibazo ejo mugihe wakiriye igice gikurikira cyamakuru kuva muri raporo n’ibikorwa hanyuma ugahitamo kubihuza nububiko buriho.
- Byinshi mubyerekeranye no kudahuza cyangwa guhindura id nyuma yo gutunganya
- Noneho ku isoko rya OTC, id idahuye na gato.
- Nka nuance yibikoresho byo guhuza, byongeye ntibihura, kubera umwihariko wa API. Ariko iyo ni iyindi nkuru.
Reka twongere kubona amakuru kubyerekeranye nibikorwa byacu. Ikibazo nyamukuru kizaba aho amakuru azatunganyirizwa akabikwa.
- Niba ubikora wenyine, uzakoresha amakuru amwe mubikoresho bitandukanye. Noneho ugomba gutunganya no kubika amakuru kuri seriveri.
- Niba ufite amakuru menshi atandukanye akoreshwa nabakoresha benshi batandukanye, noneho ugomba guhitamo icyingenzi: umuvuduko wabakoresha cyangwa kuzigama ibyuma kuruhande rwawe. Umuntu wese ushobora kugura ibyuma bitagira ingano bibara ibintu byose kuri seriveri ye kandi bigatuma byihuta cyane kubakoresha, bikiza umutungo wabakoresha, nka bateri na traffic, bifite akamaro kanini kuri terefone.
Na none, kubara muri mushakisha ntabwo aricyo gisubizo cyiza muburyo bwiza. Kubwibyo, ibitari bihenze, tubitekereza kuri seriveri yacu. Ibisigaye tubisigira abakiriya. Ndashaka rwose gufata no kubara komisiyo kuri seriveri. Ariko hano haza nuance yitwa “interaction”. Reka tuvuge ko ufite ibikorwa ibihumbi kandi bisaba iminota itanu yo kubyakira. Ni iki umukoresha azaba afite muri iki gihe? Kuzunguruka? Iterambere? Infa kubyerekeye kangahe? Nibyiza gukoresha “gutegereza gukora” mugihe umukoresha mubikorwa yamaze kubona ikintu. Dore Igisubizo:
- Urupapuro
- Inyemezabuguzi zose zirasabwa
- Nyuma yibyo, ibikorwa byose hamwe na komisiyo kubikorwa byakozwe birasabwa kuri konti zose. Nkuko amakuru yakiriwe, atangwa muri mushakisha.
Kugirango tutayungurura amakuru mubyabaye buri gihe, dukurura ibyabaye kuri buri konte. Nkibi:
sock . _ _
Umushinga wo gutangiza hano: https://github.com/pskucherov/tcsstat/tree/step3 https://github.com/pskucherov/tcsstat/compare/step2…step3 Gukomeza. Nibyiza ko wasomye uyu murongo!
Kubara no gusohora amakuru yinyungu
Biterwa ninde ukeneye amakuru. Kubwibyo, mpita nkubwira ibintu byingenzi uzahura nabyo.
Gukorana n’ibiciro
Umuntu wese ukorana namafaranga azi ko ibikorwa byamafaranga bigomba gukorwa numubare wose. Bitewe no kutamenya neza indangagaciro nyuma yumwanya wa cumi hamwe no kwibeshya hamwe numubare munini wibikorwa. Niyo mpamvu ibiciro byose bitangwa muburyo bukurikira bwa MoneyValue
umurima | Ubwoko | Ibisobanuro |
---|---|---|
ifaranga | umugozi | Ikurikiranyanyuguti rya ISO |
ibice | int64 | Igice cyuzuye cyamafaranga, gishobora kuba umubare mubi |
nano | int32 | Igice cy’igice cy’amafaranga, gishobora kuba umubare mubi |
Turabitunganya ukundi, hanyuma tubazane kubiciro byigiciro:
gusubiramo.units + amagambo.nano / 1e9
Igiciro cyamasezerano yigihe kizaza
Igiciro cyigihe kizaza gitangwa mumanota, mugihe ufite amafaranga yigihe kizaza, ugomba kumenya igipimo. Kandi nukuri igiciro mumanota n’intambwe y’ibiciro. Iyo ubara inyungu ivuye mubikorwa, ibi birashobora kurasa, kuko. niba ubara umubare wuzuye mugwiza igiciro kubwinshi. Hano ugomba kwitonda. Kuri ubu, tuzareba uko bigenda. Ibi bireba amafaranga yigihe kizaza, ahandi hantu byose ni sawa nibi.
Isoko rya OTC
Iri soko rifite umwihariko mwinshi, reka rero twige ibikorwa kuri ryo ukundi. Mugihe utangiye guhuza ibikorwa, bizagaragara ko ugomba kuzana figi / ticker kumiterere imwe kugirango uhuze neza nigikoresho. Mugihe utangiye guhuza ibi na raporo ya brokerage, bizagaragara ko tradeID yubucuruzi bumwe ifite amabaruwa mugitangira mubikorwa kandi ntabwo biri muri raporo yubucuruzi. Kubwibyo, ntibashobora kugereranywa … ahem-ahem … kubigereranya! Nahuje igihe cyubucuruzi, ticker no guhuza ko ubucuruzi bumweId bukubiye mubindi. Nibyo, simbizi. Umuntu wese uhuye nibi kandi ubyitayeho, uze kukibazo cyangwa utangire bundi bushya.
Imibare yimibare kubikoresho
Ntibishoboka, utarebye, gukora imibare hamwe nurutonde rwose. Kugirango tutongeramo ubushyuhe bworoshye, duhora tugenzura ifaranga kandi tugatunganya gusa niba tuzi neza ko ifaranga rihuye, kandi ingingo zigahinduka kumafaranga wifuza. Twifashishije ubumenyi bujyanye no gukorana nimero ya banki, tuzabara komisiyo yakoresheje kuri buri konti. Nkiyi: https://github.com/pskucherov/tcsstat/tree/step4 https://github.com/pskucherov/tcsstat/compare/step3…step4
Microservice iriteguye!
https :
Imyanzuro n’imigambi y’ejo hazaza
- Yize kubyerekeye ibikorwa byibanze no gukorana nishoramari API
- Igihe cyakoreshejwe ~ amasaha 10
- Urwego rutoroshye ~ muto + / hagati
Niba ukomeje kunonosora microservice, ushobora kurangiza nibintu nkibi
https://opexbot.info
Iri niryo terambere ryanjye, kubanebwe cyane kubyumva, kwiruka no kubara bonyine. Ndateganya kongeramo analyse ngaho mbisabwe nabakoresha. Niba ukunda ingingo, iyandikishe kumuyoboro wa telegaramu .
Полезная статья. Не могу представить, сколько усилий автора потребовалось, чтобы все описать. Благодарю.